Пример #1
0
 function setUp()
 {
     _reset_wp();
     $_GET = array();
     _set_current_option('is_admin', true);
     $this->m = new PluginWonderfulViewMain();
 }
 /**
  * @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);
     }
 }
 /**
  * @dataProvider providerInsertAdsIntoRSS
  */
 function testInsertAdsIntoRSS($is_feed, $publisher_info, $in_rss_feed)
 {
     _set_current_option('is_feed', $is_feed);
     if ($is_feed) {
         if ($publisher_info) {
             $this->pw->publisher_info = (object) array('adboxes' => array((object) array('advancedcode' => "<noscript>test</noscript>", 'in_rss_feed' => $in_rss_feed)));
         } else {
             $this->pw->publisher_info = false;
         }
     }
     ob_start();
     $this->pw->insert_rss_feed_ads("body");
     $source = ob_get_clean();
     $this->assertEquals($is_feed && $publisher_info && $in_rss_feed == 1, !empty($source));
 }
Пример #4
0
 function testIsHome()
 {
     _set_current_option('is_home', true);
     $this->assertTrue(is_home());
 }