diff --git a/core/includes/common.inc b/core/includes/common.inc index 95ec2e2..5f8f1b8 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -1366,7 +1366,7 @@ function drupal_clear_css_cache() { * @return * The cleaned identifier. * - * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.0. * Use \Drupal\Component\Utility\Html::cleanCssIdentifier() */ function drupal_clean_css_identifier($identifier, $filter = array(' ' => '-', '_' => '-', '__' => '__', '/' => '-', '[' => '-', ']' => '')) { @@ -1385,7 +1385,7 @@ function drupal_clean_css_identifier($identifier, $filter = array(' ' => '-', '_ * @return * The cleaned class name. * - * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.0. * Use \Drupal\Component\Utility\Html::getClass() */ function drupal_html_class($class) { @@ -1419,7 +1419,7 @@ function drupal_html_class($class) { * @return * The cleaned ID. * - * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.0. * Use \Drupal\Component\Utility\Html::getUniqueId() */ function drupal_html_id($id) { @@ -1440,7 +1440,7 @@ function drupal_html_id($id) { * * @see drupal_html_id() * - * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0. + * @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.0. * Use \Drupal\Component\Utility\Html::getId() */ function drupal_clean_id_identifier($id) { diff --git a/core/tests/Drupal/Tests/Core/Utility/HtmlTest.php b/core/tests/Drupal/Tests/Core/Utility/HtmlTest.php index 5ebd0bc..cd78d20 100644 --- a/core/tests/Drupal/Tests/Core/Utility/HtmlTest.php +++ b/core/tests/Drupal/Tests/Core/Utility/HtmlTest.php @@ -13,7 +13,7 @@ /** * Tests \Drupal\Component\Utility\Html. * - * @group Drupal + * @group Common * * @coversDefaultClass \Drupal\Component\Utility\Html */ @@ -22,12 +22,12 @@ class HtmlTest extends UnitTestCase { /** * {@inheritdoc} */ - public static function getInfo() { - return array( - 'name' => 'HTML identifiers', - 'description' => 'Test the methods Html::getClass(), Html::getUniqueId() and Html::cleanCssIdentifier() for expected behavior.', - 'group' => 'Common', - ); + protected function setUp() { + parent::setUp(); + + $property = new \ReflectionProperty('Drupal\Component\Utility\Html', 'seenIdsInit'); + $property->setAccessible(TRUE); + $property->setValue(NULL); } /** @@ -143,6 +143,43 @@ public function providerTestHtmlGetUniqueId() { * The expected result. * @param string $source * The string being transformed to an ID. + * @param bool $reset + * (optional) If TRUE, reset the list of seen IDs. Defaults to FALSE. + * + * @dataProvider providerTestHtmlGetUniqueIdWithAjaxIds + * + * @covers ::getUniqueId + */ + public function testHtmlGetUniqueIdWithAjaxIds($expected, $source, $reset = FALSE) { + if ($reset) { + Html::resetSeenIds(); + } + Html::setAjaxHtmlIds('test-unique-id1 test-unique-id2--3'); + $this->assertSame($expected, Html::getUniqueId($source)); + } + + /** + * Provides test data for testHtmlGetId(). + * + * @return array + * Test data. + */ + public function providerTestHtmlGetUniqueIdWithAjaxIds() { + return array( + array('test-unique-id1--2', 'test-unique-id1', TRUE), + array('test-unique-id1--3', 'test-unique-id1'), + array('test-unique-id2--4', 'test-unique-id2', TRUE), + array('test-unique-id2--5', 'test-unique-id2'), + ); + } + + /** + * Tests the Html::getUniqueId() method. + * + * @param string $expected + * The expected result. + * @param string $source + * The string being transformed to an ID. * * @dataProvider providerTestHtmlGetId *