本文整理匯總了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);
}