diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeTypeRenameConfigImportTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeTypeRenameConfigImportTest.php index bd2ba66..5a189ab 100644 --- a/core/modules/node/lib/Drupal/node/Tests/NodeTypeRenameConfigImportTest.php +++ b/core/modules/node/lib/Drupal/node/Tests/NodeTypeRenameConfigImportTest.php @@ -9,6 +9,7 @@ use Drupal\Component\Utility\String; use Drupal\Component\Utility\Unicode; +use Drupal\Component\Utility\Xss; use Drupal\Core\Config\Entity\ConfigEntityStorage; use Drupal\simpletest\WebTestBase; @@ -106,8 +107,12 @@ public function testConfigurationRename() { $entity_type = \Drupal::entityManager()->getDefinition($config_entity_type); $old_id = ConfigEntityStorage::getIDFromConfigName($names['old_name'], $entity_type->getConfigPrefix()); $new_id = ConfigEntityStorage::getIDFromConfigName($names['new_name'], $entity_type->getConfigPrefix()); - $this->assertText('-' . $entity_type->getKey('id') . ': ' . $old_id); - $this->assertText('+' . $entity_type->getKey('id') . ': ' . $new_id); + + $id_key = $entity_type->getKey('id'); + $text = "$id_key: $old_id"; + $this->assertTextPattern('/\-\s+' . preg_quote($text, '/') . '/', "'-$text' found."); + $text = "$id_key: $new_id"; + $this->assertTextPattern('/\+\s+' . preg_quote($text, '/') . '/', "'+$text' found."); } // Run the import. @@ -119,4 +124,27 @@ public function testConfigurationRename() { $this->assertIdentical($staged_type, $content_type->type); } + /** + * Asserts that a Perl regex pattern is found in the text content. + * + * @param string $pattern + * Perl regex to look for including the regex delimiters. + * @param string $message + * (optional) A message to display with the assertion. + * + * @return bool + * TRUE on pass, FALSE on failure. + */ + protected function assertTextPattern($pattern, $message = NULL) { + // @see WebTestBase::assertTextHelper() + if ($this->plainTextContent === FALSE) { + $this->plainTextContent = Xss::filter($this->drupalGetContent(), array()); + } + // @see WebTestBase::assertPattern() + if (!$message) { + $message = String::format('Pattern "@pattern" found', array('@pattern' => $pattern)); + } + return $this->assert((bool) preg_match($pattern, $this->plainTextContent), $message); + } + }