本文整理汇总了PHP中WP_Mock::expectFilterAdded方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_Mock::expectFilterAdded方法的具体用法?PHP WP_Mock::expectFilterAdded怎么用?PHP WP_Mock::expectFilterAdded使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WP_Mock
的用法示例。
在下文中一共展示了WP_Mock::expectFilterAdded方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testRegister
public function testRegister()
{
$layoutRegister = new \Dxw\Iguana\Theme\LayoutRegister($this->getHelpers());
$this->assertInstanceOf(\Dxw\Iguana\Registerable::class, $layoutRegister);
\WP_Mock::expectFilterAdded('template_include', [\Dxw\Iguana\Theme\Layout::class, 'apply'], 99);
$layoutRegister->register();
}
示例2: test_ready_priority
/**
* Tests hooking the template loader to the WordPress template loading filters
* with a priority.
*
* @covers ::ready
*
* @dataProvider loader_provider
*/
public function test_ready_priority(Loader $loader)
{
$priority = rand(11, 99);
\WP_Mock::expectFilterAdded('template_include', array($loader, 'filter'), $priority);
$loader->ready($priority);
$this->assertHooksAdded();
}
示例3: testInit
public function testInit()
{
$useAtom = new \Dxw\Iguana\Extras\UseAtom();
\WP_Mock::expectFilterAdded('default_feed', [$useAtom, 'defaultFeed']);
\WP_Mock::wpFunction('remove_action', ['args' => ['do_feed_rdf', 'do_feed_rdf', 10, 1], 'times' => 1]);
\WP_Mock::wpFunction('remove_action', ['args' => ['do_feed_rss', 'do_feed_rss', 10, 1], 'times' => 1]);
\WP_Mock::wpFunction('remove_action', ['args' => ['do_feed_rss2', 'do_feed_rss2', 10, 1], 'times' => 1]);
$useAtom->init();
}
示例4: test_initialize
public function test_initialize()
{
$model = Mockery::mock('tfrommen\\ExternalContent\\Models\\Post');
/** @var tfrommen\ExternalContent\Models\Post $model */
$testee = new Testee($model);
WP_Mock::expectFilterAdded('post_type_link', array($model, 'get_external_url'), 10, 2);
WP_Mock::expectFilterAdded('pre_get_shortlink', array($model, 'get_shortlink'), 10, 3);
$testee->initialize();
$this->assertHooksAdded();
}
示例5: 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();
}
示例6: test_construct
/**
* Test constructor
*
* @since 4.0.0
*/
public function test_construct()
{
// Setup.
$journal = new Journal();
\WP_Mock::expectActionAdded('init', array($journal, 'create_journal_type'));
\WP_Mock::expectActionAdded('save_post', array($journal, 'journal_save_morning_meta'), 10, 2);
\WP_Mock::expectActionAdded('save_post', array($journal, 'journal_save_evening_meta'), 10, 2);
\WP_Mock::expectFilterAdded('wp_insert_post_data', array($journal, 'filter_wp_insert_post_data'), 10, 2);
// Act.
$journal->__construct();
// Verify.
$this->assertConditionsMet();
}
示例7: test_setup
/**
* Test load method.
*
* @since 3.2.0
*/
public function test_setup()
{
// Setup.
\Mockery::mock('WP_Widget');
\WP_Mock::wpFunction('current_time', array('times' => 1, 'return_arg' => time()));
\WP_Mock::expectActionAdded('dashboard_glance_items', 'CW\\Plugin\\Core\\action_dashboard_glance_items');
\WP_Mock::expectActionAdded('plugins_loaded', 'CW\\Plugin\\Core\\action_plugins_loaded');
\WP_Mock::expectActionAdded('widgets_init', 'CW\\Plugin\\Core\\action_widgets_init');
\WP_Mock::expectFilterAdded('user_contactmethods', 'CW\\Plugin\\Core\\filter_user_contactmethods');
// Act.
setup();
// Verify.
$this->assertConditionsMet();
}
示例8: test_handle_postback
public function test_handle_postback()
{
$async = $this->getMockAsync('Async', array('verify_async_nonce', 'run_action'));
$nonce = 'asdfasdf';
$_POST['_nonce'] = $nonce;
$async->shouldReceive('verify_async_nonce')->once()->with($nonce)->andReturn(true);
WP_Mock::wpFunction('is_user_logged_in', array('times' => 1, 'return' => true));
$async->shouldReceive('run_action')->once()->with();
WP_Mock::expectFilterAdded('wp_die_handler', function () {
die;
});
WP_Mock::wpFunction('wp_die', array('times' => 1));
/** @var Async $async */
$async->handle_postback();
$action = new ReflectionProperty('Async', 'action');
$action->setAccessible(true);
$this->assertEquals('async', $action->getValue($async));
$this->assertConditionsMet();
}
示例9: test_safe_exit
/**
* Ensure the safe exit function adds the appropriate filters and
* invokes `wp_die()` in the end.
*/
public function test_safe_exit()
{
M::wpFunction('wp_die', ['times' => 1]);
$handler = function () {
return function () {
die;
};
};
M::expectFilterAdded('wp_die_ajax_handler', $handler);
M::expectFilterAdded('wp_die_xmlrpc_handler', $handler);
M::expectFilterAdded('wp_die_handler', $handler);
safe_exit();
$this->assertConditionsMet();
}
示例10: testAddedGalleryShortcodeParsing
/**
*
*/
public function testAddedGalleryShortcodeParsing()
{
\WP_Mock::expectFilterAdded('post_gallery', array($this->shortcodeParser, 'galleryCallback'), 0, 2);
$this->shortcodeParser->addFilters();
}