Make WordPress Core

Ticket #39141: 39141.unit-test.diff

File 39141.unit-test.diff, 2.2 KB (added by dd32, 9 years ago)
  • tests/phpunit/tests/feed/rss2.php

    class Tests_Feeds_RSS2 extends WP_UnitTe 
    124124                // Verify the channel is present and contains a title child element
    125125                $title = xml_find( $xml, 'rss', 'channel', 'title' );
    126126                $this->assertEquals( get_option( 'blogname' ), $title[0]['content'] );
    127127
    128128                $desc = xml_find( $xml, 'rss', 'channel', 'description' );
    129129                $this->assertEquals( get_option( 'blogdescription' ), $desc[0]['content'] );
    130130
    131131                $link = xml_find( $xml, 'rss', 'channel', 'link' );
    132132                $this->assertEquals( get_option( 'siteurl' ), $link[0]['content'] );
    133133
    134134                $pubdate = xml_find( $xml, 'rss', 'channel', 'lastBuildDate' );
    135135                $this->assertEquals( strtotime( get_lastpostmodified() ), strtotime( $pubdate[0]['content'] ) );
    136136        }
    137137
    138138        /**
     139         * Test that translated feeds have a valid listed date.
     140         * @group 39141
     141         */
     142        function test_channel_pubdate_element_translated() {
     143                $original_locale = $GLOBALS['wp_locale'];
     144                /* @var WP_Locale $locale */
     145                $locale = clone $GLOBALS['wp_locale'];
     146
     147                $locale->weekday[2] = 'Tuesday_Translated';
     148                $locale->weekday_abbrev[ 'Tuesday_Translated' ] = 'Tue_Translated';
     149
     150                $GLOBALS['wp_locale'] = $locale;
     151
     152                $this->go_to( '/?feed=rss2' );
     153                $feed = $this->do_rss2();
     154
     155                // Restore original locale.
     156                $GLOBALS['wp_locale'] = $original_locale;
     157
     158                $xml = xml_to_array( $feed );
     159
     160                // Verify the date is untranslated.
     161                $pubdate = xml_find( $xml, 'rss', 'channel', 'lastBuildDate' );
     162                $this->assertNotContains( 'Tue_Translated', $pubdate[0]['content'] );
     163        }
     164
     165        /**
    139166         * @ticket UT32
    140167         */
    141168        function test_item_elements() {
    142169                $this->go_to( '/?feed=rss2' );
    143170                $feed = $this->do_rss2();
    144171                $xml = xml_to_array( $feed );
    145172
    146173                // Get all the <item> child elements of the <channel> element
    147174                $items = xml_find( $xml, 'rss', 'channel', 'item' );
    148175
    149176                // Verify we are displaying the correct number of posts.
    150177                $this->assertCount( $this->post_count, $items );
    151178
    152179                // We Really only need to test X number of items unless the content is different
    153180                $items = array_slice( $items, 1 );