Update Composer, update everything

This commit is contained in:
Oliver Davies 2018-11-23 12:29:20 +00:00
parent ea3e94409f
commit dda5c284b6
19527 changed files with 1135420 additions and 351004 deletions

View file

@ -75,10 +75,12 @@ class ContentEntityFormCorrectUserInputMappingOnFieldDeltaElementsTest extends B
$storage = $this->container->get('entity_type.manager')->getStorage($this->entityTypeId);
/** @var ContentEntityInterface $entity */
$entity = $storage->create([$this->fieldName => [
['shape' => 'rectangle', 'color' => 'green'],
['shape' => 'circle', 'color' => 'blue'],
]]);
$entity = $storage->create([
$this->fieldName => [
['shape' => 'rectangle', 'color' => 'green'],
['shape' => 'circle', 'color' => 'blue'],
],
]);
$entity->save();
$this->drupalGet($this->entityTypeId . '/manage/' . $entity->id() . '/edit');

View file

@ -0,0 +1,163 @@
<?php
namespace Drupal\FunctionalTests\Entity;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\Tests\BrowserTestBase;
use Drupal\Tests\TestFileCreationTrait;
/**
* Tests field validation filtering on content entity forms.
*
* @group Entity
*/
class ContentEntityFormFieldValidationFilteringTest extends BrowserTestBase {
use TestFileCreationTrait;
/**
* The ID of the type of the entity under test.
*
* @var string
*/
protected $entityTypeId;
/**
* The single-valued field name being tested with the entity type.
*
* @var string
*/
protected $fieldNameSingle;
/**
* The multi-valued field name being tested with the entity type.
*
* @var string
*/
protected $fieldNameMultiple;
/**
* The name of the file field being tested with the entity type.
*
* @var string
*/
protected $fieldNameFile;
/**
* {@inheritdoc}
*/
public static $modules = ['entity_test', 'field_test', 'file', 'image'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$web_user = $this->drupalCreateUser(['administer entity_test content']);
$this->drupalLogin($web_user);
// Create two fields of field type "test_field", one with single cardinality
// and one with unlimited cardinality on the entity type "entity_test". It
// is important to use this field type because its default widget has a
// custom \Drupal\Core\Field\WidgetInterface::errorElement() implementation.
$this->entityTypeId = 'entity_test';
$this->fieldNameSingle = 'test_single';
$this->fieldNameMultiple = 'test_multiple';
$this->fieldNameFile = 'test_file';
FieldStorageConfig::create([
'field_name' => $this->fieldNameSingle,
'entity_type' => $this->entityTypeId,
'type' => 'test_field',
'cardinality' => 1,
])->save();
FieldConfig::create([
'entity_type' => $this->entityTypeId,
'field_name' => $this->fieldNameSingle,
'bundle' => $this->entityTypeId,
'label' => 'Test single',
'required' => TRUE,
'translatable' => FALSE,
])->save();
FieldStorageConfig::create([
'field_name' => $this->fieldNameMultiple,
'entity_type' => $this->entityTypeId,
'type' => 'test_field',
'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
])->save();
FieldConfig::create([
'entity_type' => $this->entityTypeId,
'field_name' => $this->fieldNameMultiple,
'bundle' => $this->entityTypeId,
'label' => 'Test multiple',
'translatable' => FALSE,
])->save();
// Also create a file field to test its '#limit_validation_errors'
// implementation.
FieldStorageConfig::create([
'field_name' => $this->fieldNameFile,
'entity_type' => $this->entityTypeId,
'type' => 'file',
'cardinality' => 1,
])->save();
FieldConfig::create([
'entity_type' => $this->entityTypeId,
'field_name' => $this->fieldNameFile,
'bundle' => $this->entityTypeId,
'label' => 'Test file',
'translatable' => FALSE,
])->save();
entity_get_form_display($this->entityTypeId, $this->entityTypeId, 'default')
->setComponent($this->fieldNameSingle, ['type' => 'test_field_widget'])
->setComponent($this->fieldNameMultiple, ['type' => 'test_field_widget'])
->setComponent($this->fieldNameFile, ['type' => 'file_generic'])
->save();
}
/**
* Tests field widgets with #limit_validation_errors.
*/
public function testFieldWidgetsWithLimitedValidationErrors() {
$assert_session = $this->assertSession();
$this->drupalGet($this->entityTypeId . '/add');
// The 'Test multiple' field is the only multi-valued field in the form, so
// try to add a new item for it. This tests the '#limit_validation_errors'
// property set by \Drupal\Core\Field\WidgetBase::formMultipleElements().
$assert_session->elementsCount('css', 'div#edit-test-multiple-wrapper div.form-type-textfield input', 1);
$this->drupalPostForm(NULL, [], 'Add another item');
$assert_session->elementsCount('css', 'div#edit-test-multiple-wrapper div.form-type-textfield input', 2);
// Now try to upload a file. This tests the '#limit_validation_errors'
// property set by
// \Drupal\file\Plugin\Field\FieldWidget\FileWidget::process().
$text_file = current($this->getTestFiles('text'));
$edit = [
'files[test_file_0]' => \Drupal::service('file_system')->realpath($text_file->uri),
];
$assert_session->elementNotExists('css', 'input#edit-test-file-0-remove-button');
$this->drupalPostForm(NULL, $edit, 'Upload');
$assert_session->elementExists('css', 'input#edit-test-file-0-remove-button');
// Make the 'Test multiple' field required and check that adding another
// item throws a validation error.
$field_config = FieldConfig::loadByName($this->entityTypeId, $this->entityTypeId, $this->fieldNameMultiple);
$field_config->setRequired(TRUE);
$field_config->save();
$this->drupalPostForm($this->entityTypeId . '/add', [], 'Add another item');
$assert_session->pageTextContains('Test multiple (value 1) field is required.');
// Check that saving the form without entering any value for the required
// field still throws the proper validation errors.
$this->drupalPostForm(NULL, [], 'Save');
$assert_session->pageTextContains('Test single field is required.');
$assert_session->pageTextContains('Test multiple (value 1) field is required.');
}
}

View file

@ -0,0 +1,157 @@
<?php
namespace Drupal\FunctionalTests\Entity;
use Drupal\entity_test\Entity\EntityTestBundle;
use Drupal\entity_test\Entity\EntityTestMulRevPub;
use Drupal\entity_test\Entity\EntityTestRev;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\Tests\BrowserTestBase;
/**
* Tests the delete multiple confirmation form.
*
* @group Entity
* @runTestsInSeparateProcesses
* @preserveGlobalState disabled
*/
class DeleteMultipleFormTest extends BrowserTestBase {
/**
* The current user.
*
* @var \Drupal\Core\Session\AccountInterface
*/
protected $account;
/**
* Modules to enable.
*
* @var array
*/
public static $modules = ['entity_test', 'user', 'language'];
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
EntityTestBundle::create([
'id' => 'default',
'label' => 'Default',
])->save();
$this->account = $this->drupalCreateUser(['administer entity_test content']);
$this->drupalLogin($this->account);
}
/**
* Tests the delete form for translatable entities.
*/
public function testTranslatableEntities() {
ConfigurableLanguage::create(['id' => 'es'])->save();
ConfigurableLanguage::create(['id' => 'fr'])->save();
$selection = [];
$entity1 = EntityTestMulRevPub::create(['type' => 'default', 'name' => 'entity1']);
$entity1->addTranslation('es', ['name' => 'entity1 spanish']);
$entity1->addTranslation('fr', ['name' => 'entity1 french']);
$entity1->save();
$selection[$entity1->id()]['en'] = 'en';
$entity2 = EntityTestMulRevPub::create(['type' => 'default', 'name' => 'entity2']);
$entity2->addTranslation('es', ['name' => 'entity2 spanish']);
$entity2->addTranslation('fr', ['name' => 'entity2 french']);
$entity2->save();
$selection[$entity2->id()]['es'] = 'es';
$selection[$entity2->id()]['fr'] = 'fr';
$entity3 = EntityTestMulRevPub::create(['type' => 'default', 'name' => 'entity3']);
$entity3->addTranslation('es', ['name' => 'entity3 spanish']);
$entity3->addTranslation('fr', ['name' => 'entity3 french']);
$entity3->save();
$selection[$entity3->id()]['fr'] = 'fr';
// This entity will be inaccessible because of
// Drupal\entity_test\EntityTestAccessControlHandler.
$entity4 = EntityTestMulRevPub::create(['type' => 'default', 'name' => 'forbid_access']);
$entity4->save();
$selection[$entity4->id()]['en'] = 'en';
// Add the selection to the tempstore just like DeleteAction would.
$tempstore = \Drupal::service('tempstore.private')->get('entity_delete_multiple_confirm');
$tempstore->set($this->account->id() . ':entity_test_mulrevpub', $selection);
$this->drupalGet('/entity_test/delete');
$assert = $this->assertSession();
$assert->statusCodeEquals(200);
$assert->elementTextContains('css', '.page-title', 'Are you sure you want to delete these test entity - revisions, data table, and published interface entities?');
$list_selector = '#entity-test-mulrevpub-delete-multiple-confirm-form > div.item-list > ul';
$assert->elementTextContains('css', $list_selector, 'entity1 (Original translation) - The following test entity - revisions, data table, and published interface translations will be deleted:');
$assert->elementTextContains('css', $list_selector, 'entity2 spanish');
$assert->elementTextContains('css', $list_selector, 'entity2 french');
$assert->elementTextNotContains('css', $list_selector, 'entity3 spanish');
$assert->elementTextContains('css', $list_selector, 'entity3 french');
$delete_button = $this->getSession()->getPage()->findButton('Delete');
$delete_button->click();
$assert = $this->assertSession();
$assert->addressEquals('/user/' . $this->account->id());
$assert->responseContains('Deleted 6 items.');
$assert->responseContains('1 item has not been deleted because you do not have the necessary permissions.');
\Drupal::entityTypeManager()->getStorage('entity_test_mulrevpub')->resetCache();
$remaining_entities = EntityTestMulRevPub::loadMultiple([$entity1->id(), $entity2->id(), $entity3->id(), $entity4->id()]);
$this->assertCount(3, $remaining_entities);
}
/**
* Tests the delete form for untranslatable entities.
*/
public function testUntranslatableEntities() {
$selection = [];
$entity1 = EntityTestRev::create(['type' => 'default', 'name' => 'entity1']);
$entity1->save();
$selection[$entity1->id()]['en'] = 'en';
$entity2 = EntityTestRev::create(['type' => 'default', 'name' => 'entity2']);
$entity2->save();
$selection[$entity2->id()]['en'] = 'en';
// This entity will be inaccessible because of
// Drupal\entity_test\EntityTestAccessControlHandler.
$entity3 = EntityTestRev::create(['type' => 'default', 'name' => 'forbid_access']);
$entity3->save();
$selection[$entity3->id()]['en'] = 'en';
// This entity will be inaccessible because of
// Drupal\entity_test\EntityTestAccessControlHandler.
$entity4 = EntityTestRev::create(['type' => 'default', 'name' => 'forbid_access']);
$entity4->save();
$selection[$entity4->id()]['en'] = 'en';
// Add the selection to the tempstore just like DeleteAction would.
$tempstore = \Drupal::service('tempstore.private')->get('entity_delete_multiple_confirm');
$tempstore->set($this->account->id() . ':entity_test_rev', $selection);
$this->drupalGet('/entity_test_rev/delete_multiple');
$assert = $this->assertSession();
$assert->statusCodeEquals(200);
$assert->elementTextContains('css', '.page-title', 'Are you sure you want to delete these test entity - revisions entities?');
$list_selector = '#entity-test-rev-delete-multiple-confirm-form > div.item-list > ul';
$assert->elementTextContains('css', $list_selector, 'entity1');
$assert->elementTextContains('css', $list_selector, 'entity2');
$delete_button = $this->getSession()->getPage()->findButton('Delete');
$delete_button->click();
$assert = $this->assertSession();
$assert->addressEquals('/user/' . $this->account->id());
$assert->responseContains('Deleted 2 items.');
$assert->responseContains('2 items have not been deleted because you do not have the necessary permissions.');
\Drupal::entityTypeManager()->getStorage('entity_test_mulrevpub')->resetCache();
$remaining_entities = EntityTestRev::loadMultiple([$entity1->id(), $entity2->id(), $entity3->id(), $entity4->id()]);
$this->assertCount(2, $remaining_entities);
}
}