本文整理汇总了PHP中WP_Mock::wpPassthruFunction方法的典型用法代码示例。如果您正苦于以下问题:PHP WP_Mock::wpPassthruFunction方法的具体用法?PHP WP_Mock::wpPassthruFunction怎么用?PHP WP_Mock::wpPassthruFunction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WP_Mock
的用法示例。
在下文中一共展示了WP_Mock::wpPassthruFunction方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
public function setUp()
{
parent::setUp();
// We are not testing escaping functions so let them passthrough
\WP_Mock::wpPassthruFunction('absint');
\WP_Mock::wpPassthruFunction('esc_url');
}
示例2: test_get_field
/**
* @covers tfrommen\ThatWasHelpful\Models\Nonce::get_field
* @dataProvider provide_get_data
*
* @param string $response
* @param string $action
*/
public function test_get_field($response, $action)
{
$testee = new Testee('class_action');
WP_Mock::wpPassthruFunction('wp_nonce_field', array('times' => 1, 'args' => array(WP_Mock\Functions::type('string'), WP_Mock\Functions::type('string'), WP_Mock\Functions::type('bool'), WP_Mock\Functions::type('bool'))));
$this->assertSame($response, $testee->get_field($action));
$this->assertConditionsMet();
}
示例3: test_load_message_scenarios
public function test_load_message_scenarios()
{
$defaults = array('days' => 30, 'limit' => 50);
$_GET = array('nonce' => true);
$_POST = $defaults;
$instance = Mockery::mock('RevisionStrike')->makePartial();
$instance->shouldReceive('strike')->with($defaults);
$instance->shouldReceive('get_stats')->times(3)->andReturn(array('count' => 0), array('count' => 5, 'deleted' => 0), array('count' => 5, 'deleted' => 5));
M::wpFunction('wp_verify_nonce', array('return' => true));
M::wpFunction('_n', array('times' => 1, 'return' => '%d post revisions'));
M::wpPassthruFunction('wp_nonce_url');
M::wpPassthruFunction('submit_button');
// Pass 1: no revisions found
ob_start();
include $this->tools_file;
$result = ob_get_contents();
ob_end_clean();
$this->assertContains('<div class="error"><p>', $result, 'No revisions found did not trigger an error message');
// Pass 2: revisions found, but nothing deleted
ob_start();
include $this->tools_file;
$result = ob_get_contents();
ob_end_clean();
$this->assertContains('<div class="error"><p>', $result, 'The user should be warned when revisions were found be we can\'t delete them');
// Pass 3: revisions deleted successfully
ob_start();
include $this->tools_file;
$result = ob_get_contents();
ob_end_clean();
$this->assertContains('<div class="updated"><p>', $result, 'Notify the user when revisions are deleted');
$this->assertContains('5 post revisions', $result, 'Display the number of revisions that were removed.');
unset($_GET, $_POST);
}
示例4: test_getter_exception
/**
* Invalid items in the getter should return a WP_Error instance
*/
public function test_getter_exception()
{
require_once 'dummy-files/wp_error.php';
\WP_Mock::wpPassthruFunction('__');
$context = new WP_TemplateContext();
$context->invalid;
$this->assertInstanceOf('WP_Error', $context->invalid);
}
示例5: test_register
public function test_register()
{
$testee = new Testee();
WP_Mock::wpPassthruFunction('_x', array('args' => array(WP_Mock\Functions::type('string'), WP_Mock\Functions::type('string'), 'external-content')));
WP_Mock::wpPassthruFunction('__', array('args' => array(WP_Mock\Functions::type('string'), 'external-content')));
WP_Mock::wpFunction('register_post_type', array('times' => 1, 'args' => array('external_content', WP_Mock\Functions::type('array'))));
$testee->register();
$this->assertConditionsMet();
}
示例6: testBuildPostTypeExpectsRegisterPostTypeCalledOnce
function testBuildPostTypeExpectsRegisterPostTypeCalledOnce()
{
// Arrange
$PostTypeObj = new PostTypeObj();
\WP_Mock::wpPassthruFunction('wp_parse_args', array('times' => 1));
\WP_Mock::wpPassthruFunction('register_post_type', array('times' => 1));
// Act
$PostTypeObj->build_post_type('Custom', 'Customs', 'custom', $prefix = 'cfpb_', $args = array('has_archive' => false, 'rewrite' => array('slug' => 'regulations', 'with_front' => false), 'supports' => array('title', 'editor', 'revisions', 'page-attributes', 'custom-fields')));
}
示例7: test_init
/**
* Test theme setup
*
* @since 5.0.0
*/
function test_init()
{
// Setup.
\WP_Mock::wpPassthruFunction('remove_action');
\WP_Mock::expectActionAdded('after_setup_theme', 'CW\\Theme\\Functions\\Core\\action_after_setup_theme');
// Act.
init();
// Verify.
$this->assertConditionsMet();
}
示例8: test_srcset_replacement_no_protocol_cdn
public function test_srcset_replacement_no_protocol_cdn()
{
$manager = Base\DomainManager('http://test1.com');
$manager->add('cdn1.com');
// Mocks
M::wpFunction('is_ssl', ['return' => false]);
M::wpPassthruFunction('esc_url');
$source = ['url' => 'http://test1.com/image.jpg'];
$replacer = srcset_replacer('http://test1.com');
$this->assertEquals('http://cdn1.com/image.jpg', $replacer($source)['url']);
}
示例9: plugin
protected function plugin()
{
// functions used as part of constructor
Mock::wpPassthruFunction('untrailingslashit');
Mock::wpFunction('plugin_dir_path', array('args' => bootstrap()->get_framework_path() . '/woocommerce/class-sv-wc-plugin.php', 'return' => bootstrap()->get_framework_path() . '/woocommerce'));
Mock::wpFunction('is_admin', array('return' => true));
Mock::wpPassthruFunction('plugin_basename');
Mock::wpFunction('has_action', array('return' => true));
$args = array('mock', '7.7.7', 'woocommerce-mock', 'args' => array('dependencies' => 'json', 'function_dependencies' => 'ftp_ssl_connect'));
return $this->getMockBuilder('SV_WC_Plugin')->setConstructorArgs($args)->getMockForAbstractClass();
}
示例10: test_load
/**
* @covers tfrommen\ThatWasHelpful\Models\TextDomain::load
*
* @return void
*/
public function test_load()
{
$file = '/path/to/file.php';
$domain = 'text-domain';
$path = '/domain';
WP_Mock::wpPassthruFunction('plugin_basename', array('times' => 1, 'args' => array(WP_Mock\Functions::type('string'))));
$testee = new Testee($file, $domain, $path);
$path = dirname($file) . $path;
WP_Mock::wpFunction('load_plugin_textdomain', array('times' => 1, 'args' => array($domain, FALSE, $path)));
$testee->load();
$this->assertConditionsMet();
}
示例11: test_init_widgets
public function test_init_widgets()
{
$widget = new Widget();
\WP_Mock::expectActionAdded('widgets_init', array($widget, 'registerWidgets'));
$widget->init();
\WP_Mock::wpPassthruFunction('register_widget', array('times' => 1, 'args' => array('Lnh\\Widget\\LastMatch\\LastMatch')));
\WP_Mock::wpPassthruFunction('register_widget', array('times' => 1, 'args' => array('Lnh\\Widget\\NextMatch\\NextMatch')));
\WP_Mock::wpPassthruFunction('register_widget', array('times' => 1, 'args' => array('Lnh\\Widget\\Calendar\\Calendar')));
\WP_Mock::wpPassthruFunction('register_widget', array('times' => 1, 'args' => array('Lnh\\Widget\\Calendar\\Short\\CalendarShort')));
\WP_Mock::wpPassthruFunction('register_widget', array('times' => 1, 'args' => array('Lnh\\Widget\\Classement\\Classement')));
$widget->registerWidgets();
}
示例12: test_domain_replacement_mixed
public function test_domain_replacement_mixed()
{
$manager = DomainManager('http://test.com');
$manager->add('https://cdn1.com');
$original = 'http://test.com/image.png';
$expected = 'https://cdn1.com/image.png';
// Mocks
M::wpFunction('is_ssl', ['return' => false]);
M::wpPassthruFunction('esc_url');
// Verify
$this->assertEquals($expected, $manager->new_url($original));
}
示例13: testLoginTransientExpectsTransientSet
function testLoginTransientExpectsTransientSet()
{
$user_obj = new StdClass();
$user_obj->ID = 1;
$L = new \gboone\LoginLockout();
\WP_Mock::wpFunction('set_transient', array('times' => 1));
\WP_Mock::wpPassthruFunction('wp_die');
$user_id = \WP_Mock::wpFunction('get_user_by', array('times' => 1, 'args' => array('slug', 'user'), 'return' => $user_obj));
\WP_Mock::wpFunction('get_transient', array('times' => 1, 'return' => false));
// Act
$L->login_transient('user');
// Test fails if set_transient isn't called
}
示例14: test_save_item_multiple
public function test_save_item_multiple()
{
$importer = new Import($this->createItem(10));
\WP_Mock::wpPassthruFunction('get_posts', array('times' => 1));
\WP_Mock::wpPassthruFunction('wp_insert_post', array('times' => 1));
\WP_Mock::wpPassthruFunction('update_post_meta', array('times' => 10));
$importer->save();
$importer->setItem($this->createItem(5));
\WP_Mock::wpPassthruFunction('get_posts', array('times' => 1));
\WP_Mock::wpPassthruFunction('wp_insert_post', array('times' => 1));
\WP_Mock::wpPassthruFunction('update_post_meta', array('times' => 5));
$importer->save();
}
示例15: test_filter_user_contactmethods
/**
* Test filter_user_contactmethods
*
* @since 4.0.0
*/
public function test_filter_user_contactmethods()
{
// Setup.
\WP_Mock::wpPassthruFunction('esc_html__');
// Act.
$contact_methods = filter_user_contactmethods(array());
// Verify.
$this->assertTrue(is_array($contact_methods));
$this->assertArrayHasKey('website_title', $contact_methods);
$this->assertArrayHasKey('twitter', $contact_methods);
$this->assertArrayHasKey('facebook', $contact_methods);
$this->assertArrayHasKey('wordpress', $contact_methods);
$this->assertArrayHasKey('github', $contact_methods);
}