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(); }
/** * 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(); }
public function testInit() { $useAtom = new \Dxw\Iguana\Extras\UseAtom(); \WP_Mock::expectFilterAdded('default_feed', [$useAtom, 'defaultFeed']); \WP_Mock::wpFunction('remove_action', ['args' => ['do_feed_rdf', 'do_feed_rdf', 10, 1], 'times' => 1]); \WP_Mock::wpFunction('remove_action', ['args' => ['do_feed_rss', 'do_feed_rss', 10, 1], 'times' => 1]); \WP_Mock::wpFunction('remove_action', ['args' => ['do_feed_rss2', 'do_feed_rss2', 10, 1], 'times' => 1]); $useAtom->init(); }
public function test_initialize() { $model = Mockery::mock('tfrommen\\ExternalContent\\Models\\Post'); /** @var tfrommen\ExternalContent\Models\Post $model */ $testee = new Testee($model); WP_Mock::expectFilterAdded('post_type_link', array($model, 'get_external_url'), 10, 2); WP_Mock::expectFilterAdded('pre_get_shortlink', array($model, 'get_shortlink'), 10, 3); $testee->initialize(); $this->assertHooksAdded(); }
/** * Test that the actions are successfully added. */ public function test_init() { $this->dt = new \notne\Da_Tag\Da_Tag(dirname(__FILE__) . '/../'); \WP_Mock::expectActionAdded('admin_notices', array($this->dt, 'admin_notices'), 10, 1); \WP_Mock::expectActionAdded('admin_init', array($this->dt, 'admin_notices_ignore')); \WP_Mock::expectActionAdded('save_post', array($this->dt, 'save_highlighted_tag'), 10, 3); \WP_Mock::expectActionAdded('admin_enqueue_scripts', array($this->dt, 'enqueues')); \WP_Mock::expectFilterAdded('post_submitbox_misc_actions', array($this->dt, 'highlight_tag')); $this->dt->init(); }
/** * Test constructor * * @since 4.0.0 */ public function test_construct() { // Setup. $journal = new Journal(); \WP_Mock::expectActionAdded('init', array($journal, 'create_journal_type')); \WP_Mock::expectActionAdded('save_post', array($journal, 'journal_save_morning_meta'), 10, 2); \WP_Mock::expectActionAdded('save_post', array($journal, 'journal_save_evening_meta'), 10, 2); \WP_Mock::expectFilterAdded('wp_insert_post_data', array($journal, 'filter_wp_insert_post_data'), 10, 2); // Act. $journal->__construct(); // Verify. $this->assertConditionsMet(); }
/** * Test load method. * * @since 3.2.0 */ public function test_setup() { // Setup. \Mockery::mock('WP_Widget'); \WP_Mock::wpFunction('current_time', array('times' => 1, 'return_arg' => time())); \WP_Mock::expectActionAdded('dashboard_glance_items', 'CW\\Plugin\\Core\\action_dashboard_glance_items'); \WP_Mock::expectActionAdded('plugins_loaded', 'CW\\Plugin\\Core\\action_plugins_loaded'); \WP_Mock::expectActionAdded('widgets_init', 'CW\\Plugin\\Core\\action_widgets_init'); \WP_Mock::expectFilterAdded('user_contactmethods', 'CW\\Plugin\\Core\\filter_user_contactmethods'); // Act. setup(); // Verify. $this->assertConditionsMet(); }
public function test_handle_postback() { $async = $this->getMockAsync('Async', array('verify_async_nonce', 'run_action')); $nonce = 'asdfasdf'; $_POST['_nonce'] = $nonce; $async->shouldReceive('verify_async_nonce')->once()->with($nonce)->andReturn(true); WP_Mock::wpFunction('is_user_logged_in', array('times' => 1, 'return' => true)); $async->shouldReceive('run_action')->once()->with(); WP_Mock::expectFilterAdded('wp_die_handler', function () { die; }); WP_Mock::wpFunction('wp_die', array('times' => 1)); /** @var Async $async */ $async->handle_postback(); $action = new ReflectionProperty('Async', 'action'); $action->setAccessible(true); $this->assertEquals('async', $action->getValue($async)); $this->assertConditionsMet(); }
/** * Ensure the safe exit function adds the appropriate filters and * invokes `wp_die()` in the end. */ public function test_safe_exit() { M::wpFunction('wp_die', ['times' => 1]); $handler = function () { return function () { die; }; }; M::expectFilterAdded('wp_die_ajax_handler', $handler); M::expectFilterAdded('wp_die_xmlrpc_handler', $handler); M::expectFilterAdded('wp_die_handler', $handler); safe_exit(); $this->assertConditionsMet(); }
/** * */ public function testAddedGalleryShortcodeParsing() { \WP_Mock::expectFilterAdded('post_gallery', array($this->shortcodeParser, 'galleryCallback'), 0, 2); $this->shortcodeParser->addFilters(); }