當前位置: 首頁>>代碼示例>>PHP>>正文


PHP WP_Mock::expectActionAdded方法代碼示例

本文整理匯總了PHP中WP_Mock::expectActionAdded方法的典型用法代碼示例。如果您正苦於以下問題:PHP WP_Mock::expectActionAdded方法的具體用法?PHP WP_Mock::expectActionAdded怎麽用?PHP WP_Mock::expectActionAdded使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在WP_Mock的用法示例。


在下文中一共展示了WP_Mock::expectActionAdded方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: test_actions_added_in_constructor

 /**
  * This is INSANE - don't put your actions in a constructor.
  */
 function test_actions_added_in_constructor()
 {
     $class = new \ReflectionClass('\\tenup\\demo\\Real_World_Class');
     $object = $class->newInstanceWithoutConstructor();
     \WP_Mock::expectActionAdded('init', [$object, 'action_init']);
     $object->__construct();
 }
開發者ID:ryanwelcher,項目名稱:unit-test-wp-mock,代碼行數:10,代碼來源:Real_World_Tests.php

示例2: test_textarea_wysiwyg

 public function test_textarea_wysiwyg()
 {
     $textarea = new Textarea('mon_textarea', null, "mon_textarea_id", array('wysiwyg' => true));
     \WP_Mock::expectActionAdded('admin_print_footer_scripts', array($textarea, 'addEditorTinymce'), 99);
     $html = $textarea->getDisplay();
     $this->assertRegExp('/<textarea(. *)+><\\/textarea>/', $html);
 }
開發者ID:Weysan,項目名稱:wp-framework-backend-form,代碼行數:7,代碼來源:TextareaTest.php

示例3: test_init_non_admin

 public function test_init_non_admin()
 {
     \WP_Mock::wpFunction('is_admin', array('return' => true));
     $plugin = new SpiderBlocker();
     \WP_Mock::expectActionAdded('generate_rewrite_rules', array($plugin, 'generateRewriteRules'));
     $plugin->__construct();
     \WP_Mock::assertHooksAdded();
 }
開發者ID:lacmkt,項目名稱:spiderblocker,代碼行數:8,代碼來源:TestBlocker.php

示例4: testRegister

 public function testRegister()
 {
     $useAtom = new \Dxw\Iguana\Extras\UseAtom();
     $this->assertInstanceOf(\Dxw\Iguana\Registerable::class, $useAtom);
     \WP_Mock::expectActionAdded('init', [$useAtom, 'init']);
     \WP_Mock::expectActionAdded('wp_head', [$useAtom, 'wpHead']);
     $useAtom->register();
 }
開發者ID:dxw,項目名稱:iguana-extras,代碼行數:8,代碼來源:use_atom_test.php

示例5: test_initialize

 /**
  * @covers tfrommen\ThatWasHelpful\Controllers\Action::initialize
  *
  * @return void
  */
 public function test_initialize()
 {
     /** @var tfrommen\ThatWasHelpful\Models\Post $post */
     $post = Mockery::mock('tfrommen\\ThatWasHelpful\\Models\\Post');
     $testee = new Testee($post);
     WP_Mock::expectActionAdded('template_redirect', array($post, 'update_http'));
     $testee->initialize();
     $this->assertHooksAdded();
 }
開發者ID:tfrommen,項目名稱:that-was-helpful,代碼行數:14,代碼來源:ActionControllerTest.php

示例6: test_initialize

 public function test_initialize()
 {
     $model = Mockery::mock('tfrommen\\ExternalContent\\Models\\PostType');
     /** @var tfrommen\ExternalContent\Models\PostType $model */
     $testee = new Testee($model);
     WP_Mock::expectActionAdded('wp_loaded', array($model, 'register'));
     $testee->initialize();
     $this->assertHooksAdded();
 }
開發者ID:tfrommen,項目名稱:external-content,代碼行數:9,代碼來源:PostTypeControllerTest.php

示例7: test_init

 /**
  * Test theme setup
  *
  * @since 5.0.0
  */
 function test_init()
 {
     // Setup.
     \WP_Mock::wpPassthruFunction('remove_action');
     \WP_Mock::expectActionAdded('after_setup_theme', 'CW\\Theme\\Functions\\Core\\action_after_setup_theme');
     // Act.
     init();
     // Verify.
     $this->assertConditionsMet();
 }
開發者ID:ChrisWiegman,項目名稱:chriswiegman-theme,代碼行數:15,代碼來源:Core_Tests.php

示例8: test_init

 /**
  * Test that the actions are successfully added.
  */
 public function test_init()
 {
     $this->dt = new \notne\Da_Tag\Da_Tag(dirname(__FILE__) . '/../');
     \WP_Mock::expectActionAdded('admin_notices', array($this->dt, 'admin_notices'), 10, 1);
     \WP_Mock::expectActionAdded('admin_init', array($this->dt, 'admin_notices_ignore'));
     \WP_Mock::expectActionAdded('save_post', array($this->dt, 'save_highlighted_tag'), 10, 3);
     \WP_Mock::expectActionAdded('admin_enqueue_scripts', array($this->dt, 'enqueues'));
     \WP_Mock::expectFilterAdded('post_submitbox_misc_actions', array($this->dt, 'highlight_tag'));
     $this->dt->init();
 }
開發者ID:rwrobe,項目名稱:datag,代碼行數:13,代碼來源:Da_TagTest.php

示例9: test_setup

 /** 
  * Test load method.
  */
 public function test_setup()
 {
     // Setup
     \WP_Mock::expectActionAdded('init', 'Stream\\Stream_Notifications\\Core\\i18n');
     \WP_Mock::expectActionAdded('init', 'Stream\\Stream_Notifications\\Core\\init');
     \WP_Mock::expectAction('stream_notifications_loaded');
     // Act
     setup();
     // Verify
     $this->assertConditionsMet();
 }
開發者ID:xwp,項目名稱:stream-notifications,代碼行數:14,代碼來源:Core_Tests.php

示例10: test_add_hooks

 public function test_add_hooks()
 {
     $instance = new RevisionStrike();
     $settings = new RevisionStrikeSettings();
     $instance->settings = $settings;
     M::expectActionAdded(RevisionStrike::STRIKE_ACTION, array($instance, 'strike'));
     M::expectActionAdded('admin_init', array($settings, 'add_settings_section'));
     M::expectActionAdded('admin_menu', array($settings, 'add_tools_page'));
     M::expectActionAdded('wp_delete_post_revision', array($instance, 'count_deleted_revision'));
     $instance->add_hooks();
 }
開發者ID:stevegrunwell,項目名稱:revision-strike,代碼行數:11,代碼來源:RevisionStrikeTest.php

示例11: test_clean_with_verbose_argument

 public function test_clean_with_verbose_argument()
 {
     $instance = Mockery::mock('RevisionStrike')->makePartial();
     $instance->shouldReceive('strike')->once();
     $instance->shouldReceive('get_stats')->once()->andReturn(array('deleted' => 0));
     $cli = Mockery::mock('RevisionStrikeCLI')->shouldAllowMockingProtectedMethods()->makePartial();
     $cli->shouldReceive('get_instance')->once()->andReturn($instance);
     M::wpPassthruFunction('esc_html__');
     M::expectActionAdded('wp_delete_post_revision', array($cli, 'log_deleted_revision'), 10, 2);
     $cli->clean(array(), array('verbose' => true));
 }
開發者ID:stevegrunwell,項目名稱:revision-strike,代碼行數:11,代碼來源:CLITest.php

示例12: test_setup

 /**
  * Test load method.
  */
 public function test_setup()
 {
     // Setup
     M::expectActionAdded('init', 'EAMann\\Dynamic_CDN\\Core\\init');
     M::expectActionAdded('dynamic_cdn_init', 'EAMann\\Dynamic_CDN\\Core\\initialize_manager');
     M::expectAction('dynamic_cdn_first_loaded');
     // Act
     setup();
     // Verify
     $this->assertConditionsMet();
 }
開發者ID:ericmann,項目名稱:dynamic-cdn,代碼行數:14,代碼來源:Core_Tests.php

示例13: test_initialize

 /**
  * @covers tfrommen\ThatWasHelpful\Controllers\AJAX::initialize
  *
  * @return void
  */
 public function test_initialize()
 {
     $action = 'action';
     /** @var tfrommen\ThatWasHelpful\Models\Script $script */
     $script = Mockery::mock('tfrommen\\ThatWasHelpful\\Models\\Script')->shouldReceive('get_action')->andReturn($action)->getMock();
     /** @var tfrommen\ThatWasHelpful\Models\Post $post */
     $post = Mockery::mock('tfrommen\\ThatWasHelpful\\Models\\Post');
     $testee = new Testee($script, $post);
     WP_Mock::expectActionAdded("wp_ajax_{$action}", array($post, 'update_ajax'));
     $testee->initialize();
     $this->assertHooksAdded();
 }
開發者ID:tfrommen,項目名稱:that-was-helpful,代碼行數:17,代碼來源:AJAXControllerTest.php

示例14: test_initialize

 public function test_initialize()
 {
     $model = Mockery::mock('tfrommen\\ExternalContent\\Models\\MetaBox');
     $view = Mockery::mock('tfrommen\\ExternalContent\\Views\\MetaBox');
     /** @var tfrommen\ExternalContent\Models\MetaBox $model */
     /** @var tfrommen\ExternalContent\Views\MetaBox $view */
     $testee = new Testee($model, $view);
     WP_Mock::expectActionAdded('add_meta_boxes', array($view, 'add'));
     WP_Mock::expectActionAdded('save_post', array($model, 'save'), 10, 2);
     $testee->initialize();
     $this->assertHooksAdded();
 }
開發者ID:tfrommen,項目名稱:external-content,代碼行數:12,代碼來源:MetaBoxControllerTest.php

示例15: test_initialize

 /**
  * @covers tfrommen\ThatWasHelpful\Controllers\Asset::initialize
  *
  * @return void
  */
 public function test_initialize()
 {
     /** @var tfrommen\ThatWasHelpful\Models\Script $script */
     $script = Mockery::mock('tfrommen\\ThatWasHelpful\\Models\\Script');
     /** @var tfrommen\ThatWasHelpful\Models\Style $style */
     $style = Mockery::mock('tfrommen\\ThatWasHelpful\\Models\\Style');
     $testee = new Testee($script, $style);
     WP_Mock::expectActionAdded('wp_footer', array($script, 'enqueue'));
     WP_Mock::expectActionAdded('wp_footer', array($style, 'enqueue'));
     $testee->initialize();
     $this->assertHooksAdded();
 }
開發者ID:tfrommen,項目名稱:that-was-helpful,代碼行數:17,代碼來源:AssetControllerTest.php


注:本文中的WP_Mock::expectActionAdded方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。