Update to Drupal 8.2.4. For more information, see https://www.drupal.org/project/drupal/releases/8.2.4
This commit is contained in:
parent
0a95b8440e
commit
8544b60b39
284 changed files with 12980 additions and 3199 deletions
|
@ -8,6 +8,7 @@ use Drupal\Core\Form\FormInterface;
|
|||
use Drupal\Core\Form\FormState;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\entity_test\Entity\EntityTest;
|
||||
use Drupal\entity_test\Entity\EntityTestStringId;
|
||||
use Drupal\KernelTests\Core\Entity\EntityKernelTestBase;
|
||||
use Drupal\user\Entity\User;
|
||||
|
||||
|
@ -46,6 +47,7 @@ class EntityAutocompleteElementFormTest extends EntityKernelTestBase implements
|
|||
parent::setUp();
|
||||
|
||||
$this->installSchema('system', ['key_value_expire']);
|
||||
$this->installEntitySchema('entity_test_string_id');
|
||||
\Drupal::service('router.builder')->rebuild();
|
||||
|
||||
$this->testUser = User::create(array(
|
||||
|
@ -68,6 +70,17 @@ class EntityAutocompleteElementFormTest extends EntityKernelTestBase implements
|
|||
$entity->save();
|
||||
$this->referencedEntities[] = $entity;
|
||||
}
|
||||
|
||||
// Use special characters in the ID of some of the test entities so we can
|
||||
// test if these are handled correctly.
|
||||
for ($i = 0; $i < 2; $i++) {
|
||||
$entity = EntityTestStringId::create([
|
||||
'name' => $this->randomMachineName(),
|
||||
'id' => $this->randomMachineName() . '&</\\:?',
|
||||
]);
|
||||
$entity->save();
|
||||
$this->referencedEntities[] = $entity;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -150,6 +163,16 @@ class EntityAutocompleteElementFormTest extends EntityKernelTestBase implements
|
|||
'#default_value' => array($this->referencedEntities[0], $this->referencedEntities[1]),
|
||||
);
|
||||
|
||||
$form['single_string_id'] = array(
|
||||
'#type' => 'entity_autocomplete',
|
||||
'#target_type' => 'entity_test_string_id',
|
||||
);
|
||||
$form['tags_string_id'] = array(
|
||||
'#type' => 'entity_autocomplete',
|
||||
'#target_type' => 'entity_test_string_id',
|
||||
'#tags' => TRUE,
|
||||
);
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
|
@ -181,6 +204,8 @@ class EntityAutocompleteElementFormTest extends EntityKernelTestBase implements
|
|||
$this->getAutocompleteInput($this->referencedEntities[0])
|
||||
. ', tags - autocreated entity label with specific uid, '
|
||||
. $this->getAutocompleteInput($this->referencedEntities[1]),
|
||||
'single_string_id' => $this->getAutocompleteInput($this->referencedEntities[2]),
|
||||
'tags_string_id' => $this->getAutocompleteInput($this->referencedEntities[2]) . ', ' . $this->getAutocompleteInput($this->referencedEntities[3]),
|
||||
]);
|
||||
$form_builder = $this->container->get('form_builder');
|
||||
$form_builder->submitForm($this, $form_state);
|
||||
|
@ -231,6 +256,16 @@ class EntityAutocompleteElementFormTest extends EntityKernelTestBase implements
|
|||
$this->assertEqual($value[1]['entity']->getOwnerId(), $this->testAutocreateUser->id());
|
||||
// Third value is an existing entity.
|
||||
$this->assertEqual($value[2]['target_id'], $this->referencedEntities[1]->id());
|
||||
|
||||
// Test the 'single_string_id' element.
|
||||
$this->assertEquals($this->referencedEntities[2]->id(), $form_state->getValue('single_string_id'));
|
||||
|
||||
// Test the 'tags_string_id' element.
|
||||
$expected = [
|
||||
['target_id' => $this->referencedEntities[2]->id()],
|
||||
['target_id' => $this->referencedEntities[3]->id()],
|
||||
];
|
||||
$this->assertEquals($expected, $form_state->getValue('tags_string_id'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\KernelTests\Core\Entity;
|
||||
|
||||
use Drupal\Component\Plugin\Exception\PluginNotFoundException;
|
||||
use Drupal\Component\Utility\Unicode;
|
||||
use Drupal\entity_test\Entity\EntityTest;
|
||||
use Drupal\field\Tests\EntityReference\EntityReferenceTestTrait;
|
||||
|
@ -115,7 +117,7 @@ class EntityQueryRelationshipTest extends EntityKernelTestBase {
|
|||
* Tests querying.
|
||||
*/
|
||||
public function testQuery() {
|
||||
// This returns the 0th entity as that's only one pointing to the 0th
|
||||
// This returns the 0th entity as that's the only one pointing to the 0th
|
||||
// account.
|
||||
$this->queryResults = $this->factory->get('entity_test')
|
||||
->condition("user_id.entity.name", $this->accounts[0]->getUsername())
|
||||
|
@ -154,6 +156,56 @@ class EntityQueryRelationshipTest extends EntityKernelTestBase {
|
|||
->condition("$this->fieldName.entity.name", $this->terms[0]->name->value, '<>')
|
||||
->execute();
|
||||
$this->assertResults(array(1, 2));
|
||||
// This returns the 0th entity as that's only one pointing to the 0th
|
||||
// account.
|
||||
$this->queryResults = $this->factory->get('entity_test')
|
||||
->condition("user_id.entity:user.name", $this->accounts[0]->getUsername())
|
||||
->execute();
|
||||
$this->assertResults(array(0));
|
||||
// This returns the 1st and 2nd entity as those point to the 1st account.
|
||||
$this->queryResults = $this->factory->get('entity_test')
|
||||
->condition("user_id.entity:user.name", $this->accounts[0]->getUsername(), '<>')
|
||||
->execute();
|
||||
$this->assertResults(array(1, 2));
|
||||
// This returns all three entities because all of them point to an
|
||||
// account.
|
||||
$this->queryResults = $this->factory->get('entity_test')
|
||||
->exists("user_id.entity:user.name")
|
||||
->execute();
|
||||
$this->assertResults(array(0, 1, 2));
|
||||
// This returns no entities because all of them point to an account.
|
||||
$this->queryResults = $this->factory->get('entity_test')
|
||||
->notExists("user_id.entity:user.name")
|
||||
->execute();
|
||||
$this->assertEqual(count($this->queryResults), 0);
|
||||
// This returns the 0th entity as that's only one pointing to the 0th
|
||||
// term (test without specifying the field column).
|
||||
$this->queryResults = $this->factory->get('entity_test')
|
||||
->condition("$this->fieldName.entity:taxonomy_term.name", $this->terms[0]->name->value)
|
||||
->execute();
|
||||
$this->assertResults(array(0));
|
||||
// This returns the 0th entity as that's only one pointing to the 0th
|
||||
// term (test with specifying the column name).
|
||||
$this->queryResults = $this->factory->get('entity_test')
|
||||
->condition("$this->fieldName.target_id.entity:taxonomy_term.name", $this->terms[0]->name->value)
|
||||
->execute();
|
||||
$this->assertResults(array(0));
|
||||
// This returns the 1st and 2nd entity as those point to the 1st term.
|
||||
$this->queryResults = $this->factory->get('entity_test')
|
||||
->condition("$this->fieldName.entity:taxonomy_term.name", $this->terms[0]->name->value, '<>')
|
||||
->execute();
|
||||
$this->assertResults(array(1, 2));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the invalid specifier in the query relationship.
|
||||
*/
|
||||
public function testInvalidSpecifier() {
|
||||
$this->setExpectedException(PluginNotFoundException::class);
|
||||
$this->factory
|
||||
->get('taxonomy_term')
|
||||
->condition('langcode.language.foo', 'bar')
|
||||
->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
namespace Drupal\KernelTests\Core\Entity;
|
||||
|
||||
use Drupal\Core\Entity\EntityViewBuilder;
|
||||
use Drupal\Core\Language\LanguageInterface;
|
||||
use Drupal\field\Tests\EntityReference\EntityReferenceTestTrait;
|
||||
use Drupal\Core\Cache\Cache;
|
||||
|
@ -210,4 +211,23 @@ class EntityViewBuilderTest extends EntityKernelTestBase {
|
|||
return $this->container->get('entity.manager')->getStorage($entity_type)->create($data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that viewing an entity without template does not specify #theme.
|
||||
*/
|
||||
public function testNoTemplate() {
|
||||
// Ensure that an entity type without explicit view builder uses the
|
||||
// default.
|
||||
$entity_type_manager = \Drupal::entityTypeManager();
|
||||
$entity_type = $entity_type_manager->getDefinition('entity_test_base_field_display');
|
||||
$this->assertTrue($entity_type->hasViewBuilderClass());
|
||||
$this->assertEquals(EntityViewBuilder::class, $entity_type->getViewBuilderClass());
|
||||
|
||||
// Ensure that an entity without matching template does not have a #theme
|
||||
// key.
|
||||
$entity = $this->createTestEntity('entity_test');
|
||||
$build = $entity_type_manager->getViewBuilder('entity_test')->view($entity);
|
||||
$this->assertEquals($entity, $build['#entity_test']);
|
||||
$this->assertFalse(array_key_exists('#theme', $build));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Reference in a new issue