Make WordPress Core

Ticket #38101: 38101.diff

File 38101.diff, 3.4 KB (added by peterwilsoncc, 4 years ago)
  • new file tests/phpunit/tests/functions/_cleanup_header_comment.php

    diff --git a/tests/phpunit/tests/functions/_cleanup_header_comment.php b/tests/phpunit/tests/functions/_cleanup_header_comment.php
    new file mode 100644
    index 0000000000..0f1ceed3b0
    - +  
     1<?php
     2/*
     3 * Test _cleanup_header_comment().
     4 *
     5 * @group functions.php
     6 * @ticket 8497
     7 * @ticket 38101
     8 */
     9class Tests_Cleanup_Header_Comment extends WP_UnitTestCase {
     10        /**
     11         * Test cleanup header of header comment.
     12         *
     13         * @covers _cleanup_header_comment
     14         * @dataProvider data_cleanup_header_comment
     15         *
     16         * @param string $test_string
     17         * @param string $expected
     18         */
     19        public function test_cleanup_header_comment( $test_string, $expected ) {
     20                $this->assertEquals( $expected, _cleanup_header_comment( $test_string ) );
     21        }
     22
     23        /**
     24         * Data provider for test_cleanup_header_comment.
     25         *
     26         * @return array[] Test parameters {
     27         *     @type string $test_string Test string.
     28         *     @type string $expected    Expected return value.
     29         * }
     30         */
     31        public function data_cleanup_header_comment() {
     32                return array(
     33                        // Set 0: A string.
     34                        array(
     35                                'ffffffffffffff',
     36                                'ffffffffffffff',
     37                        ),
     38                        // Set 1: Trim a string.
     39                        array(
     40                                '       ffffffffffffff ',
     41                                'ffffffffffffff',
     42                        ),
     43                        // Set 2: Trim a full comment string.
     44                        array(
     45                                '<?php
     46/*
     47Plugin Name: Health Check
     48Plugin URI: https://wordpress.org/plugins/health-check/
     49Description: Checks the health of your WordPress install
     50Version: 0.1.0
     51Author: The Health Check Team
     52Author URI: http://health-check-team.example.com
     53Text Domain: health-check
     54Domain Path: /languages
     55*/
     56',
     57                                '<?php
     58/*
     59Plugin Name: Health Check
     60Plugin URI: https://wordpress.org/plugins/health-check/
     61Description: Checks the health of your WordPress install
     62Version: 0.1.0
     63Author: The Health Check Team
     64Author URI: http://health-check-team.example.com
     65Text Domain: health-check
     66Domain Path: /languages',
     67                        ),
     68                        // Set 3: Trim HTML following comment.
     69                        array(
     70                                '<?php
     71/*
     72Plugin Name: Health Check
     73Plugin URI: https://wordpress.org/plugins/health-check/
     74Description: Checks the health of your WordPress install
     75Version: 0.1.0
     76Author: The Health Check Team
     77Author URI: http://health-check-team.example.com
     78Text Domain: health-check
     79Domain Path: /languages
     80*/ ?>
     81dddlddfs
     82',
     83                                '<?php
     84/*
     85Plugin Name: Health Check
     86Plugin URI: https://wordpress.org/plugins/health-check/
     87Description: Checks the health of your WordPress install
     88Version: 0.1.0
     89Author: The Health Check Team
     90Author URI: http://health-check-team.example.com
     91Text Domain: health-check
     92Domain Path: /languages
     93dddlddfs',
     94                        ),
     95                        // Set 4: Trim a docblock style comment.
     96                        array(
     97                                '<?php
     98/**
     99 * Plugin Name: Health Check
     100 * Plugin URI: https://wordpress.org/plugins/health-check/
     101 * Description: Checks the health of your WordPress install
     102 * Version: 0.1.0
     103 * Author: The Health Check Team
     104 * Author URI: http://health-check-team.example.com
     105 * Text Domain: health-check
     106 * Domain Path: /languages
     107 */',
     108                                '<?php
     109/**
     110 * Plugin Name: Health Check
     111 * Plugin URI: https://wordpress.org/plugins/health-check/
     112 * Description: Checks the health of your WordPress install
     113 * Version: 0.1.0
     114 * Author: The Health Check Team
     115 * Author URI: http://health-check-team.example.com
     116 * Text Domain: health-check
     117 * Domain Path: /languages',
     118                        ),
     119                );
     120        }
     121}