| 1 | <?php |
| 2 | /* |
| 3 | * Test _cleanup_header_comment(). |
| 4 | * |
| 5 | * @group functions.php |
| 6 | * @ticket 8497 |
| 7 | * @ticket 38101 |
| 8 | */ |
| 9 | class 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 | /* |
| 47 | Plugin Name: Health Check |
| 48 | Plugin URI: https://wordpress.org/plugins/health-check/ |
| 49 | Description: Checks the health of your WordPress install |
| 50 | Version: 0.1.0 |
| 51 | Author: The Health Check Team |
| 52 | Author URI: http://health-check-team.example.com |
| 53 | Text Domain: health-check |
| 54 | Domain Path: /languages |
| 55 | */ |
| 56 | ', |
| 57 | '<?php |
| 58 | /* |
| 59 | Plugin Name: Health Check |
| 60 | Plugin URI: https://wordpress.org/plugins/health-check/ |
| 61 | Description: Checks the health of your WordPress install |
| 62 | Version: 0.1.0 |
| 63 | Author: The Health Check Team |
| 64 | Author URI: http://health-check-team.example.com |
| 65 | Text Domain: health-check |
| 66 | Domain Path: /languages', |
| 67 | ), |
| 68 | // Set 3: Trim HTML following comment. |
| 69 | array( |
| 70 | '<?php |
| 71 | /* |
| 72 | Plugin Name: Health Check |
| 73 | Plugin URI: https://wordpress.org/plugins/health-check/ |
| 74 | Description: Checks the health of your WordPress install |
| 75 | Version: 0.1.0 |
| 76 | Author: The Health Check Team |
| 77 | Author URI: http://health-check-team.example.com |
| 78 | Text Domain: health-check |
| 79 | Domain Path: /languages |
| 80 | */ ?> |
| 81 | dddlddfs |
| 82 | ', |
| 83 | '<?php |
| 84 | /* |
| 85 | Plugin Name: Health Check |
| 86 | Plugin URI: https://wordpress.org/plugins/health-check/ |
| 87 | Description: Checks the health of your WordPress install |
| 88 | Version: 0.1.0 |
| 89 | Author: The Health Check Team |
| 90 | Author URI: http://health-check-team.example.com |
| 91 | Text Domain: health-check |
| 92 | Domain Path: /languages |
| 93 | dddlddfs', |
| 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 | } |