wordpress-develop/tests/phpunit/tests/formatting/ent2ncr.php
Tonya Mork 40ac5de838 Coding Standards: Add visibility to methods in tests/phpunit/tests/.
Adds a `public` visibility to test fixtures, tests, data providers, and callbacks methods.

Adds a `private` visibility to helper methods within test classes.

Renames callbacks and helpers that previously started with a `_` prefix. Why? For consistency and to leverage using the method visibility. Further naming standardizations is beyond the scope of this commit.

Props costdev, jrf, hellofromTonya.
Fixes #54177.

git-svn-id: https://develop.svn.wordpress.org/trunk@52010 602fd350-edb4-49c9-b593-d223f7449a82
2021-11-04 15:22:47 +00:00

38 lines
897 B
PHP

<?php
/**
* @group formatting
*/
class Tests_Formatting_Ent2ncr extends WP_UnitTestCase {
/**
* @dataProvider entities
*/
public function test_converts_named_entities_to_numeric_character_references( $entity, $ncr ) {
$entity = '&' . $entity . ';';
$ncr = '&#' . $ncr . ';';
$this->assertSame( $ncr, ent2ncr( $entity ), $entity );
}
/**
* Get test data from files, one test per line.
* Comments start with "###".
*/
public function entities() {
$entities = file( DIR_TESTDATA . '/formatting/entities.txt' );
$data_provided = array();
foreach ( $entities as $line ) {
// Comment.
$commentpos = strpos( $line, '###' );
if ( false !== $commentpos ) {
$line = trim( substr( $line, 0, $commentpos ) );
if ( ! $line ) {
continue;
}
}
$data_provided[] = array_map( 'trim', explode( '|', $line ) );
}
return $data_provided;
}
}