本文整理汇总了PHP中WP_Mock类的典型用法代码示例。如果您正苦于以下问题:PHP WP_Mock类的具体用法?PHP WP_Mock怎么用?PHP WP_Mock使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了WP_Mock类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: test_textarea_wysiwyg
public function test_textarea_wysiwyg()
{
$textarea = new Textarea('mon_textarea', null, "mon_textarea_id", array('wysiwyg' => true));
\WP_Mock::expectActionAdded('admin_print_footer_scripts', array($textarea, 'addEditorTinymce'), 99);
$html = $textarea->getDisplay();
$this->assertRegExp('/<textarea(. *)+><\\/textarea>/', $html);
}
开发者ID:Weysan,项目名称:wp-framework-backend-form,代码行数:7,代码来源:TextareaTest.php
示例2: testRegister
public function testRegister()
{
$layoutRegister = new \Dxw\Iguana\Theme\LayoutRegister($this->getHelpers());
$this->assertInstanceOf(\Dxw\Iguana\Registerable::class, $layoutRegister);
\WP_Mock::expectFilterAdded('template_include', [\Dxw\Iguana\Theme\Layout::class, 'apply'], 99);
$layoutRegister->register();
}
开发者ID:dxw,项目名称:iguana-theme,代码行数:7,代码来源:layout_register_test.php
示例3: test_ready_priority
/**
* Tests hooking the template loader to the WordPress template loading filters
* with a priority.
*
* @covers ::ready
*
* @dataProvider loader_provider
*/
public function test_ready_priority(Loader $loader)
{
$priority = rand(11, 99);
\WP_Mock::expectFilterAdded('template_include', array($loader, 'filter'), $priority);
$loader->ready($priority);
$this->assertHooksAdded();
}
开发者ID:goblindegook,项目名称:syllables,代码行数:15,代码来源:Loader_Test.php
示例4: react
public function react($args)
{
\WP_Mock::invokeAction($this->name);
$arg_num = count($args);
if (0 === $arg_num) {
if (!isset($this->processors['argsnull'])) {
return;
}
$this->processors['argsnull']->react();
} else {
$processors = $this->processors;
for ($i = 0; $i < $arg_num - 1; $i++) {
$arg = $this->safe_offset($args[$i]);
if (!isset($processors[$arg])) {
return;
}
$processors = $processors[$arg];
}
$arg = $this->safe_offset($args[$arg_num - 1]);
if (!isset($processors[$arg])) {
return;
}
$processors[$arg]->react();
}
}
开发者ID:lloc,项目名称:wp_mock,代码行数:25,代码来源:Action.php
示例5: test_customize_meta_boxes
public function test_customize_meta_boxes()
{
$testee = new Testee();
WP_Mock::wpFunction('remove_meta_box', array('times' => 1, 'args' => array(WP_Mock\Functions::type('string'), WP_Mock\Functions::type('string'), WP_Mock\Functions::type('string'))));
$testee->customize_meta_boxes();
$this->assertConditionsMet();
}
开发者ID:tfrommen,项目名称:external-content,代码行数:7,代码来源:PostTypeModelTest.php
示例6: testTaxonomyWithExistingToAndFromExpectsTaxonomiesMigrated
/**
* Tests our ability to mock the cli interface
*
* @group wip
* @covers taxonomy
*
*/
function testTaxonomyWithExistingToAndFromExpectsTaxonomiesMigrated()
{
// arrange
$args = $this->validTaxonomyArgs;
$assoc_args = array('post_type' => 'post');
$this->posts['args'] = $args + $assoc_args;
var_dump($this->posts);
$mock = $this->getMockBuilder('\\CFPB\\Migrate_Command')->setMethods(array('get_specified_posts'))->getMock();
$mock->expects($this->once())->method('get_specified_posts')->will($this->returnValue($this->posts));
$new_term0 = array('slug' => 'term');
$new_term1 = array('slug' => 'another');
// mock taxonomy_exists form the WordPress API which we expect to be fired exactly twice
\WP_Mock::wpFunction('taxonomy_exists', array('times' => 2, 'return' => true));
// mock wp_get_post_terms from the WordPress API which we expect to fire exactly twice
$terms = \WP_Mock::wpFunction('wp_get_post_terms', array('times' => 2, 'with' => array(array($this->post0->ID, $args[0]), array($this->post1->ID, $args[0])), 'return' => $this->terms));
// mock wp_insert_term from the WordPress API which we expect to fire exactly twice
$new_term = \WP_Mock::wpFunction('wp_insert_term', array('times' => 2, 'with' => array(array($this->term0->name, $args[1], array('slug' => $this->term0->slug))), 'return' => array('term_id' => 0, 'term_id' => 1)));
// we expect get_term to fire twice with
\WP_Mock::wpFunction('get_term', array('times' => 2, 'with' => array(array(1, $args[1])), 'return' => $this->term0));
// we expect wp_set_objec_terms to fire twice
\WP_Mock::wpFunction('wp_set_object_terms', array('times' => 2, 'return' => true));
$cli = $this->cli->getMock();
$cli->expects($this->once())->method('success')->will($this->returnValue('Success'));
// act
$action = $mock->taxonomy($args, $assoc_args);
$this->assertTrue($action == 'Success');
}
开发者ID:vccabral,项目名称:cms-toolkit,代码行数:34,代码来源:test-cli-migrate.php
示例7: test_content_type
public function test_content_type()
{
$plugin = new Plugin();
\WP_Mock::wpFunction('register_post_type', array('times' => 3, 'arg' => array('lnh_matches')));
\WP_Mock::wpFunction('get_option', array('times' => 1, 'arg' => array('lnh_equipe_handball'), 'return' => array('equipe' => 'toulouse', 'classement' => '1', 'joueurs' => '1', 'calendrier' => '1')));
$plugin->createContentType();
}
开发者ID:CouleurCitron,项目名称:wp-lnh-flux,代码行数:7,代码来源:PluginTest.php
示例8: testSetupMetaBoxesNotPostOrPage
public function testSetupMetaBoxesNotPostOrPage()
{
\WP_Mock::wpFunction('add_meta_box', ['times' => 0]);
\WP_Mock::onFilter('dxw_content_review_post_types')->with(['post', 'page'])->reply(['meow']);
\Dxw_Content_Review\Dxw_Content_Review::setup_meta_boxes('post');
\Dxw_Content_Review\Dxw_Content_Review::setup_meta_boxes('page');
}
开发者ID:dxw,项目名称:dxw-content-review,代码行数:7,代码来源:content_review_test.php
示例9: apply_filters
/**
* Call the functions added to a filter hook.
*
* @param string $tag The name of the filter hook.
* @param mixed $value The value on which the filters hooked to <tt>$tag</tt> are applied on.
* @param mixed $var,... Additional variables passed to the functions hooked to <tt>$tag</tt>.
*
* @return mixed The filtered value after all hooked functions are applied to it.
*/
function apply_filters($tag, $value)
{
$args = func_get_args();
$args = array_slice($args, 1);
$args[0] = $value;
return \WP_Mock::onFilter($tag)->apply($args);
}
开发者ID:lloc,项目名称:wp_mock,代码行数:16,代码来源:function-mocks.php
示例10: 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
示例11: test_meta_box_save_rejects_invalid_before_or_after_setting
public function test_meta_box_save_rejects_invalid_before_or_after_setting()
{
$cpt = new CPT();
WP_Mock::wpFunction('wp_verify_nonce', array('times' => 1, 'args' => array('nonce-value', 'itelic-renewal-reminders-metabox'), 'return' => true));
WP_Mock::wpFunction('update_post_meta', array('times' => 1, 'args' => array(1, '_itelic_renewal_reminder_days', 3), 'return' => true));
WP_Mock::wpFunction('update_post_meta', array('times' => 1, 'args' => array(1, '_itelic_renewal_reminder_boa', 'before'), 'return' => true));
$cpt->do_save(1, array('itelic_reminder_nonce' => 'nonce-value', 'itelic_reminder' => array('days' => 3, 'boa' => 'garbage')));
}
开发者ID:pemiu01,项目名称:exchange-addon-licensing,代码行数:8,代码来源:test-cpt.php
示例12: 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);
}
开发者ID:ericmann,项目名称:mvpress,代码行数:11,代码来源:contextTest.php
示例13: testToString
public function testToString()
{
$layout = new \Dxw\Iguana\Theme\Layout();
$layout->slug = 'slug';
\WP_Mock::onFilter('roots_wrap_slug')->with(['layouts/main.php'])->reply(['layouts/my-layout.php']);
\WP_Mock::wpFunction('locate_template', ['args' => [['layouts/my-layout.php']], 'return' => 'correct output']);
$this->assertEquals('correct output', $layout->__toString());
}
开发者ID:dxw,项目名称:iguana-theme,代码行数:8,代码来源:layout_test.php
示例14: tearDown
public function tearDown()
{
\WP_Mock::tearDown();
$cls = new ReflectionClass(\Dxw\Iguana\Registrar::class);
$property = $cls->getProperty('singleton');
$property->setAccessible(true);
$property->setValue(null);
}
开发者ID:dxw,项目名称:iguana,代码行数:8,代码来源:registrar_test.php
示例15: test_checkAjaxReferer
public function test_checkAjaxReferer()
{
$action = 'nonce_action';
$query_arg = '_wpnonce_name';
$myNonce = new WPnonce($action);
\WP_Mock::wpFunction('check_ajax_referer', array('times' => 1, 'args' => array($myNonce->getAction(), $query_arg, true), 'return' => true));
$this->assertTrue($myNonce->checkAjaxReferer($query_arg, true));
}
开发者ID:christophwolff,项目名称:wpnonce,代码行数:8,代码来源:WPnonceTest.php
示例16: test_initialize
/**
* @covers tfrommen\ThatWasHelpful\Controllers\Action::initialize
*
* @return void
*/
public function test_initialize()
{
/** @var tfrommen\ThatWasHelpful\Models\Post $post */
$post = Mockery::mock('tfrommen\\ThatWasHelpful\\Models\\Post');
$testee = new Testee($post);
WP_Mock::expectActionAdded('template_redirect', array($post, 'update_http'));
$testee->initialize();
$this->assertHooksAdded();
}
开发者ID:tfrommen,项目名称:that-was-helpful,代码行数:14,代码来源:ActionControllerTest.php
示例17: test_initialize
public function test_initialize()
{
$model = Mockery::mock('tfrommen\\ExternalContent\\Models\\PostType');
/** @var tfrommen\ExternalContent\Models\PostType $model */
$testee = new Testee($model);
WP_Mock::expectActionAdded('wp_loaded', array($model, 'register'));
$testee->initialize();
$this->assertHooksAdded();
}
开发者ID:tfrommen,项目名称:external-content,代码行数:9,代码来源:PostTypeControllerTest.php
示例18: test_activate
/**
* Test activation routine.
*/
public function test_activate()
{
// Setup
\WP_Mock::wpFunction('flush_rewrite_rules', array('times' => 1));
// Act
activate();
// Verify
$this->assertConditionsMet();
}
开发者ID:aldeloren,项目名称:a1d-wp-monitoring,代码行数:12,代码来源:Core_Tests.php
示例19: test_interval_after
public function test_interval_after()
{
$post = new WP_Post((object) array('post_type' => Reminder\CPT::TYPE, 'ID' => 1));
WP_Mock::wpFunction('get_post_meta', array('times' => 1, 'args' => array(1, '_itelic_renewal_reminder_days', true), 'return' => 5));
WP_Mock::wpFunction('get_post_meta', array('times' => 1, 'args' => array(1, '_itelic_renewal_reminder_boa', true), 'return' => Reminder::TYPE_AFTER));
$reminder = new Reminder($post);
$expects = new DateInterval('P5D');
$expects->invert = true;
$this->assertEquals($expects, $reminder->get_interval());
}
开发者ID:pemiu01,项目名称:exchange-addon-licensing,代码行数:10,代码来源:test-reminder.php
示例20: test_update
/**
* @covers tfrommen\ThatWasHelpful\Controllers\Update::update
* @dataProvider provide_update_data
*
* @param bool $expected
* @param string $version
* @param string $old_version
*
* @return void
*/
public function test_update($expected, $version, $old_version)
{
$testee = new Testee($version);
WP_Mock::wpFunction('get_option', array('times' => 1, 'args' => array(Mockery::type('string')), 'return' => $old_version));
if ($old_version !== $version) {
WP_Mock::wpFunction('update_option', array('times' => 1, 'args' => array(Mockery::type('string'), $version)));
}
$this->assertSame($expected, $testee->update());
$this->assertConditionsMet();
}
开发者ID:tfrommen,项目名称:that-was-helpful,代码行数:20,代码来源:UpdateControllerTest.php
注:本文中的WP_Mock类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论