Commit 6c614cbf authored by catch's avatar catch

Issue #2459289 by Lendude, dhrjgpt2005, kalistos, dawehner, david_garcia:...

Issue #2459289 by Lendude, dhrjgpt2005, kalistos, dawehner, david_garcia: Boolean default values are not saved
parent 97642595
......@@ -132,7 +132,7 @@ display:
entity_type: node
filters:
status:
value: true
value: '1'
table: node_field_data
field: status
id: status
......
......@@ -854,7 +854,7 @@ display:
plugin_id: field
filters:
status:
value: true
value: '1'
table: node_field_data
field: status
plugin_id: boolean
......
......@@ -173,7 +173,7 @@ display:
entity_field: changed
filters:
status:
value: true
value: '1'
table: comment_field_data
field: status
id: status
......@@ -184,7 +184,7 @@ display:
entity_type: comment
entity_field: status
status_node:
value: true
value: '1'
table: node_field_data
field: status
relationship: node
......
......@@ -120,7 +120,7 @@ display:
entity_field: subject
filters:
status:
value: true
value: '1'
table: comment_field_data
field: status
id: status
......@@ -131,7 +131,7 @@ display:
entity_type: comment
entity_field: status
status_node:
value: true
value: '1'
table: node_field_data
field: status
relationship: node
......
......@@ -111,7 +111,7 @@ display:
entity_type: user
filters:
status:
value: true
value: '1'
table: users_field_data
field: status
id: status
......
......@@ -146,6 +146,16 @@ public function testBooleanFilterHandler() {
$this->assertEqual(t('True'), (string) $option[0]);
$option = $this->xpath('//label[@for="edit-options-value-0"]');
$this->assertEqual(t('False'), (string) $option[0]);
// Expose the filter and see if the 'Any' option is added and if we can save
// it.
$this->drupalPostForm(NULL, [], 'Expose filter');
$option = $this->xpath('//label[@for="edit-options-value-all"]');
$this->assertEqual(t('- Any -'), (string) $option[0]);
$this->drupalPostForm(NULL, ['options[value]' => 'All', 'options[expose][required]' => FALSE], 'Apply');
$this->drupalPostForm(NULL, [], 'Save');
$this->drupalGet('/admin/structure/views/nojs/handler/test_view_fieldapi/default/filter/field_boolean_value');
$this->assertFieldChecked('edit-options-value-all');
}
}
......@@ -147,7 +147,7 @@ display:
plugin_id: field
filters:
status:
value: true
value: '1'
table: node_field_data
field: status
plugin_id: boolean
......
......@@ -106,7 +106,7 @@ display:
id: status
table: node_field_data
field: status
value: true
value: '1'
group: 0
expose:
operator: '0'
......
......@@ -370,7 +370,7 @@ display:
group_type: group
admin_label: ''
operator: '='
value: true
value: '1'
group: 1
exposed: true
expose:
......
......@@ -105,7 +105,7 @@ display:
operator: '='
relationship: none
table: node_field_data
value: true
value: '1'
plugin_id: boolean
entity_type: node
entity_field: promote
......@@ -116,7 +116,7 @@ display:
group: 1
id: status
table: node_field_data
value: true
value: '1'
plugin_id: boolean
entity_type: node
entity_field: status
......
......@@ -91,7 +91,7 @@ display:
plugin_id: field
filters:
status:
value: true
value: '1'
table: node_field_data
field: status
id: status
......@@ -177,7 +177,7 @@ display:
filter_groups: false
filters:
status:
value: true
value: '1'
table: node_field_data
field: status
id: status
......@@ -244,7 +244,7 @@ display:
filter_groups: false
filters:
status:
value: true
value: '1'
table: node_field_data
field: status
id: status
......@@ -311,7 +311,7 @@ display:
filter_groups: false
filters:
status:
value: true
value: '1'
table: node_field_data
field: status
id: status
......
......@@ -166,7 +166,7 @@ display:
type: language
filters:
status:
value: true
value: '1'
table: node_field_data
field: status
id: status
......
......@@ -123,7 +123,7 @@ display:
plugin_id: node_path
filters:
status:
value: true
value: '1'
table: node_field_data
field: status
plugin_id: boolean
......
......@@ -29,7 +29,7 @@ display:
group: 1
id: status
table: node_field_data
value: true
value: '1'
plugin_id: boolean
entity_type: node
entity_field: status
......
......@@ -123,7 +123,7 @@ display:
entity_field: nid
filters:
status:
value: true
value: '1'
table: node_field_data
field: status
id: status
......
......@@ -89,7 +89,7 @@ display:
plugin_id: field
filters:
status:
value: true
value: '1'
table: node_field_data
field: status
id: status
......
......@@ -89,7 +89,7 @@ display:
plugin_id: field
filters:
status:
value: true
value: '1'
table: node_field_data
field: status
id: status
......
......@@ -89,7 +89,7 @@ display:
plugin_id: field
filters:
status:
value: true
value: '1'
table: node_field_data
field: status
id: status
......
......@@ -223,7 +223,7 @@ display:
plugin_id: numeric
filters:
status:
value: true
value: '1'
table: node_field_data
field: status
id: status
......
......@@ -250,27 +250,28 @@ protected function runUpdates() {
// Ensure there are no failed updates.
if ($this->checkFailedUpdates) {
$this->assertNoRaw('<strong>' . t('Failed:') . '</strong>');
}
// The config schema can be incorrect while the update functions are being
// executed. But once the update has been completed, it needs to be valid
// again. Assert the schema of all configuration objects now.
$names = $this->container->get('config.storage')->listAll();
/** @var \Drupal\Core\Config\TypedConfigManagerInterface $typed_config */
$typed_config = $this->container->get('config.typed');
$typed_config->clearCachedDefinitions();
foreach ($names as $name) {
$config = $this->config($name);
$this->assertConfigSchema($typed_config, $name, $config->get());
}
// The config schema can be incorrect while the update functions are being
// executed. But once the update has been completed, it needs to be valid
// again. Assert the schema of all configuration objects now.
$names = $this->container->get('config.storage')->listAll();
/** @var \Drupal\Core\Config\TypedConfigManagerInterface $typed_config */
$typed_config = $this->container->get('config.typed');
$typed_config->clearCachedDefinitions();
foreach ($names as $name) {
$config = $this->config($name);
$this->assertConfigSchema($typed_config, $name, $config->get());
}
// Ensure that the update hooks updated all entity schema.
$needs_updates = \Drupal::entityDefinitionUpdateManager()->needsUpdates();
$this->assertFalse($needs_updates, 'After all updates ran, entity schema is up to date.');
if ($needs_updates) {
foreach (\Drupal::entityDefinitionUpdateManager()->getChangeSummary() as $entity_type_id => $summary) {
foreach ($summary as $message) {
$this->fail($message);
// Ensure that the update hooks updated all entity schema.
$needs_updates = \Drupal::entityDefinitionUpdateManager()->needsUpdates();
$this->assertFalse($needs_updates, 'After all updates ran, entity schema is up to date.');
if ($needs_updates) {
foreach (\Drupal::entityDefinitionUpdateManager()
->getChangeSummary() as $entity_type_id => $summary) {
foreach ($summary as $message) {
$this->fail($message);
}
}
}
}
......
......@@ -88,7 +88,7 @@ display:
entity_field: title
filters:
status:
value: true
value: '1'
table: node_field_data
field: status
id: status
......
......@@ -182,7 +182,7 @@ display:
group_type: group
admin_label: ''
operator: '='
value: true
value: '1'
group: 1
exposed: false
expose:
......
......@@ -130,7 +130,7 @@ display:
field_api_classes: false
filters:
status:
value: true
value: '1'
table: node_field_data
field: status
plugin_id: boolean
......
......@@ -116,7 +116,7 @@ display:
entity_field: title
filters:
status:
value: true
value: '1'
table: node_field_data
field: status
id: status
......
......@@ -116,7 +116,7 @@ display:
entity_field: title
filters:
status:
value: true
value: '1'
table: node_field_data
field: status
id: status
......
......@@ -116,7 +116,7 @@ display:
entity_field: title
filters:
status:
value: true
value: '1'
table: node_field_data
field: status
id: status
......
......@@ -705,7 +705,7 @@ display:
group_type: group
admin_label: ''
operator: '='
value: true
value: '1'
group: 1
exposed: true
expose:
......@@ -753,7 +753,7 @@ display:
group_type: group
admin_label: ''
operator: '='
value: true
value: '1'
group: 1
exposed: false
expose:
......
......@@ -89,7 +89,7 @@ display:
entity_field: name
filters:
status:
value: true
value: '1'
table: users_field_data
field: status
id: status
......
......@@ -96,7 +96,7 @@ display:
entity_field: name
filters:
status:
value: true
value: '1'
table: users_field_data
field: status
id: status
......
......@@ -48,7 +48,7 @@ display:
group: 1
id: status
table: users_field_data
value: true
value: '1'
plugin_id: boolean
entity_type: user
entity_field: status
......
......@@ -52,7 +52,7 @@ display:
table: users_field_data
field: status
operator: '='
value: true
value: '1'
plugin_id: boolean
entity_type: user
entity_field: status
......
......@@ -126,7 +126,7 @@ display:
field_api_classes: false
filters:
status:
value: true
value: '1'
table: users_field_data
field: status
plugin_id: boolean
......
......@@ -142,7 +142,7 @@ display:
plugin_id: user_roles
filters:
status:
value: true
value: '1'
table: users_field_data
field: status
id: status
......
......@@ -123,7 +123,7 @@ views.filter.group_item.numeric:
# Schema for the views filter value.
views.filter_value.boolean:
type: boolean
type: string
views.filter_value.combine:
type: string
......
<?php
namespace Drupal\views\Tests\Update;
use Drupal\system\Tests\Update\UpdatePathTestBase;
use Drupal\views\Entity\View;
/**
* Tests the upgrade path for boolean field values.
*
* @see views_post_update_boolean_filter_values()
*
* @group Update
*/
class BooleanFilterValuesUpdateTest extends UpdatePathTestBase {
/**
* {@inheritdoc}
*/
protected function setDatabaseDumpFiles() {
$this->databaseDumpFiles = [
__DIR__ . '/../../../../system/tests/fixtures/update/drupal-8.bare.standard.php.gz',
__DIR__ . '/../../../tests/fixtures/update/boolean-filter-values.php',
];
}
/**
* Tests that boolean filter values are updated properly.
*/
public function testViewsPostUpdateBooleanFilterValues() {
$this->runUpdates();
// Load and initialize our test view.
$view = View::load('test_boolean_filter_values');
$data = $view->toArray();
// Check that the field is using the expected string value.
$this->assertIdentical('1', $data['display']['default']['display_options']['filters']['status']['value']);
}
}
<?php
/**
* @file
* Test fixture.
*/
use Drupal\Core\Database\Database;
use Drupal\Core\Serialization\Yaml;
$connection = Database::getConnection();
$connection->insert('config')
->fields(array(
'collection' => '',
'name' => 'views.view.test_boolean_filter_values',
'data' => serialize(Yaml::decode(file_get_contents('core/modules/views/tests/fixtures/update/views.view.test_boolean_filter_values.yml'))),
))
->execute();
......@@ -119,7 +119,7 @@ display:
field_api_classes: false
filters:
status:
value: true
value: '1'
table: node_field_data
field: status
plugin_id: boolean
......
......@@ -133,7 +133,7 @@ display:
group_type: group
admin_label: ''
operator: '='
value: false
value: '0'
group: 1
exposed: false
expose:
......
......@@ -121,7 +121,7 @@ display:
field_api_classes: false
filters:
status:
value: true
value: '1'
table: node_field_data
field: status
plugin_id: boolean
......
......@@ -115,7 +115,7 @@ display:
hide_alter_empty: true
filters:
status:
value: true
value: '1'
table: node_field_data
field: status
plugin_id: boolean
......
......@@ -130,7 +130,7 @@ display:
field_api_classes: false
filters:
status:
value: true
value: '1'
table: node_field_data
field: status
plugin_id: boolean
......
......@@ -110,7 +110,7 @@ display:
hide_alter_empty: true
filters:
status:
value: true
value: '1'
table: node_field_data
field: status
plugin_id: boolean
......
......@@ -371,7 +371,7 @@ display:
group_type: group
admin_label: ''
operator: '='
value: true
value: '1'
group: 1
exposed: true
expose:
......
......@@ -126,7 +126,7 @@ display:
entity_type: node
entity_field: nid
status:
field: status
field: '1'
id: status
table: node_field_data
plugin_id: boolean
......
......@@ -109,7 +109,7 @@ display:
hide_alter_empty: true
filters:
status:
value: true
value: '1'
table: node_field_data
field: status
plugin_id: boolean
......
......@@ -35,7 +35,7 @@ display:
group: 1
id: status
table: node_field_data
value: true
value: '1'
plugin_id: boolean
entity_type: node
entity_field: status
......
......@@ -115,7 +115,7 @@ display:
group: 1
id: status
table: node_field_data
value: true
value: '1'
plugin_id: boolean
entity_type: node
entity_field: status
......
......@@ -215,7 +215,7 @@ display:
destination: true
filters:
status:
value: true
value: '1'
table: node_field_data
field: status
id: status
......
......@@ -224,7 +224,7 @@ display:
plugin_id: date
filters:
status:
value: true
value: '1'
table: node_field_data
field: status
plugin_id: boolean
......
......@@ -144,7 +144,7 @@ display:
plugin_id: field
filters:
status:
value: true
value: '1'
table: node_field_data
field: status
plugin_id: boolean
......
......@@ -41,7 +41,7 @@ display:
group: 1
id: status
table: node_field_data
value: true
value: '1'
plugin_id: boolean
entity_type: node
entity_field: status
......
......@@ -65,7 +65,7 @@ display:
group: 1
id: status
table: node_field_data
value: true
value: '1'