当前位置: 首页>>代码示例>>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;未经允许,请勿转载。