WordPress.org

Make WordPress Core

Changeset 703 in tests


Ignore:
Timestamp:
04/30/12 01:17:01 (2 years ago)
Author:
nacin
Message:

Add basic test cases for get_file_data() and #WP19854.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • wp-testcase/test_includes_functions.php

    r571 r703  
    431431} 
    432432 
    433 ?> 
     433class Test_WP_File_Headers extends WPTestCase { 
     434    function setUp() { 
     435        parent::setUp(); 
     436    } 
     437 
     438    function tearDown() { 
     439        parent::tearDown(); 
     440    } 
     441 
     442    function test_get_file_data() { 
     443        $theme_headers = array( 
     444            'Name' => 'Theme Name', 
     445            'ThemeURI' => 'Theme URI', 
     446            'Description' => 'Description', 
     447            'Version' => 'Version', 
     448            'Author' => 'Author', 
     449            'AuthorURI' => 'Author URI', 
     450        ); 
     451 
     452        $actual = get_file_data( DIR_TESTDATA . '/themedir1/default/style.css', $theme_headers ); 
     453 
     454        $expected = array( 
     455            'Name' => 'WordPress Default', 
     456            'ThemeURI' => 'http://wordpress.org/', 
     457            'Description' => 'The default WordPress theme based on the famous <a href="http://binarybonsai.com/kubrick/">Kubrick</a>.', 
     458            'Version' => '1.6', 
     459            'Author' => 'Michael Heilemann', 
     460            'AuthorURI' => 'http://binarybonsai.com/', 
     461        ); 
     462 
     463        foreach ( $actual as $header => $value ) 
     464            $this->assertEquals( $expected[ $header ], $value, $header ); 
     465    } 
     466         
     467    function test_get_file_data_cr_line_endings() { 
     468        $headers = array( 'SomeHeader' => 'Some Header', 'Description' => 'Description', 'Author' => 'Author' ); 
     469        $actual = get_file_data( DIR_TESTDATA . '/formatting/cr-line-endings-file-header.php', $headers ); 
     470        $expected = array( 
     471            'SomeHeader' => 'Some header value!', 
     472            'Description' => 'This file is using CR line endings for a testcase.', 
     473            'Author' => 'A Very Old Mac', 
     474        ); 
     475 
     476        foreach ( $actual as $header => $value ) 
     477            $this->assertEquals( $expected[ $header ], $value, $header ); 
     478    } 
     479} 
Note: See TracChangeset for help on using the changeset viewer.