WordPress.org

Make WordPress Core

Changeset 264 in tests


Ignore:
Timestamp:
11/19/2009 09:36:41 PM (9 years ago)
Author:
westi
Message:

Some tests for get_themes() size with a lot of themes.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wp-testcase/test_includes_theme.php

    r259 r264  
    197197
    198198        add_filter('theme_root', array(&$this, '_theme_root'));
    199        
     199
    200200        // clear caches
    201201        unset($GLOBALS['wp_themes']);
     
    325325    function test_page_templates() {
    326326        $themes = get_themes();
    327 
     327       
    328328        $theme = $themes['Page Template Theme'];
    329329        $this->assertFalse( empty($theme) );
    330        
     330               
    331331        $templates = $theme['Template Files'];
     332        $this->assertEquals( 3, count( $templates ) );
    332333        $this->assertTrue( in_array( $this->theme_root . '/page-templates/template-top-level.php', $templates));
    333334        $this->assertTrue( in_array( $this->theme_root . '/page-templates/subdir/template-sub-dir.php', $templates));
    334335    }
    335336}
    336 
     337class TestLargeThemeDir extends _WPEmptyBlog {
     338   
     339    function setUp() {
     340        parent::setUp();
     341        $this->theme_root = realpath(DIR_TESTROOT.'/'.DIR_TESTDATA.'/wpcom-themes');
     342
     343        add_filter('theme_root', array(&$this, '_theme_root'));
     344
     345        // clear caches
     346        unset($GLOBALS['wp_themes']);
     347        unset($GLOBALS['wp_broken_themes']);
     348       
     349    }
     350
     351    function tearDown() {
     352        remove_filter('theme_root', array(&$this, '_theme_root'));
     353        parent::tearDown();
     354    }
     355
     356    // replace the normal theme root dir with our premade test dir
     357    function _theme_root($dir) {
     358        return $this->theme_root;
     359    }
     360    function test_theme_list() {
     361        $themes = get_themes();
     362        $theme_names = array_keys($themes);
     363        $this->assertEquals(87, count($theme_names));
     364        //2.9 pre [12226]
     365        $this->assertLessThanOrEqual(387283, strlen(serialize($themes)));
     366        //2.8.5
     367        $this->assertLessThanOrEqual(368319, strlen(serialize($themes)));
     368        //2.9 post [12226]
     369        $this->assertLessThanOrEqual(261998, strlen(serialize($themes)));
     370    }
     371}
    337372?>
Note: See TracChangeset for help on using the changeset viewer.