コード例 #1
0
 function test_largo_load_more_posts_cats_home_option()
 {
     $this->markTestSkipped('Unable to read the ajax return, even when it is filled with dumb <h1>foo</h1> tags that do not depend upon categories or posts or queries.');
     global $wp_action;
     $preserve = $wp_action;
     $wp_action = array();
     $category = $this->factory->category->create();
     of_set_option('cats_home', (string) $category);
     $posts = $this->factory->post->create_many(10, array('post_category' => $category));
     $_POST['paged'] = 0;
     $_POST['query'] = json_encode(array());
     try {
         $this->_handleAjax("load_more_posts");
     } catch (WPAjaxDieStopException $e) {
         foreach ($this->post_ids as $number) {
             $pos = strpos($this->_last_response, 'post-' . $number);
             $this->assertTrue((bool) $pos);
         }
     } catch (WPAjaxDieContinueException $e) {
         foreach ($this->post_ids as $number) {
             $pos = strpos($this->_last_response, 'post-' . $number);
             $this->assertTrue((bool) $pos);
         }
     }
     $wp_action = $preserve;
 }
コード例 #2
0
 function testIsActiveHomepageLayout()
 {
     // Our test layout should not be active homepage layout to start
     $this->assertFalse($this->layout->isActiveHomepageLayout());
     // After we set the homepage layout option, it should
     of_set_option('home_template', get_class($this->layout));
     $this->assertTrue($this->layout->isActiveHomepageLayout());
 }
コード例 #3
0
ファイル: test-taxonomies.php プロジェクト: GaryJones/Largo
 function test_largo_post_in_series()
 {
     // If series are disabled:
     of_set_option('series_enabled', false);
     $result = largo_post_in_series();
     $this->assertFalse($result);
     // If series are enabled:
     of_set_option('series_enabled', 1);
     $this->markTestIncomplete('This test has not been implemented yet.');
 }
コード例 #4
0
 function test_largo_social_links()
 {
     // this function only creates output if there are >0 social links
     $fields = array('rss_link', 'facebook_link', 'twitter_link', 'youtube_link', 'flickr_link', 'tumblr_link', 'gplus_link', 'linkedin_link', 'github_link');
     foreach ($fields as $field) {
         of_set_option($field, 'http://foo.bar\\/' . $field);
         $this->expectOutputRegex('/http:\\/\\/foo.bar\\/' . $field . '/');
         // This is excessively greedy, it expects any output at all
         largo_social_links();
         of_reset_options();
     }
 }
コード例 #5
0
 function test_largo_post_social_links()
 {
     // Create a post, go to it.
     $id = $this->factory->post->create();
     $this->go_to('/?p=' . $id);
     // Test the output of this when no options are set
     of_set_option('article_utilities', array('facebook' => false, 'twitter' => false, 'print' => false, 'email' => false));
     ob_start();
     largo_post_social_links();
     $ret = ob_get_clean();
     $this->assertRegExp('/post-social/', $ret, "The .post-social class was not in the output");
     unset($ret);
     // Test that this outputs the expected data for each of the button types
     // Twitter
     of_set_option('article_utilities', array('twitter' => '1', 'facebook' => false, 'print' => false, 'email' => false));
     of_set_option('twitter_link', 'foo');
     ob_start();
     largo_post_social_links();
     $ret = ob_get_clean();
     $this->assertRegExp('/class="twitter"/', $ret, "The 'twitter' class did not appear in the output");
     // @TODO: insert a test for the get_the_author_meta test here
     $this->assertRegExp('/' . __('Tweet', 'largo') . '/', $ret, "The translation of 'Tweet' was not in the Twitter output");
     unset($ret);
     of_reset_options();
     // Facebook
     of_set_option('article_utilities', array('facebook' => '1', 'twitter' => false, 'print' => false, 'email' => false));
     ob_start();
     largo_post_social_links();
     $ret = ob_get_clean();
     $this->assertRegExp('/' . preg_quote(esc_attr(of_get_option('fb_verb')), '/') . '/i', $ret, "The Facebook Verb was not in the Facebook output");
     $this->assertRegExp('/' . preg_quote(get_permalink(), '/') . '/', $ret, "The permalink was not in the Facebook output");
     unset($ret);
     of_reset_options();
     // Print
     of_set_option('article_utilities', array('print' => '1', 'twitter' => '1', 'facebook' => false, 'email' => false));
     ob_start();
     largo_post_social_links();
     $ret = ob_get_clean();
     $this->assertRegExp('/print/', $ret, "The Print output did not include a print class");
     unset($ret);
     of_reset_options();
     // Email
     of_set_option('article_utilities', array('email' => '1', 'twitter' => false, 'facebook' => false, 'print' => false));
     ob_start();
     largo_post_social_links();
     $ret = ob_get_clean();
     $this->assertRegExp('/email/', $ret, "The Email output did not include an email class");
     unset($ret);
     of_reset_options();
 }
コード例 #6
0
 function test_enabled_widget()
 {
     global $wp_widget_factory;
     /* 1: Test that enabling the option actually registers the widget */
     // First, make sure that nothing else registered this widget.
     unregister_widget('largo_series_posts_widget');
     // Set the option
     of_set_option('series_enabled', '1');
     largo_widgets();
     // Make sure it's registered and the correct type.
     $widget_obj = $wp_widget_factory->widgets['largo_series_posts_widget'];
     $this->assertTrue(is_a($widget_obj, 'WP_Widget'));
     /* 2: Test that disabling the option actually disabled the registration of the widget */
     // Unregister it.
     unregister_widget('largo_series_posts_widget');
     // Set the option
     of_set_option('series_enabled', false);
     largo_widgets();
     // $wp_widget_factory shouldn't know anything about the disclaimer widget anymore.
     $this->assertFalse(array_key_exists('largo_series_posts_widget', $wp_widget_factory->widgets));
 }
コード例 #7
0
ファイル: update.php プロジェクト: GaryJones/Largo
/**
 * Enable the series taxonomy if the series landing pages are in use.
 *
 * @return bool If series landing pages (and series) were enabled by this function.
 */
function largo_enable_series_if_landing_page()
{
    // get a list of post types
    $types = get_post_types('', 'names');
    // Get a list of pages in the 'series' taxonomy if the landing page is registered
    if (isset($types['cftl-tax-landing'])) {
        $args = array('post_type' => 'cftl-tax-landing');
        $pages = get_pages($args);
        if ($pages !== false) {
            // get_pages returns false if no pages found, so if it's not false then there are probably cftl-tax-landing pages
            of_set_option('series_enabled', '1');
            of_set_option('custom_landing_enabled', '1');
            return true;
        }
        return false;
    }
}
コード例 #8
0
ファイル: test-update.php プロジェクト: DrewAPicture/Largo
 function test_largo_ajax_update_database_true()
 {
     // If the install needs updated, this should return json with success == true
     of_set_option('largo_version', null);
     try {
         $this->_handleAjax("largo_ajax_update_database");
     } catch (WPAjaxDieContinueException $e) {
         $resp = json_decode($this->_last_response, true);
         $this->assertTrue($resp['success'] == true);
     }
 }
コード例 #9
0
ファイル: test-post-tags.php プロジェクト: DrewAPicture/Largo
 function test_not_largo_floating_social_button_js()
 {
     of_set_option('single_floating_social_icons', false);
     of_set_option('single_template', 'normal');
     $this->go_to('/');
     $this->expectOutputString('', "The Floating social buttons js was output to the page when it should not have been.");
     largo_floating_social_button_js();
 }
コード例 #10
0
 /**
  * @todo This test checks for a post before and a post after the considered post
  */
 function test_category()
 {
     of_set_option('series_enabled', false);
     // Some randos before and after
     $this->factory->post->create(array('post_date' => '2013-01-01 00:00:00'));
     $this->factory->post->create(array('post_date' => '2015-01-01 00:00:00'));
     $cp = $this->factory->post->create(array('post_category' => array($this->cat_id)));
     $lr = new Largo_Related(1, $this->considered);
     $ids = $lr->ids();
     $this->assertEquals(1, count($ids), "Largo_Related returned other than 1 posts");
     $this->assertEquals($cp, $ids[0], "Largo_Related did not return the post in the category");
 }