Update Composer, update everything
This commit is contained in:
parent
ea3e94409f
commit
dda5c284b6
19527 changed files with 1135420 additions and 351004 deletions
|
@ -5,5 +5,5 @@ package: Field types
|
|||
version: VERSION
|
||||
core: 8.x
|
||||
dependencies:
|
||||
- field
|
||||
- text
|
||||
- drupal:field
|
||||
- drupal:text
|
||||
|
|
|
@ -122,8 +122,7 @@ function options_field_storage_config_update_forbid(FieldStorageConfigInterface
|
|||
*/
|
||||
function _options_values_in_use($entity_type, $field_name, $values) {
|
||||
if ($values) {
|
||||
$factory = \Drupal::service('entity.query');
|
||||
$result = $factory->get($entity_type)
|
||||
$result = \Drupal::entityQuery($entity_type)
|
||||
->condition($field_name . '.value', $values, 'IN')
|
||||
->count()
|
||||
->accessCheck(FALSE)
|
||||
|
|
|
@ -222,7 +222,7 @@ abstract class ListItemBase extends FieldItemBase implements OptionsProviderInte
|
|||
* @return string
|
||||
* The error message if the specified value is invalid, NULL otherwise.
|
||||
*/
|
||||
protected static function validateAllowedValue($option) { }
|
||||
protected static function validateAllowedValue($option) {}
|
||||
|
||||
/**
|
||||
* Generates a string representation of an array of 'allowed values'.
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Drupal\options\Plugin\Field\FieldType;
|
||||
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
use Drupal\Core\Field\FieldStorageDefinitionInterface;
|
||||
use Drupal\Core\TypedData\DataDefinition;
|
||||
|
||||
|
@ -65,7 +64,7 @@ class ListStringItem extends ListItemBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
protected static function validateAllowedValue($option) {
|
||||
if (Unicode::strlen($option) > 255) {
|
||||
if (mb_strlen($option) > 255) {
|
||||
return t('Allowed values list: each key must be a string at most 255 characters long.');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\options\Plugin\migrate\field\d7;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase;
|
||||
|
||||
/**
|
||||
* @MigrateField(
|
||||
* id = "optionwidgets",
|
||||
* core = {6},
|
||||
* source_module = "optionwidgets",
|
||||
* destination_module = "options"
|
||||
* )
|
||||
*/
|
||||
class OptionWidgetsField extends FieldPluginBase {}
|
|
@ -0,0 +1,21 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\options\Plugin\migrate\field\d7;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase;
|
||||
|
||||
/**
|
||||
* @MigrateField(
|
||||
* id = "list",
|
||||
* type_map = {
|
||||
* "list_boolean" = "boolean",
|
||||
* "list_integer" = "list_integer",
|
||||
* "list_text" = "list_string",
|
||||
* "list_float" = "list_float",
|
||||
* },
|
||||
* core = {7},
|
||||
* source_module = "list",
|
||||
* destination_module = "options"
|
||||
* )
|
||||
*/
|
||||
class ListField extends FieldPluginBase {}
|
|
@ -0,0 +1,15 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\options\Plugin\migrate\field\d7;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\field\FieldPluginBase;
|
||||
|
||||
/**
|
||||
* @MigrateField(
|
||||
* id = "options",
|
||||
* core = {7},
|
||||
* source_module = "options",
|
||||
* destination_module = "options"
|
||||
* )
|
||||
*/
|
||||
class OptionsField extends FieldPluginBase {}
|
|
@ -5,5 +5,5 @@ core: 8.x
|
|||
package: Testing
|
||||
version: VERSION
|
||||
dependencies:
|
||||
- node
|
||||
- options
|
||||
- drupal:node
|
||||
- drupal:options
|
||||
|
|
|
@ -5,5 +5,5 @@ package: Testing
|
|||
version: VERSION
|
||||
core: 8.x
|
||||
dependencies:
|
||||
- options
|
||||
- views
|
||||
- drupal:options
|
||||
- drupal:views
|
||||
|
|
|
@ -3,9 +3,9 @@
|
|||
namespace Drupal\Tests\options\Functional;
|
||||
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
use Drupal\field\Tests\FieldTestBase;
|
||||
use Drupal\field\Entity\FieldStorageConfig;
|
||||
use Drupal\entity_test\Entity\EntityTestRev;
|
||||
use Drupal\Tests\field\Functional\FieldTestBase;
|
||||
|
||||
/**
|
||||
* Base class for testing allowed values of options fields.
|
||||
|
|
|
@ -8,6 +8,7 @@ namespace Drupal\Tests\options\Functional;
|
|||
* @group options
|
||||
*/
|
||||
class OptionsDynamicValuesValidationTest extends OptionsDynamicValuesTestBase {
|
||||
|
||||
/**
|
||||
* Test that allowed values function gets the entity.
|
||||
*/
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace Drupal\Tests\options\Functional;
|
|||
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
use Drupal\field\Entity\FieldStorageConfig;
|
||||
use Drupal\field\Tests\FieldTestBase;
|
||||
use Drupal\Tests\field\Functional\FieldTestBase;
|
||||
|
||||
/**
|
||||
* Tests the Options field UI functionality.
|
||||
|
@ -94,7 +94,7 @@ class OptionsFieldUITest extends FieldTestBase {
|
|||
$node = $this->drupalCreateNode($settings);
|
||||
|
||||
// Check that a flat list of values is rejected once the field has data.
|
||||
$this->assertAllowedValuesInput( "Zero\nOne", 'invalid input', 'Unkeyed lists are rejected once the field has data.');
|
||||
$this->assertAllowedValuesInput("Zero\nOne", 'invalid input', 'Unkeyed lists are rejected once the field has data.');
|
||||
|
||||
// Check that values can be added but values in use cannot be removed.
|
||||
$string = "0|Zero\n1|One\n2|Two";
|
||||
|
@ -259,7 +259,7 @@ class OptionsFieldUITest extends FieldTestBase {
|
|||
* Helper function to create list field of a given type.
|
||||
*
|
||||
* @param string $type
|
||||
* 'list_integer', 'list_float' or 'list_string'
|
||||
* One of 'list_integer', 'list_float' or 'list_string'.
|
||||
*/
|
||||
protected function createOptionsField($type) {
|
||||
// Create a field.
|
||||
|
@ -328,7 +328,7 @@ class OptionsFieldUITest extends FieldTestBase {
|
|||
$edit = [
|
||||
$this->fieldName => '1',
|
||||
];
|
||||
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save and keep published'));
|
||||
$this->drupalPostForm('node/' . $node->id() . '/edit', $edit, t('Save'));
|
||||
|
||||
// Check the node page and see if the values are correct.
|
||||
$file_formatters = ['list_default', 'list_key'];
|
||||
|
|
|
@ -4,7 +4,7 @@ namespace Drupal\Tests\options\Functional;
|
|||
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
use Drupal\field\Entity\FieldStorageConfig;
|
||||
use Drupal\field\Tests\FieldTestBase;
|
||||
use Drupal\Tests\field\Functional\FieldTestBase;
|
||||
|
||||
/**
|
||||
* Tests option fields can be updated and created through config synchronization.
|
||||
|
|
|
@ -8,6 +8,7 @@ namespace Drupal\Tests\options\Functional;
|
|||
* @group options
|
||||
*/
|
||||
class OptionsSelectDynamicValuesTest extends OptionsDynamicValuesTestBase {
|
||||
|
||||
/**
|
||||
* Tests the 'options_select' widget (single select).
|
||||
*/
|
||||
|
@ -24,7 +25,7 @@ class OptionsSelectDynamicValuesTest extends OptionsDynamicValuesTestBase {
|
|||
$options = $this->xpath('//select[@id="edit-test-options"]/option');
|
||||
$this->assertEqual(count($options), count($this->test) + 1);
|
||||
foreach ($options as $option) {
|
||||
$value = (string) $option['value'];
|
||||
$value = $option->getValue();
|
||||
if ($value != '_none') {
|
||||
$this->assertTrue(array_search($value, $this->test));
|
||||
}
|
||||
|
|
|
@ -4,8 +4,8 @@ namespace Drupal\Tests\options\Functional;
|
|||
|
||||
use Drupal\entity_test\Entity\EntityTest;
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
use Drupal\field\Tests\FieldTestBase;
|
||||
use Drupal\field\Entity\FieldStorageConfig;
|
||||
use Drupal\Tests\field\Functional\FieldTestBase;
|
||||
|
||||
/**
|
||||
* Tests the Options widgets.
|
||||
|
@ -35,7 +35,6 @@ class OptionsWidgetsTest extends FieldTestBase {
|
|||
*/
|
||||
protected $card2;
|
||||
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
|
@ -255,13 +254,13 @@ class OptionsWidgetsTest extends FieldTestBase {
|
|||
// Display form.
|
||||
$this->drupalGet('entity_test/manage/' . $entity->id() . '/edit');
|
||||
// A required field without any value has a "none" option.
|
||||
$this->assertTrue($this->xpath('//select[@id=:id]//option[@value="_none" and text()=:label]', [':id' => 'edit-card-1', ':label' => t('- Select a value -')]), 'A required select list has a "Select a value" choice.');
|
||||
$this->assertTrue($this->xpath('//select[@id=:id]//option[@value="_none" and text()=:label]', [':id' => 'edit-card-1', ':label' => '- Select a value -']), 'A required select list has a "Select a value" choice.');
|
||||
|
||||
// With no field data, nothing is selected.
|
||||
$this->assertNoOptionSelected('edit-card-1', '_none');
|
||||
$this->assertNoOptionSelected('edit-card-1', 0);
|
||||
$this->assertNoOptionSelected('edit-card-1', 1);
|
||||
$this->assertNoOptionSelected('edit-card-1', 2);
|
||||
$this->assertTrue($this->assertSession()->optionExists('card_1', '_none')->isSelected());
|
||||
$this->assertFalse($this->assertSession()->optionExists('card_1', 0)->isSelected());
|
||||
$this->assertFalse($this->assertSession()->optionExists('card_1', 1)->isSelected());
|
||||
$this->assertFalse($this->assertSession()->optionExists('card_1', 2)->isSelected());
|
||||
$this->assertRaw('Some dangerous & unescaped markup', 'Option text was properly filtered.');
|
||||
|
||||
// Submit form: select invalid 'none' option.
|
||||
|
@ -278,9 +277,9 @@ class OptionsWidgetsTest extends FieldTestBase {
|
|||
$this->drupalGet('entity_test/manage/' . $entity->id() . '/edit');
|
||||
// A required field with a value has no 'none' option.
|
||||
$this->assertFalse($this->xpath('//select[@id=:id]//option[@value="_none"]', [':id' => 'edit-card-1']), 'A required select list with an actual value has no "none" choice.');
|
||||
$this->assertOptionSelected('edit-card-1', 0);
|
||||
$this->assertNoOptionSelected('edit-card-1', 1);
|
||||
$this->assertNoOptionSelected('edit-card-1', 2);
|
||||
$this->assertTrue($this->assertSession()->optionExists('card_1', 0)->isSelected());
|
||||
$this->assertFalse($this->assertSession()->optionExists('card_1', 1)->isSelected());
|
||||
$this->assertFalse($this->assertSession()->optionExists('card_1', 2)->isSelected());
|
||||
|
||||
// Make the field non required.
|
||||
$field->setRequired(FALSE);
|
||||
|
@ -289,7 +288,7 @@ class OptionsWidgetsTest extends FieldTestBase {
|
|||
// Display form.
|
||||
$this->drupalGet('entity_test/manage/' . $entity->id() . '/edit');
|
||||
// A non-required field has a 'none' option.
|
||||
$this->assertTrue($this->xpath('//select[@id=:id]//option[@value="_none" and text()=:label]', [':id' => 'edit-card-1', ':label' => t('- None -')]), 'A non-required select list has a "None" choice.');
|
||||
$this->assertTrue($this->xpath('//select[@id=:id]//option[@value="_none" and text()=:label]', [':id' => 'edit-card-1', ':label' => '- None -']), 'A non-required select list has a "None" choice.');
|
||||
// Submit form: Unselect the option.
|
||||
$edit = ['card_1' => '_none'];
|
||||
$this->drupalPostForm('entity_test/manage/' . $entity->id() . '/edit', $edit, t('Save'));
|
||||
|
@ -303,9 +302,9 @@ class OptionsWidgetsTest extends FieldTestBase {
|
|||
|
||||
// Display form: with no field data, nothing is selected
|
||||
$this->drupalGet('entity_test/manage/' . $entity->id() . '/edit');
|
||||
$this->assertNoOptionSelected('edit-card-1', 0);
|
||||
$this->assertNoOptionSelected('edit-card-1', 1);
|
||||
$this->assertNoOptionSelected('edit-card-1', 2);
|
||||
$this->assertFalse($this->assertSession()->optionExists('card_1', 0)->isSelected());
|
||||
$this->assertFalse($this->assertSession()->optionExists('card_1', 1)->isSelected());
|
||||
$this->assertFalse($this->assertSession()->optionExists('card_1', 2)->isSelected());
|
||||
$this->assertRaw('Some dangerous & unescaped markup', 'Option text was properly filtered.');
|
||||
$this->assertRaw('More <script>dangerous</script> markup', 'Option group text was properly filtered.');
|
||||
$this->assertRaw('Group 1', 'Option groups are displayed.');
|
||||
|
@ -317,9 +316,9 @@ class OptionsWidgetsTest extends FieldTestBase {
|
|||
|
||||
// Display form: check that the right options are selected.
|
||||
$this->drupalGet('entity_test/manage/' . $entity->id() . '/edit');
|
||||
$this->assertOptionSelected('edit-card-1', 0);
|
||||
$this->assertNoOptionSelected('edit-card-1', 1);
|
||||
$this->assertNoOptionSelected('edit-card-1', 2);
|
||||
$this->assertTrue($this->assertSession()->optionExists('card_1', 0)->isSelected());
|
||||
$this->assertFalse($this->assertSession()->optionExists('card_1', 1)->isSelected());
|
||||
$this->assertFalse($this->assertSession()->optionExists('card_1', 2)->isSelected());
|
||||
|
||||
// Submit form: Unselect the option.
|
||||
$edit = ['card_1' => '_none'];
|
||||
|
@ -353,10 +352,10 @@ class OptionsWidgetsTest extends FieldTestBase {
|
|||
|
||||
// Display form: with no field data, nothing is selected.
|
||||
$this->drupalGet('entity_test/manage/' . $entity->id() . '/edit');
|
||||
$this->assertOptionSelected("edit-card-2", '_none');
|
||||
$this->assertNoOptionSelected('edit-card-2', 0);
|
||||
$this->assertNoOptionSelected('edit-card-2', 1);
|
||||
$this->assertNoOptionSelected('edit-card-2', 2);
|
||||
$this->assertTrue($this->assertSession()->optionExists('card_2', '_none')->isSelected());
|
||||
$this->assertFalse($this->assertSession()->optionExists('card_2', 0)->isSelected());
|
||||
$this->assertFalse($this->assertSession()->optionExists('card_2', 1)->isSelected());
|
||||
$this->assertFalse($this->assertSession()->optionExists('card_2', 2)->isSelected());
|
||||
$this->assertRaw('Some dangerous & unescaped markup', 'Option text was properly filtered.');
|
||||
|
||||
// Submit form: select first and third options.
|
||||
|
@ -366,9 +365,9 @@ class OptionsWidgetsTest extends FieldTestBase {
|
|||
|
||||
// Display form: check that the right options are selected.
|
||||
$this->drupalGet('entity_test/manage/' . $entity->id() . '/edit');
|
||||
$this->assertOptionSelected('edit-card-2', 0);
|
||||
$this->assertNoOptionSelected('edit-card-2', 1);
|
||||
$this->assertOptionSelected('edit-card-2', 2);
|
||||
$this->assertTrue($this->assertSession()->optionExists('card_2', 0)->isSelected());
|
||||
$this->assertFalse($this->assertSession()->optionExists('card_2', 1)->isSelected());
|
||||
$this->assertTrue($this->assertSession()->optionExists('card_2', 2)->isSelected());
|
||||
|
||||
// Submit form: select only first option.
|
||||
$edit = ['card_2[]' => [0 => 0]];
|
||||
|
@ -377,9 +376,9 @@ class OptionsWidgetsTest extends FieldTestBase {
|
|||
|
||||
// Display form: check that the right options are selected.
|
||||
$this->drupalGet('entity_test/manage/' . $entity->id() . '/edit');
|
||||
$this->assertOptionSelected('edit-card-2', 0);
|
||||
$this->assertNoOptionSelected('edit-card-2', 1);
|
||||
$this->assertNoOptionSelected('edit-card-2', 2);
|
||||
$this->assertTrue($this->assertSession()->optionExists('card_2', 0)->isSelected());
|
||||
$this->assertFalse($this->assertSession()->optionExists('card_2', 1)->isSelected());
|
||||
$this->assertFalse($this->assertSession()->optionExists('card_2', 2)->isSelected());
|
||||
|
||||
// Submit form: select the three options while the field accepts only 2.
|
||||
$edit = ['card_2[]' => [0 => 0, 1 => 1, 2 => 2]];
|
||||
|
@ -424,9 +423,9 @@ class OptionsWidgetsTest extends FieldTestBase {
|
|||
|
||||
// Display form: with no field data, nothing is selected.
|
||||
$this->drupalGet('entity_test/manage/' . $entity->id() . '/edit');
|
||||
$this->assertNoOptionSelected('edit-card-2', 0);
|
||||
$this->assertNoOptionSelected('edit-card-2', 1);
|
||||
$this->assertNoOptionSelected('edit-card-2', 2);
|
||||
$this->assertFalse($this->assertSession()->optionExists('card_2', 0)->isSelected());
|
||||
$this->assertFalse($this->assertSession()->optionExists('card_2', 1)->isSelected());
|
||||
$this->assertFalse($this->assertSession()->optionExists('card_2', 2)->isSelected());
|
||||
$this->assertRaw('Some dangerous & unescaped markup', 'Option text was properly filtered.');
|
||||
$this->assertRaw('More <script>dangerous</script> markup', 'Option group text was properly filtered.');
|
||||
$this->assertRaw('Group 1', 'Option groups are displayed.');
|
||||
|
@ -438,9 +437,9 @@ class OptionsWidgetsTest extends FieldTestBase {
|
|||
|
||||
// Display form: check that the right options are selected.
|
||||
$this->drupalGet('entity_test/manage/' . $entity->id() . '/edit');
|
||||
$this->assertOptionSelected('edit-card-2', 0);
|
||||
$this->assertNoOptionSelected('edit-card-2', 1);
|
||||
$this->assertNoOptionSelected('edit-card-2', 2);
|
||||
$this->assertTrue($this->assertSession()->optionExists('card_2', 0)->isSelected());
|
||||
$this->assertFalse($this->assertSession()->optionExists('card_2', 1)->isSelected());
|
||||
$this->assertFalse($this->assertSession()->optionExists('card_2', 2)->isSelected());
|
||||
|
||||
// Submit form: Unselect the option.
|
||||
$edit = ['card_2[]' => ['_none' => '_none']];
|
||||
|
@ -488,7 +487,7 @@ class OptionsWidgetsTest extends FieldTestBase {
|
|||
// Display form: check that _none options are present and has label.
|
||||
$this->drupalGet('entity_test/manage/' . $entity->id() . '/edit');
|
||||
// A required field without any value has a "none" option.
|
||||
$this->assertTrue($this->xpath('//select[@id=:id]//option[@value="_none" and text()=:label]', [':id' => 'edit-card-1', ':label' => t('- None -')]), 'A test select has a "None" choice.');
|
||||
$this->assertTrue($this->xpath('//select[@id=:id]//option[@value="_none" and text()=:label]', [':id' => 'edit-card-1', ':label' => '- None -']), 'A test select has a "None" choice.');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -78,20 +78,20 @@ class OptionsListFilterTest extends OptionsTestBase {
|
|||
'operator' => 'or',
|
||||
'value' => [
|
||||
$this->fieldValues[0] => $this->fieldValues[0],
|
||||
]
|
||||
],
|
||||
],
|
||||
2 => [
|
||||
'title' => 'Second',
|
||||
'operator' => 'or',
|
||||
'value' => [
|
||||
$this->fieldValues[1] => $this->fieldValues[1],
|
||||
]
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
'reduce_duplicates' => '',
|
||||
'plugin_id' => 'list_field',
|
||||
]
|
||||
],
|
||||
];
|
||||
$view->setDisplay();
|
||||
$view->displayHandlers->get('default')->overrideOption('filters', $filters);
|
||||
|
|
Reference in a new issue