diff --git a/core/modules/node/src/Tests/NodeTokenLanguageTest.php b/core/modules/node/src/Tests/NodeTokenLanguageTest.php index fe3f2cb..d94fb71 100644 --- a/core/modules/node/src/Tests/NodeTokenLanguageTest.php +++ b/core/modules/node/src/Tests/NodeTokenLanguageTest.php @@ -11,7 +11,6 @@ use Drupal\language\Entity\ConfigurableLanguage; use Drupal\field\Entity\FieldStorageConfig; use Drupal\node\Entity\Node; -use Drupal\user\Entity\User; /** * Check if node tokens are multilingual. @@ -86,7 +85,7 @@ public function testMultilingualNodeTokens() { $node = Node::create($fields); $node->save(); - $this->testTokenReplacement($node); + $this->assertTokenReplacement($node); // Create italian translation with new field values. $langcode = 'it'; @@ -95,7 +94,7 @@ public function testMultilingualNodeTokens() { $node->addTranslation($langcode, $fields); $translation = $node->getTranslation($langcode); - $this->testTokenReplacement($translation); + $this->assertTokenReplacement($translation); } /** @@ -119,12 +118,12 @@ protected function getFieldsArray($langcode) { } /** - * Tests if tokens are correctly replaced. + * Asserts if tokens are correctly replaced. * * @param \Drupal\node\Entity\Node $node * The node for which to test token replacement. */ - protected function testTokenReplacement(Node $node) { + protected function assertTokenReplacement(Node $node) { // Perform unsanitized replacement for easy comparison. $options = ['langcode' => $node->language()->getId(), 'sanitize' => FALSE]; diff --git a/core/modules/node/src/Tests/NodeTokenReplaceTest.php b/core/modules/node/src/Tests/NodeTokenReplaceTest.php index 59a6718..0a06347 100644 --- a/core/modules/node/src/Tests/NodeTokenReplaceTest.php +++ b/core/modules/node/src/Tests/NodeTokenReplaceTest.php @@ -122,7 +122,7 @@ function testNodeTokenReplacement() { 'sanitize' => TRUE, ]; $msg = 'Sanitized node token %token replaced with %output. Expected is %expected'; - $this->testTokenReplacementAndCheckMetadata($tests, $data, $options, $msg, $metadata_tests); + $this->assertTokenReplacementAndCheckMetadata($tests, $data, $options, $msg, $metadata_tests); // Generate and test unsanitized tokens. $tests['[node:type-name]'] = $this->nodeType->label(); @@ -134,7 +134,7 @@ function testNodeTokenReplacement() { $tests['[node:author:name]'] = $account->getUsername(); $options['sanitize'] = FALSE; $msg = 'Unsanitized node token %token replaced with %output. Expected is %expected'; - $this->testTokenReplacement($tests, $data, $options, $msg); + $this->assertTokenReplacement($tests, $data, $options, $msg); // Repeat for a node without a summary. $node = entity_create('node', array( @@ -161,18 +161,18 @@ function testNodeTokenReplacement() { $data = ['node' => $node]; $options['sanitize'] = TRUE; $msg = 'Sanitized node token %token replaced with %output for node without a summary. Expected is %expected'; - $this->testTokenReplacement($tests, $data, $options, $msg); + $this->assertTokenReplacement($tests, $data, $options, $msg); // Generate and test unsanitized tokens. $tests['[node:summary]'] = $node->body->value; $options['sanitize'] = FALSE; $msg = 'Unsanitized node token %token replaced with %output for node without a summary. Expected is %expected'; - $this->testTokenReplacement($tests, $data, $options, $msg); + $this->assertTokenReplacement($tests, $data, $options, $msg); } /** - * Tests if tokens are correctly replaced and verifies that the correct + * Asserts if tokens are correctly replaced and verifies that the correct * metadata has been set. * * @param array $tests @@ -189,7 +189,7 @@ function testNodeTokenReplacement() { * @param array $metadata_tests * The metadata to verify. Keyed by the relevant token. */ - protected function testTokenReplacementAndCheckMetadata(array $tests, array $data, array $options, $message, array $metadata_tests) { + protected function assertTokenReplacementAndCheckMetadata(array $tests, array $data, array $options, $message, array $metadata_tests) { foreach ($tests as $token => $expected) { $bubbleable_metadata = new BubbleableMetadata(); $output = $this->tokenService->replace($token, $data, $options, $bubbleable_metadata); @@ -204,7 +204,7 @@ protected function testTokenReplacementAndCheckMetadata(array $tests, array $dat } /** - * Tests if tokens are correctly replaced. + * Asserts if tokens are correctly replaced. * * @param array $tests * Expected results keyed by their respective tokens. @@ -218,7 +218,7 @@ protected function testTokenReplacementAndCheckMetadata(array $tests, array $dat * - %output for the value returned by the token replacement service * - %expected for the expected result */ - protected function testTokenReplacement(array $tests, array $data, array $options, $message) { + protected function assertTokenReplacement(array $tests, array $data, array $options, $message) { foreach ($tests as $token => $expected) { $output = $this->tokenService->replace($token, $data, $options); $this->assertEqual($output, $expected, SafeMarkup::format($message, [ diff --git a/core/modules/taxonomy/src/Tests/TokenReplaceTest.php b/core/modules/taxonomy/src/Tests/TokenReplaceTest.php index 18f005e..3432009 100644 --- a/core/modules/taxonomy/src/Tests/TokenReplaceTest.php +++ b/core/modules/taxonomy/src/Tests/TokenReplaceTest.php @@ -135,7 +135,7 @@ function testTaxonomyTokenReplacement() { 'sanitize' => TRUE, ]; $msg = 'Sanitized taxonomy term 1 token %token replaced with %output. Expected is %expected'; - $this->testTokenReplacementAndCheckMetadata($tests, $data, $options, $msg, $metadata_tests); + $this->assertTokenReplacementAndCheckMetadata($tests, $data, $options, $msg, $metadata_tests); // Generate and test sanitized tokens for term2. $tests = array(); @@ -157,7 +157,7 @@ function testTaxonomyTokenReplacement() { $data = ['term' => $term2]; $options['sanitize'] = TRUE; $msg = 'Sanitized taxonomy term 2 token %token replaced with %output. Expected is %expected'; - $this->testTokenReplacement($tests, $data, $options, $msg); + $this->assertTokenReplacement($tests, $data, $options, $msg); // Generate and test unsanitized tokens. $tests['[term:name]'] = $term2->getName(); @@ -169,7 +169,7 @@ function testTaxonomyTokenReplacement() { $options['sanitize'] = FALSE; $msg = 'Unsanitized taxonomy term 2 token %token replaced with %output. Expected is %expected'; - $this->testTokenReplacement($tests, $data, $options, $msg); + $this->assertTokenReplacement($tests, $data, $options, $msg); // Generate and test sanitized tokens. $tests = array(); @@ -185,7 +185,7 @@ function testTaxonomyTokenReplacement() { $data = ['vocabulary' => $this->vocabulary]; $options['sanitize'] = TRUE; $msg = 'Sanitized taxonomy vocabulary token %token replaced with %output. Expected is %expected'; - $this->testTokenReplacement($tests, $data, $options, $msg); + $this->assertTokenReplacement($tests, $data, $options, $msg); // Generate and test unsanitized tokens. $tests['[vocabulary:name]'] = $this->vocabulary->label(); @@ -193,11 +193,11 @@ function testTaxonomyTokenReplacement() { $options['sanitize'] = FALSE; $msg = 'Unsanitized taxonomy vocabulary token %token replaced with %output. Expected is %expected.'; - $this->testTokenReplacement($tests, $data, $options, $msg); + $this->assertTokenReplacement($tests, $data, $options, $msg); } /** - * Tests if tokens are correctly replaced and verifies that the correct + * Asserts if tokens are correctly replaced and verifies that the correct * metadata has been set. * * @param array $tests @@ -214,7 +214,7 @@ function testTaxonomyTokenReplacement() { * @param array $metadata_tests * The metadata to verify. Keyed by the relevant token. */ - protected function testTokenReplacementAndCheckMetadata(array $tests, array $data, array $options, $message, array $metadata_tests) { + protected function assertTokenReplacementAndCheckMetadata(array $tests, array $data, array $options, $message, array $metadata_tests) { foreach ($tests as $token => $expected) { $bubbleable_metadata = new BubbleableMetadata(); $output = $this->tokenService->replace($token, $data, $options, $bubbleable_metadata); @@ -229,7 +229,7 @@ protected function testTokenReplacementAndCheckMetadata(array $tests, array $dat } /** - * Tests if tokens are correctly replaced. + * Asserts if tokens are correctly replaced. * * @param array $tests * Expected results keyed by their respective tokens. @@ -243,7 +243,7 @@ protected function testTokenReplacementAndCheckMetadata(array $tests, array $dat * - %output for the value returned by the token replacement service * - %expected for the expected result */ - protected function testTokenReplacement(array $tests, array $data, array $options, $message) { + protected function assertTokenReplacement(array $tests, array $data, array $options, $message) { foreach ($tests as $token => $expected) { $output = $this->tokenService->replace($token, $data, $options); $this->assertEqual($output, $expected, SafeMarkup::format($message, [