本文整理汇总了PHP中WP_Mock::expectAction方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_Mock::expectAction方法的具体用法?PHP WP_Mock::expectAction怎么用?PHP WP_Mock::expectAction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WP_Mock
的用法示例。
在下文中一共展示了WP_Mock::expectAction方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: test_get_answer
/**
* Test for the get_answer() method.
*
* @covers HookOracle::get_answer()
*
* @return void
*/
public function test_get_answer()
{
$testee = new HookOracle();
WP_Mock::expectAction('give_answer');
WP_Mock::onFilter('the_answer')->with('42')->reply('4815162342');
$this->assertSame('4815162342', $testee->get_answer(), 'get_answer() should return the expected answer.');
}
示例2: test_init
/**
* Test initialization method.
*/
public function test_init()
{
// Setup
\WP_Mock::expectAction('a1dmonitor_init');
// Act
init();
// Verify
$this->assertConditionsMet();
}
示例3: test_init
/**
* Test initialization method.
*/
public function test_init()
{
// Setup
M::expectAction('dynamic_cdn_init');
// Act
init();
// Verify
$this->assertConditionsMet();
}
示例4: test_action_plugins_loaded
/**
* Test internationalization integration.
*
* @since 3.2.0
*/
public function test_action_plugins_loaded()
{
// Setup.
\WP_Mock::wpFunction('get_locale', array('times' => 1, 'args' => array(), 'return' => 'en_US'));
\WP_Mock::onFilter('plugin_locale')->with('en_US', 'chriswiegman')->reply('en_US');
\WP_Mock::wpFunction('load_textdomain', array('times' => 1, 'args' => array('chriswiegman', 'lang_dir/chriswiegman/chriswiegman-en_US.mo')));
\WP_Mock::wpFunction('load_plugin_textdomain', array('times' => 1, 'args' => array('chriswiegman', false, CW_PLUGIN_PATH . '/languages/')));
\WP_Mock::expectAction('chriswiegman_plugins_loaded');
// Act.
action_plugins_loaded();
// Verify.
$this->assertConditionsMet();
}
示例5: mockForImport
protected function mockForImport()
{
global $wpdb;
\WP_Mock::wpFunction('wp_cache_flush');
\WP_Mock::wpFunction('get_option', ['args' => ['siteurl'], 'times' => '2+', 'return' => 'http://www.example.com']);
\WP_Mock::wpFunction('get_option', ['args' => ['sidebars_widgets', []], 'times' => '1+', 'return' => []]);
\WP_Mock::wpFunction('get_option', ['args' => ['page_on_front', 0], 'times' => '1+', 'return' => 12]);
\WP_Mock::wpFunction('wp_upload_dir', ['times' => '0+', 'return' => ['basedir' => '/tmp/import']]);
\WP_Mock::wpFunction('get_taxonomies', ['times' => '1+', 'return' => ['category' => 'category']]);
\WP_Mock::wpFunction('update_option', ['times' => '0+']);
\WP_Mock::expectAction('wp-bootstrap_before_import');
\WP_Mock::expectAction('wp-bootstrap_after_import_settings');
\WP_Mock::expectAction('wp-bootstrap_after_import_content');
\WP_Mock::expectAction('wp-bootstrap_after_import');
$wpdb = $this->getMock('wpdb', ['get_var', 'prepare']);
$wpdb->expects($this->any())->method('prepare')->will($this->returnValue(''));
$wpdb->posts = 'wp_posts';
}
示例6: test_custom_action_with_params
/**
* Testing a custom action that has a parameter
*/
function test_custom_action_with_params()
{
\WP_Mock::expectAction('above_staff_avatar', 12345);
\tenup\demo\generate_staff_avatar(12345);
}