wordpress-develop/tests/phpunit/tests/functions/cleanupHeaderComment.php
Sergey Biryukov 835e9c48a4 Tests: Add missing @covers tags for files in phpunit/tests/functions/.
Props pbearne, jrf.
See #39265.

git-svn-id: https://develop.svn.wordpress.org/trunk@49006 602fd350-edb4-49c9-b593-d223f7449a82
2020-09-19 15:52:03 +00:00

124 lines
3.0 KiB
PHP

<?php
/**
* Test _cleanup_header_comment().
*
* @ticket 8497
* @ticket 38101
*
* @group functions.php
* @covers ::_cleanup_header_comment
*/
class Tests_Functions_CleanupHeaderComment extends WP_UnitTestCase {
/**
* Test cleanup header of header comment.
*
* @dataProvider data_cleanup_header_comment
*
* @param string $test_string
* @param string $expected
*/
public function test_cleanup_header_comment( $test_string, $expected ) {
$this->assertSameIgnoreEOL( $expected, _cleanup_header_comment( $test_string ) );
}
/**
* Data provider for test_cleanup_header_comment.
*
* @return array[] Test parameters {
* @type string $test_string Test string.
* @type string $expected Expected return value.
* }
*/
public function data_cleanup_header_comment() {
return array(
// Set 0: A string.
array(
'ffffffffffffff',
'ffffffffffffff',
),
// Set 1: Trim a string.
array(
' ffffffffffffff ',
'ffffffffffffff',
),
// Set 2: Trim a full comment string.
array(
'<?php
/*
Plugin Name: Health Check
Plugin URI: https://wordpress.org/plugins/health-check/
Description: Checks the health of your WordPress install
Version: 0.1.0
Author: The Health Check Team
Author URI: http://health-check-team.example.com
Text Domain: health-check
Domain Path: /languages
*/
',
'<?php
/*
Plugin Name: Health Check
Plugin URI: https://wordpress.org/plugins/health-check/
Description: Checks the health of your WordPress install
Version: 0.1.0
Author: The Health Check Team
Author URI: http://health-check-team.example.com
Text Domain: health-check
Domain Path: /languages',
),
// Set 3: Trim HTML following comment.
array(
'<?php
/*
Plugin Name: Health Check
Plugin URI: https://wordpress.org/plugins/health-check/
Description: Checks the health of your WordPress install
Version: 0.1.0
Author: The Health Check Team
Author URI: http://health-check-team.example.com
Text Domain: health-check
Domain Path: /languages
*/ ?>
dddlddfs
',
'<?php
/*
Plugin Name: Health Check
Plugin URI: https://wordpress.org/plugins/health-check/
Description: Checks the health of your WordPress install
Version: 0.1.0
Author: The Health Check Team
Author URI: http://health-check-team.example.com
Text Domain: health-check
Domain Path: /languages
dddlddfs',
),
// Set 4: Trim a docblock style comment.
array(
'<?php
/**
* Plugin Name: Health Check
* Plugin URI: https://wordpress.org/plugins/health-check/
* Description: Checks the health of your WordPress install
* Version: 0.1.0
* Author: The Health Check Team
* Author URI: http://health-check-team.example.com
* Text Domain: health-check
* Domain Path: /languages
*/',
'<?php
/**
* Plugin Name: Health Check
* Plugin URI: https://wordpress.org/plugins/health-check/
* Description: Checks the health of your WordPress install
* Version: 0.1.0
* Author: The Health Check Team
* Author URI: http://health-check-team.example.com
* Text Domain: health-check
* Domain Path: /languages',
),
);
}
}