commit 267220cf3473f3c8a4459903ca6d02adf720bece Author: Joel Pittet Date: Wed Sep 23 01:02:58 2015 +0200 customboolean diff --git a/core/modules/views/src/Plugin/views/field/Boolean.php b/core/modules/views/src/Plugin/views/field/Boolean.php index 28a40fd..1e0eab0 100644 --- a/core/modules/views/src/Plugin/views/field/Boolean.php +++ b/core/modules/views/src/Plugin/views/field/Boolean.php @@ -7,7 +7,6 @@ namespace Drupal\views\Plugin\views\field; -use Drupal\Component\Utility\Xss as UtilityXss; use Drupal\Core\Form\FormStateInterface; use Drupal\views\ResultRow; use Drupal\views\ViewExecutable; @@ -118,7 +117,13 @@ public function render(ResultRow $values) { } if ($this->options['type'] == 'custom') { - return $value ? UtilityXss::filterAdmin($this->options['type_custom_true']) : UtilityXss::filterAdmin($this->options['type_custom_false']); + if ($value) { + $build = ['#markup' => $this->options['type_custom_true']]; + } + else { + $build = ['#markup' => $this->options['type_custom_false']]; + } + return \Drupal::service('renderer')->renderPlain($build); } elseif (isset($this->formats[$this->options['type']])) { return $value ? $this->formats[$this->options['type']][0] : $this->formats[$this->options['type']][1]; diff --git a/core/modules/views_ui/src/Tests/CustomBooleanTest.php b/core/modules/views_ui/src/Tests/CustomBooleanTest.php index 4e3a608..9910973 100644 --- a/core/modules/views_ui/src/Tests/CustomBooleanTest.php +++ b/core/modules/views_ui/src/Tests/CustomBooleanTest.php @@ -22,7 +22,7 @@ class CustomBooleanTest extends UITestBase { * * @var array */ - public static $testViews = array('test_view', 'test_page_display'); + public static $testViews = array('test_view'); /** * \Drupal\views\Tests\ViewTestBase::viewsData(). @@ -101,17 +101,10 @@ public function testCustomOption() { $view = Views::getView('test_view'); $output = $view->preview(); $output = \Drupal::service('renderer')->renderRoot($output); - - $replacements = array('%type' => $type); - $this->{$values['test']}(strpos($output, $values['true']), format_string('Expected custom boolean TRUE value in output for %type.', $replacements)); - $this->{$values['test']}(strpos($output, $values['false']), format_string('Expected custom boolean FALSE value in output for %type', $replacements)); + $this->{$values['test']}(strpos($output, $values['true']), 'Expected custom boolean TRUE value ' . $values['true'] . ' in output for ' . $type); + $this->{$values['test']}(strpos($output, $values['false']), 'Expected custom boolean FALSE value ' . $values['false'] . ' in output for ' . $type); } - } - /** - * Tests the setting and output of custom labels for boolean values. - */ - public function testCustomOptionWithTemplate() { // Install theme to test with template system. \Drupal::service('theme_handler')->install(array('views_test_theme')); @@ -119,17 +112,25 @@ public function testCustomOptionWithTemplate() { $this->config('system.theme') ->set('default', 'views_test_theme') ->save(); - $this->assertEqual($this->config('system.theme')->get('default'), 'views_test_theme'); - $this->drupalGet('test_page_display_200'); - // Assert that we are using the correct template. - $this->assertText('llama', 'Loaded the correct views-view-field.html.twig template'); + // Run the same tests on each type. + foreach ($custom_values as $type => $values) { + $options = array( + 'options[type]' => 'custom', + 'options[type_custom_true]' => $values['true'], + 'options[type_custom_false]' => $values['false'], + ); + $this->drupalPostForm('admin/structure/views/nojs/handler/test_view/default/field/age', $options, 'Apply'); - // @todo Fix this. - $this->testCustomOption(); + // Save the view. + $this->drupalPostForm('admin/structure/views/view/test_view', array(), 'Save'); - // Assert that there are no escaped '<'s characters. - $this->assertNoEscaped('<'); + $view = Views::getView('test_view'); + $output = $view->preview(); + $output = \Drupal::service('renderer')->renderRoot($output); + $this->{$values['test']}(strpos($output, $values['true']), 'Expected custom boolean TRUE value ' . $values['true'] . ' in output for ' . $type); + $this->{$values['test']}(strpos($output, $values['false']), 'Expected custom boolean FALSE value ' . $values['false'] . ' in output for ' . $type); + } } }