Skip to content

Commit

Permalink
Unit tests: Don't pre-populate database with theme options
Browse files Browse the repository at this point in the history
See #110
  • Loading branch information
middlesister committed Jul 26, 2014
1 parent d1415ef commit deebd99
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 76 deletions.
10 changes: 2 additions & 8 deletions library/tests/test-legacy-xhtml-comments.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,10 @@ class TestLegacyComments extends Thematic_UnitTestCase {
function setUp() {
/* Load the legacy files before anything else - needed for childtheme_overrides* to work */
include_legacy_xhtml_files();

/* Load the thematic files */
parent::setUp();

/* Set the option to use legacy mode */
$this->theme_options = $this->get_test_options( 'thematic_theme_opt' );
$this->theme_options['legacy_xhtml'] = '1';

$this->update_test_options( 'thematic_theme_opt', $this->theme_options );


/* Create and setup some comments for testing */
$post_id = $this->factory->post->create();
$this->factory->comment->create_post_comments( $post_id, 10 );
Expand Down
8 changes: 1 addition & 7 deletions library/tests/test-legacy-xhtml-overrides.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,10 @@ function setUp() {

/* Load the legacy files before anything else - needed for childtheme_overrides* to work */
include_legacy_xhtml_files();

/* Load the thematic files */
parent::setUp();

/* Set the option to use legacy mode */
$this->theme_options = $this->get_test_options( 'thematic_theme_opt' );
$this->theme_options['legacy_xhtml'] = '1';

$this->update_test_options( 'thematic_theme_opt', $this->theme_options );

/* Create and setup a loop for testing */
$post_ids = $this->factory->post->create_many( 10 );
foreach ( $post_ids as $post_id )
Expand Down
11 changes: 0 additions & 11 deletions library/tests/test-legacy-xhtml.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,6 @@ function setUp() {
/* Load the thematic files */
parent::setUp();

/* Set the option to use legacy mode */
$this->theme_options = $this->get_test_options( 'thematic_theme_opt' );
$this->theme_options['legacy_xhtml'] = '1';

$this->update_test_options( 'thematic_theme_opt', $this->theme_options );

/* Create and setup a loop for testing */
$post_ids = $this->factory->post->create_many( 10 );
foreach ( $post_ids as $post_id )
Expand All @@ -40,11 +34,6 @@ function setUp() {

thematic_replace_loops();
}


function test_legacy_theme_options() {
$this->assertEquals( '1', $this->theme_options['legacy_xhtml'] );
}


function test_thematic_doctype() {
Expand Down
50 changes: 0 additions & 50 deletions library/tests/test-thematic.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@
* @group default
*/
class Thematic_UnitTestCase extends WP_UnitTestCase {

/**
* @var array
*/
public $theme_options;

function setUp() {
parent::setUp();
Expand All @@ -24,56 +19,11 @@ function setUp() {
/* Include the Thematic function file and extensions */
include_main_theme_files();

/* Setup the theme options */
$this->theme_options = thematic_default_opt() ;
$this->theme_options['legacy_xhtml'] = '0';
$this->update_test_options( 'thematic_theme_opt', $this->theme_options );

} // end setup


function test_active_theme() {
$this->assertTrue( 'Thematic' == wp_get_theme() );
}


function test_we_have_options() {
$options = $this->get_test_options( 'thematic_theme_opt' );
$this->assertArrayHasKey( 'legacy_xhtml' , $options );
}


/**
* A wrapper for retrieving theme options on the test install
*
* @param string $option_name The option name
* @return mixed Value set for the option
*/
function get_test_options( $option_name ) {
if ( defined( 'WP_TESTS_MULTISITE') && WP_TESTS_MULTISITE ) {
global $blog_id;
$options = get_blog_option( $blog_id, $option_name, $this->theme_options );
} else {
$options = get_option( $option_name, $this->theme_options );
}
return $options;
}


/**
* A wrapper for updating theme options on the test install
*
* @param string $option_name The option name
* @param array The options array to update
* @return bool True on success, false on failure.
*/
function update_test_options( $option_name, $options_array ) {
if ( defined( 'WP_TESTS_MULTISITE') && WP_TESTS_MULTISITE ) {
global $blog_id;
$options = update_blog_option( $blog_id, $option_name, $options_array );
} else {
$options = update_option( $option_name, $options_array );
}
return $options;
}
}

0 comments on commit deebd99

Please sign in to comment.