Make WordPress Core

Ticket #38101: _cleanup_header_comment.php.patch

File _cleanup_header_comment.php.patch, 2.6 KB (added by pbearne, 8 years ago)

unit test

  • tests/phpunit/tests/functions/_cleanup_header_comment.php

     
     1<?php
     2/*
     3 * Test _cleanup_header_comment().
     4 *
     5 * @group functions.php
     6 *
     7*/
     8
     9
     10
     11class Tests_cleanup_header_comment extends WP_UnitTestCase {
     12
     13        /**
     14         * a string
     15         */
     16        public function test_cleanup_header_comment() {
     17                $this->assertEquals( 'ffffffffffffff', _cleanup_header_comment( 'ffffffffffffff' ) );
     18        }
     19
     20
     21        /**
     22         * trim a string
     23         */
     24        public function test_cleanup_header_comment_trim() {
     25                $this->assertEquals( 'ffffffffffffff', _cleanup_header_comment( ' ffffffffffffff ' ) );
     26        }
     27
     28
     29        /**
     30         * trim a string
     31         */
     32        public function test_cleanup_header_comment_good_block() {
     33                $header_comment = '<?php
     34/*
     35Plugin Name: Health Check
     36Plugin URI: https://wordpress.org/plugins/health-check/
     37Description: Checks the health of your WordPress install
     38Version: 0.1.0
     39Author: The Health Check Team
     40Author URI: http://health-check-team.example.com
     41Text Domain: health-check
     42Domain Path: /languages
     43*/
     44';
     45
     46                $expected_header_comment = '<?php
     47/*
     48Plugin Name: Health Check
     49Plugin URI: https://wordpress.org/plugins/health-check/
     50Description: Checks the health of your WordPress install
     51Version: 0.1.0
     52Author: The Health Check Team
     53Author URI: http://health-check-team.example.com
     54Text Domain: health-check
     55Domain Path: /languages';
     56
     57                $this->assertEquals( $expected_header_comment, _cleanup_header_comment( $header_comment )  );
     58        }
     59
     60        /**
     61         * trim a string
     62         */
     63        public function test_cleanup_header_comment_extra_text() {
     64                $header_comment = '<?php
     65/*
     66Plugin Name: Health Check
     67Plugin URI: https://wordpress.org/plugins/health-check/
     68Description: Checks the health of your WordPress install
     69Version: 0.1.0
     70Author: The Health Check Team
     71Author URI: http://health-check-team.example.com
     72Text Domain: health-check
     73Domain Path: /languages
     74*/ ?>
     75dddlddfs
     76';
     77
     78                $expected_header_comment = '<?php
     79/*
     80Plugin Name: Health Check
     81Plugin URI: https://wordpress.org/plugins/health-check/
     82Description: Checks the health of your WordPress install
     83Version: 0.1.0
     84Author: The Health Check Team
     85Author URI: http://health-check-team.example.com
     86Text Domain: health-check
     87Domain Path: /languages
     88dddlddfs';
     89
     90                $this->assertEquals( $expected_header_comment, _cleanup_header_comment( $header_comment ) );
     91        }
     92}
     93