当前位置: 首页>>代码示例>>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;未经允许,请勿转载。