WordPress.org

Make WordPress Core

Ticket #46227: 46227.2.diff

File 46227.2.diff, 4.8 KB (added by bogerekanzu, 12 months ago)

Added the unit tests for the Add Rel link to feed in the header

  • src/wp-admin/plugins.php

     
    346346                                <p>
    347347                                <?php
    348348                                if ( $data_to_delete ) {
    349                                         _e( 'Are you sure you wish to delete these files and data?' );
     349                                        _e( 'Are you sure you want to delete these files and data?' );
    350350                                } else {
    351                                         _e( 'Are you sure you wish to delete these files?' );
     351                                        _e( 'Are you sure you want to delete these files?' );
    352352                                }
    353353                                ?>
    354354                                </p>
  • src/wp-includes/default-filters.php

     
    294294add_action( 'wp_head', 'wp_print_head_scripts', 9 );
    295295add_action( 'wp_head', 'wp_generator' );
    296296add_action( 'wp_head', 'rel_canonical' );
     297add_action( 'wp_head', 'rel_feed_for_posts', 10, 0 );
    297298add_action( 'wp_head', 'wp_shortlink_wp_head', 10, 0 );
    298299add_action( 'wp_head', 'wp_custom_css_cb', 101 );
    299300add_action( 'wp_head', 'wp_site_icon', 99 );
  • src/wp-includes/general-template.php

     
    45834583
    45844584        return $settings;
    45854585}
     4586
     4587/**
     4588 * Adds a link rel=feed element to the home page when a static front page is set in Settings > Reading
     4589 */
     4590function rel_feed_for_posts() {
     4591        $page_for_posts = get_option( 'page_for_posts' );
     4592
     4593        if ( is_front_page() && ! is_home() ) {
     4594                echo '<link rel="feed" type="text/html" href="' . get_the_permalink( $page_for_posts ) . '" title="' . get_the_title( $page_for_posts ) . '" />';
     4595        }
     4596       
     4597}
  • src/wp-includes/script-loader.php

     
    14451445                        'themeDownloading'        => __( 'Downloading your new theme&hellip;' ),
    14461446                        'themePreviewWait'        => __( 'Setting up your live preview. This may take a bit.' ),
    14471447                        'revertingChanges'        => __( 'Reverting unpublished changes&hellip;' ),
    1448                         'trashConfirm'            => __( 'Are you sure you want to discard your unpublished changes?' ),
     1448                        'trashConfirm'            => __( 'Are you sure you&#8217;d like to discard your unpublished changes?' ),
    14491449                        /* translators: %s: Display name of the user who has taken over the changeset in customizer. */
    14501450                        'takenOverMessage'        => __( '%s has taken over and is currently customizing.' ),
    14511451                        /* translators: %s: URL to the Customizer to load the autosaved version */
  • tests/phpunit/tests/general/document-title.php

     
    66 * @group template
    77 * @group document-title
    88 */
    9 class Tests_General_DocumentTitle extends WP_UnitTestCase {
    109
     10namespace TestGeneralDocumentTitle;
     11
     12class Tests_General_DocumentTitle extends \WP_UnitTestCase {
     13
    1114        public $blog_name;
    1215        public static $category_id;
    1316        public static $author_id;
    1417        public static $post_id;
    1518
    16         public static function wpSetUpBeforeClass( WP_UnitTest_Factory $factory ) {
     19        public static function wpSetUpBeforeClass( \WP_UnitTest_Factory $factory ) {
    1720                self::$category_id = $factory->category->create(
    1821                        array(
    1922                                'name' => 'test_category',
     
    275278        function _change_title_separator( $sep ) {
    276279                return '%%';
    277280        }
     281
     282        //Testing adding custom feed link to the blog page in the header.
     283         function test_add_feed_link_to_header_front_page(){
     284                 //craete a sample blog page.
     285                 $blog_page_id = $this->factory->post->create(
     286                         array(
     287                'post_title' => 'Blog',
     288                                'post_type'  => 'page',
     289                         )
     290                 );
     291                 //make it ablog homepage..
     292                 update_option('page_for_posts', $blog_page_id);
     293                 //by default blog page should not be the homepage(front page)
     294                 update_option('show_on_front', 'page');
     295                 //visit the front page.
     296                 $this->go_to('/');
     297                 $doc = new DOMDocument();
     298                 
     299                 $doc->preserveWhiteSpace = false;
     300                 $str =  '<link rel="feed" type="text/html" href="http://localhost:8012/projects/wordpress-core/build/index.php/blog/" title="Blog" />';
     301                 
     302                  $test_link = $doc.loadHTML($str);
     303                  $selector = new DOMXPath($test_link);
     304                 
     305                  $result = $selector->query('//<link[@rel= "feed"]');
     306                 //get the attribute value from the title
     307                   $testBlogTitle = $result->item(0)->getAttribute('title');
     308               
     309                  $this-> assertEquals($testBlogTitle, $this->blog_name);
     310                 //$this->assertTrue($result);
     311         }
    278312}