當前位置: 首頁>>代碼示例>>PHP>>正文


PHP WP_Mock::expectAction方法代碼示例

本文整理匯總了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.');
 }
開發者ID:tfrommen,項目名稱:testable-code,代碼行數:14,代碼來源:HookOracleWP_MockTest.php

示例2: test_init

 /** 
  * Test initialization method.
  */
 public function test_init()
 {
     // Setup
     \WP_Mock::expectAction('a1dmonitor_init');
     // Act
     init();
     // Verify
     $this->assertConditionsMet();
 }
開發者ID:aldeloren,項目名稱:a1d-wp-monitoring,代碼行數:12,代碼來源:Core_Tests.php

示例3: test_init

 /**
  * Test initialization method.
  */
 public function test_init()
 {
     // Setup
     M::expectAction('dynamic_cdn_init');
     // Act
     init();
     // Verify
     $this->assertConditionsMet();
 }
開發者ID:ericmann,項目名稱:dynamic-cdn,代碼行數:12,代碼來源:Core_Tests.php

示例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();
 }
開發者ID:ChrisWiegman,項目名稱:chriswiegman-plugin,代碼行數:18,代碼來源:Core_Tests.php

示例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';
 }
開發者ID:eriktorsner,項目名稱:wp-bootstrap-test,代碼行數:18,代碼來源:ImportTest.php

示例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);
 }
開發者ID:ryanwelcher,項目名稱:unit-test-wp-mock,代碼行數:8,代碼來源:WP_Mock_Tests.php


注:本文中的WP_Mock::expectAction方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。