Update to Drupal 8.1.0. For more information, see https://www.drupal.org/drupal-8.1.0-release-notes
This commit is contained in:
parent
b11a755ba8
commit
c0a0d5a94c
6920 changed files with 64395 additions and 57312 deletions
|
@ -59,7 +59,7 @@ function options_field_storage_config_delete(FieldStorageConfigInterface $field_
|
|||
* @param \Drupal\Core\Entity\FieldableEntityInterface|NULL $entity
|
||||
* (optional) The specific entity when this function is called from the
|
||||
* context of a specific field on a specific entity. This allows custom
|
||||
* 'allowed_values_function' callbacks to either restrict the values or
|
||||
* 'allowed_values_function' callbacks to either restrict the values or
|
||||
* customize the labels for particular bundles and entities. NULL when
|
||||
* there is not a specific entity available, such as for Views filters.
|
||||
*
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\options\Plugin\Field\FieldFormatter\OptionsDefaultFormatter.
|
||||
*/
|
||||
|
||||
namespace Drupal\options\Plugin\Field\FieldFormatter;
|
||||
|
||||
use Drupal\Core\Field\AllowedTagsXssTrait;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\options\Plugin\Field\FieldFormatter\OptionsKeyFormatter.
|
||||
*/
|
||||
|
||||
namespace Drupal\options\Plugin\Field\FieldFormatter;
|
||||
|
||||
use Drupal\Core\Field\AllowedTagsXssTrait;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\options\Plugin\Field\FieldType\ListFloatItem.
|
||||
*/
|
||||
|
||||
namespace Drupal\options\Plugin\Field\FieldType;
|
||||
|
||||
use Drupal\Core\Field\FieldStorageDefinitionInterface;
|
||||
|
@ -104,7 +99,7 @@ class ListFloatItem extends ListItemBase {
|
|||
// Cast the value to a float first so that .5 and 0.5 are the same value
|
||||
// and then cast to a string so that values like 0.5 can be used as array
|
||||
// keys.
|
||||
// @see http://php.net/manual/en/language.types.array.php
|
||||
// @see http://php.net/manual/language.types.array.php
|
||||
$values[(string) (float) $item['value']] = $item['label'];
|
||||
}
|
||||
return $values;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\options\Plugin\Field\FieldType\ListIntegerItem.
|
||||
*/
|
||||
|
||||
namespace Drupal\options\Plugin\Field\FieldType;
|
||||
|
||||
use Drupal\Core\Field\FieldStorageDefinitionInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\options\Plugin\Field\FieldType\ListItemBase.
|
||||
*/
|
||||
|
||||
namespace Drupal\options\Plugin\Field\FieldType;
|
||||
|
||||
use Drupal\Core\Field\AllowedTagsXssTrait;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\options\Plugin\Field\FieldType\ListStringItem.
|
||||
*/
|
||||
|
||||
namespace Drupal\options\Plugin\Field\FieldType;
|
||||
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\options\Plugin\views\argument\NumberListField.
|
||||
*/
|
||||
|
||||
namespace Drupal\options\Plugin\views\argument;
|
||||
|
||||
use Drupal\Core\Field\AllowedTagsXssTrait;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\options\Plugin\views\argument\StringListField.
|
||||
*/
|
||||
|
||||
namespace Drupal\options\Plugin\views\argument;
|
||||
|
||||
use Drupal\Core\Field\AllowedTagsXssTrait;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\options\Plugin\views\filter\ListField.
|
||||
*/
|
||||
|
||||
namespace Drupal\options\Plugin\views\filter;
|
||||
|
||||
use Drupal\views\FieldAPIHandlerTrait;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\options\Tests\OptionsDynamicValuesApiTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\options\Tests;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\options\Tests\OptionsDynamicValuesTestBase.
|
||||
*/
|
||||
|
||||
namespace Drupal\options\Tests;
|
||||
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
use Drupal\field\Tests\FieldTestBase;
|
||||
use Drupal\field\Entity\FieldStorageConfig;
|
||||
use Drupal\entity_test\Entity\EntityTestRev;
|
||||
|
||||
/**
|
||||
* Base class for testing allowed values of options fields.
|
||||
|
@ -39,7 +37,7 @@ abstract class OptionsDynamicValuesTestBase extends FieldTestBase {
|
|||
parent::setUp();
|
||||
|
||||
$field_name = 'test_options';
|
||||
$this->fieldStorage = entity_create('field_storage_config', [
|
||||
$this->fieldStorage = FieldStorageConfig::create([
|
||||
'field_name' => $field_name,
|
||||
'entity_type' => 'entity_test_rev',
|
||||
'type' => 'list_string',
|
||||
|
@ -50,7 +48,7 @@ abstract class OptionsDynamicValuesTestBase extends FieldTestBase {
|
|||
]);
|
||||
$this->fieldStorage->save();
|
||||
|
||||
$this->field = entity_create('field_config', [
|
||||
$this->field = FieldConfig::create([
|
||||
'field_name' => $field_name,
|
||||
'entity_type' => 'entity_test_rev',
|
||||
'bundle' => 'entity_test_rev',
|
||||
|
@ -68,7 +66,7 @@ abstract class OptionsDynamicValuesTestBase extends FieldTestBase {
|
|||
'user_id' => mt_rand(1, 10),
|
||||
'name' => $this->randomMachineName(),
|
||||
];
|
||||
$this->entity = entity_create('entity_test_rev', $values);
|
||||
$this->entity = EntityTestRev::create($values);
|
||||
$this->entity->save();
|
||||
$this->test = [
|
||||
'label' => $this->entity->label(),
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\options\Tests\OptionsDynamicValuesValidationTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\options\Tests;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,12 +1,8 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\options\Tests\OptionsFieldUITest.
|
||||
*/
|
||||
|
||||
namespace Drupal\options\Tests;
|
||||
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
use Drupal\field\Entity\FieldStorageConfig;
|
||||
use Drupal\field\Tests\FieldTestBase;
|
||||
|
||||
|
@ -267,16 +263,16 @@ class OptionsFieldUITest extends FieldTestBase {
|
|||
*/
|
||||
protected function createOptionsField($type) {
|
||||
// Create a field.
|
||||
entity_create('field_storage_config', array(
|
||||
FieldStorageConfig::create(array(
|
||||
'field_name' => $this->fieldName,
|
||||
'entity_type' => 'node',
|
||||
'type' => $type,
|
||||
))->save();
|
||||
entity_create('field_config', array(
|
||||
FieldConfig::create([
|
||||
'field_name' => $this->fieldName,
|
||||
'entity_type' => 'node',
|
||||
'bundle' => $this->type,
|
||||
))->save();
|
||||
])->save();
|
||||
|
||||
entity_get_form_display('node', $this->type, 'default')->setComponent($this->fieldName)->save();
|
||||
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\options\Tests\OptionsFloatFieldImportTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\options\Tests;
|
||||
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\options\Tests\OptionsSelectDynamicValuesTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\options\Tests;
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\options\Tests\OptionsWidgetsTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\options\Tests;
|
||||
|
||||
use Drupal\entity_test\Entity\EntityTest;
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
use Drupal\field\Tests\FieldTestBase;
|
||||
use Drupal\field\Entity\FieldStorageConfig;
|
||||
|
||||
/**
|
||||
* Tests the Options widgets.
|
||||
|
@ -42,7 +40,7 @@ class OptionsWidgetsTest extends FieldTestBase {
|
|||
parent::setUp();
|
||||
|
||||
// Field storage with cardinality 1.
|
||||
$this->card1 = entity_create('field_storage_config', [
|
||||
$this->card1 = FieldStorageConfig::create([
|
||||
'field_name' => 'card_1',
|
||||
'entity_type' => 'entity_test',
|
||||
'type' => 'list_integer',
|
||||
|
@ -62,7 +60,7 @@ class OptionsWidgetsTest extends FieldTestBase {
|
|||
$this->card1->save();
|
||||
|
||||
// Field storage with cardinality 2.
|
||||
$this->card2 = entity_create('field_storage_config', [
|
||||
$this->card2 = FieldStorageConfig::create([
|
||||
'field_name' => 'card_2',
|
||||
'entity_type' => 'entity_test',
|
||||
'type' => 'list_integer',
|
||||
|
@ -88,7 +86,7 @@ class OptionsWidgetsTest extends FieldTestBase {
|
|||
*/
|
||||
function testRadioButtons() {
|
||||
// Create an instance of the 'single value' field.
|
||||
$field = entity_create('field_config', [
|
||||
$field = FieldConfig::create([
|
||||
'field_storage' => $this->card1,
|
||||
'bundle' => 'entity_test',
|
||||
]);
|
||||
|
@ -100,7 +98,7 @@ class OptionsWidgetsTest extends FieldTestBase {
|
|||
->save();
|
||||
|
||||
// Create an entity.
|
||||
$entity = entity_create('entity_test', [
|
||||
$entity = EntityTest::create([
|
||||
'user_id' => 1,
|
||||
'name' => $this->randomMachineName(),
|
||||
]);
|
||||
|
@ -145,10 +143,10 @@ class OptionsWidgetsTest extends FieldTestBase {
|
|||
*/
|
||||
function testCheckBoxes() {
|
||||
// Create an instance of the 'multiple values' field.
|
||||
$field = entity_create('field_config', array(
|
||||
$field = FieldConfig::create([
|
||||
'field_storage' => $this->card2,
|
||||
'bundle' => 'entity_test',
|
||||
));
|
||||
]);
|
||||
$field->save();
|
||||
entity_get_form_display('entity_test', 'entity_test', 'default')
|
||||
->setComponent($this->card2->getName(), array(
|
||||
|
@ -157,7 +155,7 @@ class OptionsWidgetsTest extends FieldTestBase {
|
|||
->save();
|
||||
|
||||
// Create an entity.
|
||||
$entity = entity_create('entity_test', array(
|
||||
$entity = EntityTest::create(array(
|
||||
'user_id' => 1,
|
||||
'name' => $this->randomMachineName(),
|
||||
));
|
||||
|
@ -234,11 +232,11 @@ class OptionsWidgetsTest extends FieldTestBase {
|
|||
*/
|
||||
function testSelectListSingle() {
|
||||
// Create an instance of the 'single value' field.
|
||||
$field = entity_create('field_config', array(
|
||||
$field = FieldConfig::create([
|
||||
'field_storage' => $this->card1,
|
||||
'bundle' => 'entity_test',
|
||||
'required' => TRUE,
|
||||
));
|
||||
]);
|
||||
$field->save();
|
||||
entity_get_form_display('entity_test', 'entity_test', 'default')
|
||||
->setComponent($this->card1->getName(), array(
|
||||
|
@ -247,7 +245,7 @@ class OptionsWidgetsTest extends FieldTestBase {
|
|||
->save();
|
||||
|
||||
// Create an entity.
|
||||
$entity = entity_create('entity_test', array(
|
||||
$entity = EntityTest::create(array(
|
||||
'user_id' => 1,
|
||||
'name' => $this->randomMachineName(),
|
||||
));
|
||||
|
@ -334,10 +332,10 @@ class OptionsWidgetsTest extends FieldTestBase {
|
|||
*/
|
||||
function testSelectListMultiple() {
|
||||
// Create an instance of the 'multiple values' field.
|
||||
$field = entity_create('field_config', array(
|
||||
$field = FieldConfig::create([
|
||||
'field_storage' => $this->card2,
|
||||
'bundle' => 'entity_test',
|
||||
));
|
||||
]);
|
||||
$field->save();
|
||||
entity_get_form_display('entity_test', 'entity_test', 'default')
|
||||
->setComponent($this->card2->getName(), array(
|
||||
|
@ -346,7 +344,7 @@ class OptionsWidgetsTest extends FieldTestBase {
|
|||
->save();
|
||||
|
||||
// Create an entity.
|
||||
$entity = entity_create('entity_test', array(
|
||||
$entity = EntityTest::create(array(
|
||||
'user_id' => 1,
|
||||
'name' => $this->randomMachineName(),
|
||||
));
|
||||
|
@ -455,7 +453,7 @@ class OptionsWidgetsTest extends FieldTestBase {
|
|||
*/
|
||||
function testEmptyValue() {
|
||||
// Create an instance of the 'single value' field.
|
||||
$field = entity_create('field_config', [
|
||||
$field = FieldConfig::create([
|
||||
'field_storage' => $this->card1,
|
||||
'bundle' => 'entity_test',
|
||||
]);
|
||||
|
@ -469,7 +467,7 @@ class OptionsWidgetsTest extends FieldTestBase {
|
|||
->save();
|
||||
|
||||
// Create an entity.
|
||||
$entity = entity_create('entity_test', [
|
||||
$entity = EntityTest::create([
|
||||
'user_id' => 1,
|
||||
'name' => $this->randomMachineName(),
|
||||
]);
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\options\Tests\OptionsFieldTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\options\Tests;
|
||||
namespace Drupal\Tests\options\Kernel;
|
||||
|
||||
use Drupal\Core\Entity\Exception\FieldStorageDefinitionUpdateForbiddenException;
|
||||
use Drupal\entity_test\Entity\EntityTest;
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
use Drupal\field\Entity\FieldStorageConfig;
|
||||
|
||||
/**
|
||||
* Tests for the 'Options' field types.
|
||||
|
@ -28,7 +26,7 @@ class OptionsFieldTest extends OptionsFieldUnitTestBase {
|
|||
*/
|
||||
function testUpdateAllowedValues() {
|
||||
// All three options appear.
|
||||
$entity = entity_create('entity_test');
|
||||
$entity = EntityTest::create();
|
||||
$form = \Drupal::service('entity.form_builder')->getForm($entity);
|
||||
$this->assertTrue(!empty($form[$this->fieldName]['widget'][1]), 'Option 1 exists');
|
||||
$this->assertTrue(!empty($form[$this->fieldName]['widget'][2]), 'Option 2 exists');
|
||||
|
@ -36,7 +34,7 @@ class OptionsFieldTest extends OptionsFieldUnitTestBase {
|
|||
|
||||
// Use one of the values in an actual entity, and check that this value
|
||||
// cannot be removed from the list.
|
||||
$entity = entity_create('entity_test');
|
||||
$entity = EntityTest::create();
|
||||
$entity->{$this->fieldName}->value = 1;
|
||||
$entity->save();
|
||||
$this->fieldStorage->setSetting('allowed_values', [2 => 'Two']);
|
||||
|
@ -54,7 +52,7 @@ class OptionsFieldTest extends OptionsFieldUnitTestBase {
|
|||
// Removed options do not appear.
|
||||
$this->fieldStorage->setSetting('allowed_values', [2 => 'Two']);
|
||||
$this->fieldStorage->save();
|
||||
$entity = entity_create('entity_test');
|
||||
$entity = EntityTest::create();
|
||||
$form = \Drupal::service('entity.form_builder')->getForm($entity);
|
||||
$this->assertTrue(empty($form[$this->fieldName]['widget'][1]), 'Option 1 does not exist');
|
||||
$this->assertTrue(!empty($form[$this->fieldName]['widget'][2]), 'Option 2 exists');
|
||||
|
@ -65,7 +63,7 @@ class OptionsFieldTest extends OptionsFieldUnitTestBase {
|
|||
$this->fieldStorage->save();
|
||||
// The entity holds an outdated field object with the old allowed values
|
||||
// setting, so we need to reinitialize the entity object.
|
||||
$entity = entity_create('entity_test');
|
||||
$entity = EntityTest::create();
|
||||
$form = \Drupal::service('entity.form_builder')->getForm($entity);
|
||||
$this->assertTrue(empty($form[$this->fieldName]['widget'][1]), 'Option 1 does not exist');
|
||||
$this->assertTrue(empty($form[$this->fieldName]['widget'][2]), 'Option 2 does not exist');
|
||||
|
@ -75,26 +73,26 @@ class OptionsFieldTest extends OptionsFieldUnitTestBase {
|
|||
|
||||
// Options are reset when a new field with the same name is created.
|
||||
$this->fieldStorage->delete();
|
||||
entity_create('field_storage_config', $this->fieldStorageDefinition)->save();
|
||||
entity_create('field_config', array(
|
||||
FieldStorageConfig::create($this->fieldStorageDefinition)->save();
|
||||
FieldConfig::create([
|
||||
'field_name' => $this->fieldName,
|
||||
'entity_type' => 'entity_test',
|
||||
'bundle' => 'entity_test',
|
||||
'required' => TRUE,
|
||||
))->save();
|
||||
])->save();
|
||||
entity_get_form_display('entity_test', 'entity_test', 'default')
|
||||
->setComponent($this->fieldName, array(
|
||||
'type' => 'options_buttons',
|
||||
))
|
||||
->save();
|
||||
$entity = entity_create('entity_test');
|
||||
$entity = EntityTest::create();
|
||||
$form = \Drupal::service('entity.form_builder')->getForm($entity);
|
||||
$this->assertTrue(!empty($form[$this->fieldName]['widget'][1]), 'Option 1 exists');
|
||||
$this->assertTrue(!empty($form[$this->fieldName]['widget'][2]), 'Option 2 exists');
|
||||
$this->assertTrue(!empty($form[$this->fieldName]['widget'][3]), 'Option 3 exists');
|
||||
|
||||
// Test the generateSampleValue() method.
|
||||
$entity = entity_create('entity_test');
|
||||
$entity = EntityTest::create();
|
||||
$entity->{$this->fieldName}->generateSampleItems();
|
||||
$this->entityValidateAndSave($entity);
|
||||
}
|
|
@ -1,19 +1,15 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\options\Tests\OptionsFieldUnitTestBase.
|
||||
*/
|
||||
namespace Drupal\Tests\options\Kernel;
|
||||
|
||||
|
||||
namespace Drupal\options\Tests;
|
||||
|
||||
use Drupal\field\Tests\FieldUnitTestBase;
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
use Drupal\Tests\field\Kernel\FieldKernelTestBase;
|
||||
use Drupal\field\Entity\FieldStorageConfig;
|
||||
|
||||
/**
|
||||
* Base class for Options module integration tests.
|
||||
*/
|
||||
abstract class OptionsFieldUnitTestBase extends FieldUnitTestBase {
|
||||
abstract class OptionsFieldUnitTestBase extends FieldKernelTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
|
@ -66,13 +62,13 @@ abstract class OptionsFieldUnitTestBase extends FieldUnitTestBase {
|
|||
'allowed_values' => array(1 => 'One', 2 => 'Two', 3 => 'Three'),
|
||||
),
|
||||
);
|
||||
$this->fieldStorage = entity_create('field_storage_config', $this->fieldStorageDefinition);
|
||||
$this->fieldStorage = FieldStorageConfig::create($this->fieldStorageDefinition);
|
||||
$this->fieldStorage->save();
|
||||
|
||||
$this->field = entity_create('field_config', array(
|
||||
$this->field = FieldConfig::create([
|
||||
'field_storage' => $this->fieldStorage,
|
||||
'bundle' => 'entity_test',
|
||||
));
|
||||
]);
|
||||
$this->field->save();
|
||||
|
||||
entity_get_form_display('entity_test', 'entity_test', 'default')
|
|
@ -1,11 +1,8 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\options\Tests\OptionsFormattersTest.
|
||||
*/
|
||||
namespace Drupal\Tests\options\Kernel;
|
||||
|
||||
namespace Drupal\options\Tests;
|
||||
use Drupal\entity_test\Entity\EntityTest;
|
||||
|
||||
/**
|
||||
* Tests the Options field type formatters.
|
||||
|
@ -27,7 +24,7 @@ class OptionsFormattersTest extends OptionsFieldUnitTestBase {
|
|||
* Tests the formatters.
|
||||
*/
|
||||
public function testFormatter() {
|
||||
$entity = entity_create('entity_test');
|
||||
$entity = EntityTest::create();
|
||||
$entity->{$this->fieldName}->value = 1;
|
||||
|
||||
$items = $entity->get($this->fieldName);
|
|
@ -0,0 +1,92 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\options\Kernel\Views;
|
||||
|
||||
use Drupal\field\Entity\FieldStorageConfig;
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
use Drupal\Tests\views\Kernel\ViewsKernelTestBase;
|
||||
use Drupal\views\Views;
|
||||
|
||||
/**
|
||||
* Tests file views data.
|
||||
*
|
||||
* @group file
|
||||
*/
|
||||
class FileViewsDataTest extends ViewsKernelTestBase {
|
||||
|
||||
/**
|
||||
* Modules to install.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('file', 'views', 'entity_test', 'user', 'field');
|
||||
|
||||
/**
|
||||
* Tests views data generated for file field relationship.
|
||||
*
|
||||
* @see file_field_views_data()
|
||||
* @see file_field_views_data_views_data_alter()
|
||||
*/
|
||||
public function testRelationshipViewsData() {
|
||||
// Create file field to entity_test.
|
||||
FieldStorageConfig::create(array(
|
||||
'entity_type' => 'entity_test',
|
||||
'field_name' => 'field_base_file',
|
||||
'type' => 'file',
|
||||
))->save();
|
||||
FieldConfig::create(array(
|
||||
'entity_type' => 'entity_test',
|
||||
'field_name' => 'field_base_file',
|
||||
'bundle' => 'entity_test',
|
||||
))->save();
|
||||
// Check the generated views data.
|
||||
$views_data = Views::viewsData()->get('entity_test__field_base_file');
|
||||
$relationship = $views_data['field_base_file_target_id']['relationship'];
|
||||
$this->assertEqual($relationship['id'], 'standard');
|
||||
$this->assertEqual($relationship['base'], 'file_managed');
|
||||
$this->assertEqual($relationship['base field'], 'fid');
|
||||
$this->assertEqual($relationship['entity type'], 'file');
|
||||
// Check the backwards reference.
|
||||
$views_data = Views::viewsData()->get('file_managed');
|
||||
$relationship = $views_data['reverse_field_base_file_entity_test']['relationship'];
|
||||
$this->assertEqual($relationship['id'], 'entity_reverse');
|
||||
$this->assertEqual($relationship['base'], 'entity_test');
|
||||
$this->assertEqual($relationship['base field'], 'id');
|
||||
$this->assertEqual($relationship['field table'], 'entity_test__field_base_file');
|
||||
$this->assertEqual($relationship['field field'], 'field_base_file_target_id');
|
||||
$this->assertEqual($relationship['field_name'], 'field_base_file');
|
||||
$this->assertEqual($relationship['entity_type'], 'entity_test');
|
||||
$this->assertEqual($relationship['join_extra'][0], ['field' => 'deleted', 'value' => 0, 'numeric' => TRUE]);
|
||||
|
||||
// Create file field to entity_test_mul.
|
||||
FieldStorageConfig::create(array(
|
||||
'entity_type' => 'entity_test_mul',
|
||||
'field_name' => 'field_data_file',
|
||||
'type' => 'file',
|
||||
))->save();
|
||||
FieldConfig::create(array(
|
||||
'entity_type' => 'entity_test_mul',
|
||||
'field_name' => 'field_data_file',
|
||||
'bundle' => 'entity_test_mul',
|
||||
))->save();
|
||||
// Check the generated views data.
|
||||
$views_data = Views::viewsData()->get('entity_test_mul__field_data_file');
|
||||
$relationship = $views_data['field_data_file_target_id']['relationship'];
|
||||
$this->assertEqual($relationship['id'], 'standard');
|
||||
$this->assertEqual($relationship['base'], 'file_managed');
|
||||
$this->assertEqual($relationship['base field'], 'fid');
|
||||
$this->assertEqual($relationship['entity type'], 'file');
|
||||
// Check the backwards reference.
|
||||
$views_data = Views::viewsData()->get('file_managed');
|
||||
$relationship = $views_data['reverse_field_data_file_entity_test_mul']['relationship'];
|
||||
$this->assertEqual($relationship['id'], 'entity_reverse');
|
||||
$this->assertEqual($relationship['base'], 'entity_test_mul_property_data');
|
||||
$this->assertEqual($relationship['base field'], 'id');
|
||||
$this->assertEqual($relationship['field table'], 'entity_test_mul__field_data_file');
|
||||
$this->assertEqual($relationship['field field'], 'field_data_file_target_id');
|
||||
$this->assertEqual($relationship['field_name'], 'field_data_file');
|
||||
$this->assertEqual($relationship['entity_type'], 'entity_test_mul');
|
||||
$this->assertEqual($relationship['join_extra'][0], ['field' => 'deleted', 'value' => 0, 'numeric' => TRUE]);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,11 +1,6 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\options\Tests\Views\OptionsListArgumentTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\options\Tests\Views;
|
||||
namespace Drupal\Tests\options\Kernel\Views;
|
||||
|
||||
use Drupal\views\Views;
|
||||
|
|
@ -1,11 +1,6 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\options\Tests\Views\OptionsListFilterTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\options\Tests\Views;
|
||||
namespace Drupal\Tests\options\Kernel\Views;
|
||||
|
||||
use Drupal\views\Views;
|
||||
|
|
@ -1,23 +1,18 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\options\Tests\Views\OptionsTestBase.
|
||||
*/
|
||||
|
||||
namespace Drupal\options\Tests\Views;
|
||||
namespace Drupal\Tests\options\Kernel\Views;
|
||||
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
use Drupal\field\Entity\FieldStorageConfig;
|
||||
use Drupal\node\Entity\Node;
|
||||
use Drupal\node\Entity\NodeType;
|
||||
use Drupal\Tests\views\Kernel\ViewsKernelTestBase;
|
||||
use Drupal\views\Tests\ViewTestData;
|
||||
use Drupal\views\Tests\ViewKernelTestBase;
|
||||
|
||||
/**
|
||||
* Base class for options views tests.
|
||||
*/
|
||||
abstract class OptionsTestBase extends ViewKernelTestBase {
|
||||
abstract class OptionsTestBase extends ViewsKernelTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
|
@ -47,7 +42,7 @@ abstract class OptionsTestBase extends ViewKernelTestBase {
|
|||
*/
|
||||
protected $fieldNames;
|
||||
|
||||
protected function setUp() {
|
||||
protected function setUp($import_test_views = TRUE) {
|
||||
parent::setUp();
|
||||
$this->mockStandardInstall();
|
||||
|
|
@ -1,10 +1,9 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\options\Tests\Views\ViewsDataTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\options\Tests\Views;
|
||||
namespace Drupal\Tests\options\Kernel\Views;
|
||||
|
||||
use Drupal\field\Entity\FieldConfig;
|
||||
use Drupal\field\Entity\FieldStorageConfig;
|
||||
|
||||
/**
|
||||
* Test to ensure views data is properly created for the Options module.
|
||||
|
@ -28,11 +27,11 @@ class ViewsDataTest extends OptionsTestBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
protected function setUp($import_test_views = TRUE) {
|
||||
parent::setUp();
|
||||
|
||||
$field_name = 'test_options';
|
||||
$this->fieldStorage = entity_create('field_storage_config', [
|
||||
$this->fieldStorage = FieldStorageConfig::create([
|
||||
'field_name' => $field_name,
|
||||
'entity_type' => 'entity_test',
|
||||
'type' => 'list_string',
|
||||
|
@ -43,7 +42,7 @@ class ViewsDataTest extends OptionsTestBase {
|
|||
]);
|
||||
$this->fieldStorage->save();
|
||||
|
||||
$this->field = entity_create('field_config', [
|
||||
$this->field = FieldConfig::create([
|
||||
'field_name' => $field_name,
|
||||
'entity_type' => 'entity_test',
|
||||
'bundle' => 'entity_test',
|
Reference in a new issue