diff --git a/core/tests/Drupal/Tests/Core/Entity/EntityListControllerTest.php b/core/tests/Drupal/Tests/Core/Entity/EntityListControllerTest.php index 8b83fdf..de9a02e 100644 --- a/core/tests/Drupal/Tests/Core/Entity/EntityListControllerTest.php +++ b/core/tests/Drupal/Tests/Core/Entity/EntityListControllerTest.php @@ -80,24 +80,22 @@ protected function setUp() { /** * Tests that buildRow() returns a string which has been run through - * check_plain. + * String::checkPlain(). * - * @dataProvider Drupal\Tests\Component\Utility\StringTest::providerCheckPlain + * @dataProvider providerBuildRow * * @param string $input * The entity label being passed into buildRow. * @param string $expected * The expected output of the label from buildRow. - * @param string $check_plain_message - * The original message from the StringTest::providerCheckPlain data - * provider used to construct the output for the test. + * @param string $message + * The message to provide as output for the test. * @param bool $ignorewarnings * Whether or not to ignore PHP 5.3+ invalid multibyte sequence warnings. * * @see Drupal\Component\Utility\Drupal\Core\Entity\EntityListController::buildRow() - * @see Drupal\Tests\Component\Utility\StringTest::providerCheckPlain() */ - public function testBuildRow($input, $expected, $check_plain_message, $ignorewarnings = FALSE) { + public function testBuildRow($input, $expected, $message, $ignorewarnings = FALSE) { $this->role->expects($this->any()) ->method('label') @@ -110,11 +108,28 @@ public function testBuildRow($input, $expected, $check_plain_message, $ignorewar $built_row = $this->entityListController->buildRow($this->role); } - $message = "buildRow returns a secure label from String::checkPlain: "; - $message .= $check_plain_message; - $this->assertEquals($built_row['label'], $expected, $message); } + /** + * Data provider for testBuildRow(). + * + * @see testBuildRow() + * @see Drupal\Tests\Component\Utility\StringTest::providerCheckPlain() + */ + public function providerBuildRow() { + // Checks that invalid multi-byte sequences are rejected. + $tests[] = array("Foo\xC0barbaz", '', 'EntityListController::buildRow() rejects invalid sequence "Foo\xC0barbaz"', TRUE); + $tests[] = array("\xc2\"", '', 'EntityListController::buildRow() rejects invalid sequence "\xc2\""', TRUE); + $tests[] = array("Fooÿñ", "Fooÿñ", 'EntityListController::buildRow() accepts valid sequence "Fooÿñ"'); + + // Checks that special characters are escaped. + $tests[] = array("