function testCreateDimensionSelector() { $source = $this->core->create_dimension_selector("test", "760x340"); $this->assertTrue(($xml = _to_xml($source, true)) !== false); foreach (array('//input[@name="test[width]" and @value="760"]' => true, '//input[@name="test[height]" and @value="340"]' => true) as $xpath => $value) { $this->assertTrue(_xpath_test($xml, $xpath, $value), $xpath); } }
/** * @dataProvider providerTestWidget */ function testWidget($instance, $expected_xpath, $is_home = false) { global $post; $post = (object) array('ID' => 1, 'guid' => 'Post url'); wp_insert_post($post); $w = new ComicPressBookmarkWidget(); _set_bloginfo('url', 'Blog url'); _set_current_option('is_home', $is_home); ob_start(); $w->widget(array('before_widget' => '', 'after_widget' => '', 'before_title' => '<p>', 'after_title' => '</p>'), $instance); $content = ob_get_clean(); $this->assertTrue(($xml = _to_xml($content, true)) !== false); foreach ($expected_xpath as $xpath => $value) { $this->assertTrue(_xpath_test($xml, $xpath, $value), $xpath); } }
function testRenderGenerationStates() { global $comicpress_manager, $comicpress_manager_admin; add_category(1, (object) array('name' => 'Comics')); add_category(2, (object) array('name' => 'Blog')); $s = new ComicPressSidebarStandard(); $s->thumbnail_generation = array('rss' => true, 'archive' => array("test")); $comicpress_manager_admin = $this->getMock('ComicPressManagerAdmin', array('show_debug_info')); ob_start(); $s->render(); $source = ob_get_clean(); $this->assertTrue(($xml = _to_xml($source, true)) !== false); foreach (array() as $xpath => $value) { $this->assertTrue(_xpath_test($xml, $xpath, $value), $xpath); } $this->markTestIncomplete(); }
function testRenderPre28WidgetControl() { update_option('plugin-wonderful-pre28-widget-info', array('adboxid' => 123, 'center' => 1)); $this->pw->publisher_info->adboxes = array((object) array('adboxid' => '123')); ob_start(); $this->pw->render_pre28_widget_control(); $source = ob_get_clean(); $this->assertTrue(($xml = _to_xml($source)) !== false); foreach (array('//input[@name="_pw_nonce"]' => true, '//input[@name="pw[adboxid]"]' => true, '//input[@name="pw[center]"]' => true) as $xpath => $value) { $this->assertTrue(_xpath_test($xml, $xpath, $value), $xpath); } }
function testObfuscateFilenames() { global $comicpress_manager; $comicpress_manager = $this->getMock('ComicPressManager', array('get_subcomic_directory', 'get_cpm_option')); $comicpress_manager->expects($this->any())->method('get_subcomic_directory')->will($this->returnValue(false)); $comicpress_manager->expects($this->at(1))->method('get_cpm_option')->with('cpm-obfuscate-filenames-on-upload')->will($this->returnValue("test")); ob_start(); $this->u->render(); $result = ob_get_clean(); $this->assertTrue(($xml = _to_xml($result)) !== false); foreach (array('//h3[contains(text(), "uploaded filenames will be obfuscated")]' => true) as $xpath => $value) { $this->assertTrue(_xpath_test($xml, $xpath, $value), $xpath); } }
function testDisplayMessages() { $this->admin->info('info'); $this->admin->warn('warn'); $this->admin->error('error'); ob_start(); $this->admin->display_messages(); $this->assertTrue(($xml = _to_xml(ob_get_clean())) !== false); foreach (array('//div[contains(@class, "cp-info")]/p' => 'info', '//div[contains(@class, "cp-warn")]/p' => 'warn', '//div[contains(@class, "cp-error")]/p' => 'error') as $xpath => $value) { $this->assertTrue(_xpath_test($xml, $xpath, $value), $xpath); } }
function testInstructions() { global $plugin_wonderful; $plugin_wonderful->publisher_info = true; $this->m->_pw_nonce = "345"; $this->m->first_adboxid = "123"; $_GET['allow-destroy'] = 1; ob_start(); $this->m->_render_instructions(); $source = ob_get_clean(); $this->assertTrue(!empty($source)); $this->assertTrue(($xml = _to_xml($source, true)) !== false); foreach (array('//tt[contains(text(), "the_project_wonderful_ad(123)")]' => true, '//tt[contains(text(), "PW(123)")]' => true, '//tt[contains(text(), "PW\\(123\\)")]' => true, '//form[@id="allow-destroy-handler"]/input[@name="_pw_nonce" and @value="345"]' => true, '//form[@id="allow-destroy-handler"]/input[@name="_pw_action" and @value="rebuild-database"]' => true) as $xpath => $value) { $this->assertTrue(_xpath_test($xml, $xpath, $value), $xpath); } }
function testWidgetUI() { ob_start(); $this->diw->render_ui(); $result = ob_get_clean(); $this->assertTrue(!empty($result)); $this->assertTrue(($xml = _to_xml($result, true)) !== false); foreach ($this->diw->_valid_options as $option => $label) { $xpath = "//label[contains(text(), '{$label}')]"; $this->assertTrue(_xpath_test($xml, $xpath, true), $xpath); } foreach (array('//input[@type="hidden" and @name="hubblesite[_wpnonce]"]' => true) as $xpath => $value) { $this->assertTrue(_xpath_test($xml, $xpath, $value), $xpath); } }