本文整理汇总了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();
}
示例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);
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}
示例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));
}
示例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();
}
示例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();
}
示例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();
}
示例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();
}