diff --git a/core/modules/field/src/Tests/Boolean/BooleanFormatterSettingsTest.php b/core/modules/field/src/Tests/Boolean/BooleanFormatterSettingsTest.php index e9b693d..5b38057 100644 --- a/core/modules/field/src/Tests/Boolean/BooleanFormatterSettingsTest.php +++ b/core/modules/field/src/Tests/Boolean/BooleanFormatterSettingsTest.php @@ -44,6 +44,13 @@ class BooleanFormatterSettingsTest extends WebTestBase { protected $fieldName; /** + * The field instance label. + * + * @var string + */ + protected $label; + + /** * {@inheritdoc} */ protected function setUp() { @@ -66,10 +73,11 @@ protected function setUp() { ]); $field_storage->save(); + $this->label = $this->randomMachineName(); $instance = FieldConfig::create([ 'field_storage' => $field_storage, 'bundle' => $this->bundle, - 'label' => $this->randomMachineName(), + 'label' => $this->label, ]); $instance->save(); @@ -95,6 +103,7 @@ function testBooleanFormatterSettings() { 'Enabled / Disabled', '1 / 0', 'Custom', + $this->label, ); // Define what the "default" option should look like, depending on the diff --git a/core/modules/field/src/Tests/Boolean/BooleanFormatterTest.php b/core/modules/field/src/Tests/Boolean/BooleanFormatterTest.php index 214590d..8589adc 100644 --- a/core/modules/field/src/Tests/Boolean/BooleanFormatterTest.php +++ b/core/modules/field/src/Tests/Boolean/BooleanFormatterTest.php @@ -50,6 +50,13 @@ class BooleanFormatterTest extends KernelTestBase { protected $display; /** + * Field instance label. + * + * @var string + */ + protected $label; + + /** * {@inheritdoc} */ protected function setUp() { @@ -69,10 +76,11 @@ protected function setUp() { ]); $field_storage->save(); + $this->label = $this->randomMachineName(); $instance = FieldConfig::create([ 'field_storage' => $field_storage, 'bundle' => $this->bundle, - 'label' => $this->randomMachineName(), + 'label' => $this->label, ]); $instance->save(); @@ -117,6 +125,10 @@ public function testBooleanFormatter() { $data[] = [1, $format, '✔']; $data[] = [0, $format, '✖']; + $format = ['format' => 'label']; + // @todo test for empty value for 0 result? + $data[] = [1, $format, $this->label]; + $format = [ 'format' => 'custom', 'format_custom_false' => 'FALSE', diff --git a/core/modules/system/src/Tests/Common/AttachedAssetsTest.php b/core/modules/system/src/Tests/Common/AttachedAssetsTest.php index a9701ff..a731b04 100644 --- a/core/modules/system/src/Tests/Common/AttachedAssetsTest.php +++ b/core/modules/system/src/Tests/Common/AttachedAssetsTest.php @@ -45,7 +45,7 @@ class AttachedAssetsTest extends KernelTestBase { /** * {@inheritdoc} */ - public static $modules = array('language', 'simpletest', 'common_test', 'system'); + public static $modules = ['language', 'simpletest', 'common_test', 'system']; /** * {@inheritdoc} @@ -392,6 +392,11 @@ function testRenderDifferentWeight() { * @see simpletest_js_alter() */ function testAlter() { + // Ensure the locale module's js alter works with external sources. + $this->enableModules(['locale']); + $this->installSchema('locale', ['locales_source', 'locales_location']); + $build['#attached']['library'][] = 'common_test/external'; + // Add both tableselect.js and simpletest.js. $build['#attached']['library'][] = 'core/drupal.tableselect'; $build['#attached']['library'][] = 'simpletest/drupal.simpletest'; diff --git a/core/modules/views/src/Tests/Handler/FieldBooleanTest.php b/core/modules/views/src/Tests/Handler/FieldBooleanTest.php index 27b8165..b8a8165 100644 --- a/core/modules/views/src/Tests/Handler/FieldBooleanTest.php +++ b/core/modules/views/src/Tests/Handler/FieldBooleanTest.php @@ -35,6 +35,7 @@ function dataSet() { function viewsData() { $data = parent::viewsData(); $data['views_test_data']['age']['field']['id'] = 'boolean'; + $data['views_test_data']['age']['field']['label'] = 'Foo'; return $data; } @@ -69,11 +70,17 @@ public function testFieldBoolean() { $this->assertEqual(t('False'), $view->field['age']->advancedRender($view->result[0])); $this->assertEqual(t('True'), $view->field['age']->advancedRender($view->result[1])); - // test awesome unicode. + // Test awesome unicode. $view->field['age']->options['type'] = 'unicode-yes-no'; $this->assertEqual('✖', $view->field['age']->advancedRender($view->result[0])); $this->assertEqual('✔', $view->field['age']->advancedRender($view->result[1])); + // Test label. + $view->field['age']->formats['label'] = ['Foo bar', '']; + $view->field['age']->options['type'] = 'label'; + $this->assertEqual('', $view->field['age']->advancedRender($view->result[0])); + $this->assertEqual('Foo bar', $view->field['age']->advancedRender($view->result[1])); + // Set a custom output format. $view->field['age']->formats['test'] = array(t('Test-True'), t('Test-False')); $view->field['age']->options['type'] = 'test';