From 54d12c1346c9dbbd798f2d9e74c2c05afbf40c7f Mon Sep 17 00:00:00 2001 From: Alex Pott <alex.a.pott@googlemail.com> Date: Tue, 14 Jan 2020 21:42:52 +0000 Subject: [PATCH] Issue #3079330 by Berdir: LocaleConfigSubscriberTest has many assertions that don't run --- .../src/Kernel/LocaleConfigSubscriberTest.php | 50 +++++++------------ 1 file changed, 17 insertions(+), 33 deletions(-) diff --git a/core/modules/locale/tests/src/Kernel/LocaleConfigSubscriberTest.php b/core/modules/locale/tests/src/Kernel/LocaleConfigSubscriberTest.php index caa9a734fce5..d77d91d6b16c 100644 --- a/core/modules/locale/tests/src/Kernel/LocaleConfigSubscriberTest.php +++ b/core/modules/locale/tests/src/Kernel/LocaleConfigSubscriberTest.php @@ -386,14 +386,12 @@ protected function deleteLocaleTranslationData($config_name, $key, $source_value * The configuration name. * @param string $langcode * The language code. - * - * @return bool - * TRUE if the assertion succeeded, FALSE otherwise. */ protected function assertNoConfigOverride($config_name, $langcode) { $config_langcode = $this->configFactory->getEditable($config_name)->get('langcode'); $override = $this->languageManager->getLanguageConfigOverride($langcode, $config_name); - return $this->assertNotEqual($config_langcode, $langcode) && $this->assertEqual($override->isNew(), TRUE); + $this->assertNotEqual($config_langcode, $langcode); + $this->assertEqual($override->isNew(), TRUE); } /** @@ -407,14 +405,12 @@ protected function assertNoConfigOverride($config_name, $langcode) { * The configuration value. * @param string $langcode * The language code. - * - * @return bool - * TRUE if the assertion succeeded, FALSE otherwise. */ protected function assertConfigOverride($config_name, $key, $value, $langcode) { $config_langcode = $this->configFactory->getEditable($config_name)->get('langcode'); $override = $this->languageManager->getLanguageConfigOverride($langcode, $config_name); - return $this->assertNotEqual($config_langcode, $langcode) && $this->assertEqual($override->get($key), $value); + $this->assertNotEqual($config_langcode, $langcode); + $this->assertEqual($override->get($key), $value); } /** @@ -428,14 +424,11 @@ protected function assertConfigOverride($config_name, $key, $value, $langcode) { * The configuration value. * @param string $langcode * The language code. - * - * @return bool - * TRUE if the assertion succeeded, FALSE otherwise. */ protected function assertActiveConfig($config_name, $key, $value, $langcode) { $config = $this->configFactory->getEditable($config_name); - return $this->assertEqual($config->get('langcode'), $langcode) && - $this->assertIdentical($config->get($key), $value); + $this->assertEqual($config->get('langcode'), $langcode); + $this->assertIdentical($config->get($key), $value); } /** @@ -445,9 +438,6 @@ protected function assertActiveConfig($config_name, $key, $value, $langcode) { * The configuration name. * @param string $langcode * The language code. - * - * @return bool - * TRUE if the assertion succeeded, FALSE otherwise. */ protected function assertNoTranslation($config_name, $langcode) { $strings = $this->stringStorage->getTranslations([ @@ -456,7 +446,7 @@ protected function assertNoTranslation($config_name, $langcode) { 'language' => $langcode, 'translated' => TRUE, ]); - return $this->assertIdentical([], $strings); + $this->assertIdentical([], $strings); } /** @@ -471,9 +461,6 @@ protected function assertNoTranslation($config_name, $langcode) { * @param bool $customized * Whether or not the string should be asserted to be customized or not * customized. - * - * @return bool - * TRUE if the assertion succeeded, FALSE otherwise. */ protected function assertTranslation($config_name, $translation, $langcode, $customized = TRUE) { // Make sure a string exists. @@ -483,20 +470,17 @@ protected function assertTranslation($config_name, $translation, $langcode, $cus 'language' => $langcode, 'translated' => TRUE, ]); - $pass = $this->assertIdentical(1, count($strings)); + $this->assertIdentical(1, count($strings)); $string = reset($strings); - if ($this->assertTrue($string instanceof StringInterface)) { - /** @var \Drupal\locale\StringInterface $string */ - $pass = $pass && $this->assertIdentical($translation, $string->getString()); - $pass = $pass && $this->assertTrue($string->isTranslation()); - if ($this->assertTrue($string instanceof TranslationString)) { - /** @var \Drupal\locale\TranslationString $string */ - // Make sure the string is marked as customized so that it does not get - // overridden when the string translations are updated. - return $pass && $this->assertEqual($customized, $string->customized); - } - } - return FALSE; + $this->assertTrue($string instanceof StringInterface); + /** @var \Drupal\locale\StringInterface $string */ + $this->assertIdentical($translation, $string->getString()); + $this->assertTrue($string->isTranslation()); + $this->assertTrue($string instanceof TranslationString); + /** @var \Drupal\locale\TranslationString $string */ + // Make sure the string is marked as customized so that it does not get + // overridden when the string translations are updated. + $this->assertEquals($customized, (bool) $string->customized); } } -- GitLab