Skip to content

Commit

Permalink
Stub tests for functions introduced in #1248
Browse files Browse the repository at this point in the history
  • Loading branch information
benlk committed Jul 12, 2016
1 parent 9652aeb commit 10b3b4d
Show file tree
Hide file tree
Showing 3 changed files with 200 additions and 124 deletions.
29 changes: 29 additions & 0 deletions tests/inc/test-pagination.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

class PaginationTestFunctions extends WP_UnitTestCase {

function setUp() {
parent::setUp();

$this->post_excerpt = <<<EOT
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque cursus purus id pharetra dapibus.
EOT;

$this->post_id = $this->factory->post->create(array(
'post_excerpt' => $this->post_excerpt,
));
}

function test_largo_entry_content() {
$this->markTestIncomplete("This test has not yet been implemented.");
}


function test_largo_content_nav() {
$this->markTestIncomplete("This test has not yet been implemented.");
}

function test_largo_custom_wp_link_pages() {
$this->markTestIncomplete("This test has not yet been implemented.");
}
}
134 changes: 134 additions & 0 deletions tests/inc/test-post-social.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
<?php

class PostSocialTestFunctions extends WP_UnitTestCase {

function setUp() {
parent::setUp();

$this->post_excerpt = <<<EOT
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque cursus purus id pharetra dapibus.
EOT;

$this->post_id = $this->factory->post->create(array(
'post_excerpt' => $this->post_excerpt,
));
}

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");
$this->assertRegExp('/' . preg_quote(rawurlencode(get_permalink()), '/') . '/', $ret, "The permalink was not in the Twitter output");
$this->assertRegExp('/' . preg_quote(rawurlencode(get_the_title()), '/') . '/', $ret, "The title 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(rawurlencode(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();

}

function test_largo_floating_social_buttons() {
$id = $this->factory->post->create();
of_set_option('single_floating_social_icons', 1);
of_set_option('single_template', 'normal');
$this->go_to('/?p=' . $id);
$this->expectOutputRegex('/post-social/', "The .post-social class was not in the output.");
$this->expectOutputRegex('/id="tmpl-floating-social-buttons"/', "The #floating-social-buttons id was not in the output.");
largo_floating_social_buttons();
}

function test_largo_floating_social_button_width_json() {
$id = $this->factory->post->create();
of_set_option('single_floating_social_icons', 1);
of_set_option('single_template', 'normal');
$this->go_to('/?p=' . $id);
$this->expectOutputRegex('/id="floating-social-buttons-width-json"/', "The #floating-social-buttons-width-json id was not in the output.");
largo_floating_social_button_width_json();
}

function test_largo_floating_social_button_js() {
$id = $this->factory->post->create();
of_set_option('single_floating_social_icons', 1);
of_set_option('single_template', 'normal');
$this->go_to('/?p=' . $id);
$this->expectOutputRegex('/\/js\/floating-social-buttons/', "The Floating social buttons js was not output to the page.");
largo_floating_social_button_js();
}

function test_not_largo_floating_social_buttons() {
of_set_option('single_floating_social_icons', false);
of_set_option('single_template', 'normal');
$this->go_to('/');
$this->expectOutputString('', "The .post-social class was not in the output.");
largo_floating_social_buttons();
}

function test_not_largo_floating_social_button_width_json() {
of_set_option('single_floating_social_icons', false);
of_set_option('single_template', 'normal');
$this->go_to('/');
$this->expectOutputString('', "The #floating-social-buttons-width-json id was in the output, when nothing should have been output.");
largo_floating_social_button_width_json();
}

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();
}

}
161 changes: 37 additions & 124 deletions tests/inc/test-post-tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,77 +49,47 @@ function test_largo_author_link() {
function test_largo_byline() {
$this->markTestIncomplete("This test has not yet been implemented.");
}

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");
$this->assertRegExp('/' . preg_quote(rawurlencode(get_permalink()), '/') . '/', $ret, "The permalink was not in the Twitter output");
$this->assertRegExp('/' . preg_quote(rawurlencode(get_the_title()), '/') . '/', $ret, "The title 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(rawurlencode(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();

function test_largo_byline_component_authors() {
$this->markTestIncomplete("This test has not yet been implemented.");
}

function test_my_queryvars() {
function test_largo_byline_coauthors() {
$this->markTestIncomplete("This test has not yet been implemented.");
}
function test_largo_byline_avatar() {
$this->markTestIncomplete("This test has not yet been implemented.");
}
function test_largo_byline_coauthor_each_component_author() {
$this->markTestIncomplete("This test has not yet been implemented.");
}
function test_largo_byline_coauthor_each_component_job_title() {
$this->markTestIncomplete("This test has not yet been implemented.");
}
function test_largo_byline_coauthor_each_component_twitter() {
$this->markTestIncomplete("This test has not yet been implemented.");
}
function test_largo_byline_normal_or_custom() {
$this->markTestIncomplete("This test has not yet been implemented.");
}
function test_largo_byline_normal_or_custom_component_author_link() {
$this->markTestIncomplete("This test has not yet been implemented.");
}
function test_largo_byline_normal_or_custom_component_author_job_title() {
$this->markTestIncomplete("This test has not yet been implemented.");
}
function test_largo_byline_normal_or_custom_component_author_twitter() {
$this->markTestIncomplete("This test has not yet been implemented.");
}
function test_largo_byline_component_sep() {
$this->markTestIncomplete("This test has not yet been implemented.");
}
function test_largo_byline_component_publish_datetime() {
$this->markTestIncomplete("This test has not yet been implemented.");
}
function test_largo_byline_component_edit_link() {
$this->markTestIncomplete("This test has not yet been implemented.");
}

function test_largo_custom_wp_link_pages() {
function test_my_queryvars() {
$this->markTestIncomplete("This test has not yet been implemented.");
}

Expand Down Expand Up @@ -198,10 +168,6 @@ function test_largo_trim_sentences() {
$this->markTestIncomplete("This test has not yet been implemented.");
}

function test_largo_content_nav() {
$this->markTestIncomplete("This test has not yet been implemented.");
}

function test_largo_comment() {
$this->markTestIncomplete("This test has not yet been implemented.");
}
Expand All @@ -221,57 +187,4 @@ function test_largo_hero_with_caption() {
function test_largo_post_metadata() {
$this->markTestIncomplete("This test has not yet been implemented.");
}

function test_largo_floating_social_buttons() {
$id = $this->factory->post->create();
of_set_option('single_floating_social_icons', 1);
of_set_option('single_template', 'normal');
$this->go_to('/?p=' . $id);
$this->expectOutputRegex('/post-social/', "The .post-social class was not in the output.");
$this->expectOutputRegex('/id="tmpl-floating-social-buttons"/', "The #floating-social-buttons id was not in the output.");
largo_floating_social_buttons();
}

function test_largo_floating_social_button_width_json() {
$id = $this->factory->post->create();
of_set_option('single_floating_social_icons', 1);
of_set_option('single_template', 'normal');
$this->go_to('/?p=' . $id);
$this->expectOutputRegex('/id="floating-social-buttons-width-json"/', "The #floating-social-buttons-width-json id was not in the output.");
largo_floating_social_button_width_json();
}

function test_largo_floating_social_button_js() {
$id = $this->factory->post->create();
of_set_option('single_floating_social_icons', 1);
of_set_option('single_template', 'normal');
$this->go_to('/?p=' . $id);
$this->expectOutputRegex('/\/js\/floating-social-buttons/', "The Floating social buttons js was not output to the page.");
largo_floating_social_button_js();
}

function test_not_largo_floating_social_buttons() {
of_set_option('single_floating_social_icons', false);
of_set_option('single_template', 'normal');
$this->go_to('/');
$this->expectOutputString('', "The .post-social class was not in the output.");
largo_floating_social_buttons();
}

function test_not_largo_floating_social_button_width_json() {
of_set_option('single_floating_social_icons', false);
of_set_option('single_template', 'normal');
$this->go_to('/');
$this->expectOutputString('', "The #floating-social-buttons-width-json id was in the output, when nothing should have been output.");
largo_floating_social_button_width_json();
}

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();
}

}

0 comments on commit 10b3b4d

Please sign in to comment.