composer update
This commit is contained in:
parent
f6abc3dce2
commit
71dfaca858
1753 changed files with 45274 additions and 14619 deletions
|
@ -40,7 +40,7 @@ trait AssertConfigTrait {
|
|||
|
||||
// Allow to skip entire config files.
|
||||
if ($skipped_config[$config_name] === TRUE) {
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
|
||||
// Allow to skip some specific lines of imported config files.
|
||||
|
@ -71,12 +71,12 @@ trait AssertConfigTrait {
|
|||
case 'Drupal\Component\Diff\Engine\DiffOpAdd':
|
||||
// The _core property does not exist in the default config.
|
||||
if ($op->closing[0] === '_core:') {
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
foreach ($op->closing as $closing) {
|
||||
// The UUIDs don't exist in the default config.
|
||||
if (strpos($closing, 'uuid: ') === 0) {
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
throw new \Exception($config_name . ': ' . var_export($op, TRUE));
|
||||
}
|
||||
|
|
|
@ -29,8 +29,12 @@ class SizeTest extends KernelTestBase {
|
|||
public function providerTestCommonFormatSize() {
|
||||
$kb = Bytes::KILOBYTE;
|
||||
return [
|
||||
['0 bytes', 0],
|
||||
['1 byte', 1],
|
||||
['-1 bytes', -1],
|
||||
['2 bytes', 2],
|
||||
['-2 bytes', -2],
|
||||
['1023 bytes', $kb - 1],
|
||||
['1 KB', $kb],
|
||||
['1 MB', pow($kb, 2)],
|
||||
['1 GB', pow($kb, 3)],
|
||||
|
@ -39,10 +43,13 @@ class SizeTest extends KernelTestBase {
|
|||
['1 EB', pow($kb, 6)],
|
||||
['1 ZB', pow($kb, 7)],
|
||||
['1 YB', pow($kb, 8)],
|
||||
// Rounded to 1 MB - not 1000 or 1024 kilobyte
|
||||
['1024 YB', pow($kb, 9)],
|
||||
// Rounded to 1 MB - not 1000 or 1024 kilobytes
|
||||
['1 MB', ($kb * $kb) - 1],
|
||||
['-1 MB', -(($kb * $kb) - 1)],
|
||||
// Decimal Megabytes
|
||||
['3.46 MB', 3623651],
|
||||
['3.77 GB', 4053371676],
|
||||
// Decimal Petabytes
|
||||
['59.72 PB', 67234178751368124],
|
||||
// Decimal Yottabytes
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
namespace Drupal\KernelTests\Core\Entity;
|
||||
|
||||
use Drupal\Core\Entity\EntityInterface;
|
||||
use Drupal\Core\Entity\EntityStorageException;
|
||||
use Drupal\Core\Entity\RevisionLogInterface;
|
||||
use Drupal\Core\Entity\TypedData\EntityDataDefinition;
|
||||
use Drupal\Core\Entity\TypedData\EntityDataDefinitionInterface;
|
||||
|
@ -919,4 +920,33 @@ class EntityFieldTest extends EntityKernelTestBase {
|
|||
$this->assertEqual($entity->field_test_text->processed, $target, format_string('%entity_type: Text is processed with the default filter.', ['%entity_type' => $entity_type]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests explicit entity ID assignment.
|
||||
*/
|
||||
public function testEntityIdAssignment() {
|
||||
$entity_type = 'entity_test';
|
||||
/** @var \Drupal\Core\Entity\ContentEntityStorageInterface $storage */
|
||||
$storage = $this->container->get('entity_type.manager')->getStorage($entity_type);
|
||||
|
||||
// Check that an ID can be explicitly assigned on creation.
|
||||
/** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
|
||||
$entity = $this->createTestEntity($entity_type);
|
||||
$entity_id = 3;
|
||||
$entity->set('id', $entity_id);
|
||||
$this->assertSame($entity_id, $entity->id());
|
||||
$storage->save($entity);
|
||||
$entity = $storage->loadUnchanged($entity->id());
|
||||
$this->assertTrue($entity);
|
||||
|
||||
// Check that an explicitly-assigned ID is preserved on update.
|
||||
$storage->save($entity);
|
||||
$entity = $storage->loadUnchanged($entity->id());
|
||||
$this->assertTrue($entity);
|
||||
|
||||
// Check that an ID cannot be explicitly assigned on update.
|
||||
$this->setExpectedException(EntityStorageException::class);
|
||||
$entity->set('id', $entity_id + 1);
|
||||
$storage->save($entity);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -138,8 +138,11 @@ class EntityQueryTest extends EntityKernelTestBase {
|
|||
}
|
||||
foreach (array_reverse(str_split(decbin($i))) as $key => $bit) {
|
||||
if ($bit) {
|
||||
list($field_name, $langcode, $values) = $units[$key];
|
||||
$entity->getTranslation($langcode)->{$field_name}[] = $values;
|
||||
// @todo https://www.drupal.org/project/drupal/issues/3001920 Doing
|
||||
// list($field_name, $langcode, $values) = $units[$key]; causes
|
||||
// problems in PHP 7.3. Revert to better variable names once
|
||||
// https://bugs.php.net/bug.php?id=76937 is fixed.
|
||||
$entity->getTranslation($units[$key][1])->{$units[$key][0]}[] = $units[$key][2];
|
||||
}
|
||||
}
|
||||
$entity->save();
|
||||
|
@ -1160,4 +1163,42 @@ class EntityQueryTest extends EntityKernelTestBase {
|
|||
$this->assertEquals($entity->id(), reset($result));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests entity queries with condition on the revision metadata keys.
|
||||
*/
|
||||
public function testConditionOnRevisionMetadataKeys() {
|
||||
$this->installModule('entity_test_revlog');
|
||||
$this->installEntitySchema('entity_test_revlog');
|
||||
|
||||
/** @var \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager */
|
||||
$entity_type_manager = $this->container->get('entity_type.manager');
|
||||
/** @var \Drupal\Core\Entity\ContentEntityTypeInterface $entity_type */
|
||||
$entity_type = $entity_type_manager->getDefinition('entity_test_revlog');
|
||||
/** @var \Drupal\Core\Entity\ContentEntityStorageInterface $storage */
|
||||
$storage = $entity_type_manager->getStorage('entity_test_revlog');
|
||||
|
||||
$revision_created_timestamp = time();
|
||||
$revision_created_field_name = $entity_type->getRevisionMetadataKey('revision_created');
|
||||
$entity = $storage->create([
|
||||
'type' => 'entity_test',
|
||||
$revision_created_field_name => $revision_created_timestamp,
|
||||
]);
|
||||
$entity->save();
|
||||
|
||||
// Query only the default revision.
|
||||
$result = $storage->getQuery()
|
||||
->condition($revision_created_field_name, $revision_created_timestamp)
|
||||
->execute();
|
||||
$this->assertCount(1, $result);
|
||||
$this->assertEquals($entity->id(), reset($result));
|
||||
|
||||
// Query all revisions.
|
||||
$result = $storage->getQuery()
|
||||
->condition($revision_created_field_name, $revision_created_timestamp)
|
||||
->allRevisions()
|
||||
->execute();
|
||||
$this->assertCount(1, $result);
|
||||
$this->assertEquals($entity->id(), reset($result));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\KernelTests\Core\File;
|
||||
|
||||
use Drupal\KernelTests\KernelTestBase;
|
||||
|
||||
/**
|
||||
* Tests that the phar stream wrapper works.
|
||||
*
|
||||
* @group File
|
||||
*/
|
||||
class PharWrapperTest extends KernelTestBase {
|
||||
|
||||
/**
|
||||
* Tests that only valid phar files can be used.
|
||||
*/
|
||||
public function testPharFile() {
|
||||
$base = $this->getDrupalRoot() . '/core/modules/simpletest/files';
|
||||
// Ensure that file operations via the phar:// stream wrapper work for phar
|
||||
// files with the .phar extension.
|
||||
$this->assertFalse(file_exists("phar://$base/phar-1.phar/no-such-file.php"));
|
||||
$this->assertTrue(file_exists("phar://$base/phar-1.phar/index.php"));
|
||||
$file_contents = file_get_contents("phar://$base/phar-1.phar/index.php");
|
||||
$expected_hash = 'c7e7904ea573c5ebea3ef00bb08c1f86af1a45961fbfbeb1892ff4a98fd73ad5';
|
||||
$this->assertSame($expected_hash, hash('sha256', $file_contents));
|
||||
|
||||
// Ensure that file operations via the phar:// stream wrapper throw an
|
||||
// exception for files without the .phar extension.
|
||||
$this->setExpectedException('TYPO3\PharStreamWrapper\Exception');
|
||||
file_exists("phar://$base/image-2.jpg/index.php");
|
||||
}
|
||||
|
||||
}
|
|
@ -144,4 +144,31 @@ class StreamWrapperTest extends FileTestBase {
|
|||
$this->assertFalse(file_stream_wrapper_valid_scheme(file_uri_scheme('foo://asdf')), 'Did not get a valid stream scheme from foo://asdf');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that phar stream wrapper is registered as expected.
|
||||
*
|
||||
* @see \Drupal\Core\StreamWrapper\StreamWrapperManager::register()
|
||||
*/
|
||||
public function testPharStreamWrapperRegistration() {
|
||||
if (!in_array('phar', stream_get_wrappers(), TRUE)) {
|
||||
$this->markTestSkipped('There is no phar stream wrapper registered. PHP is probably compiled without phar support.');
|
||||
}
|
||||
// Ensure that phar is not treated as a valid scheme.
|
||||
$stream_wrapper_manager = $this->container->get('stream_wrapper_manager');
|
||||
$this->assertFalse($stream_wrapper_manager->getViaScheme('phar'));
|
||||
|
||||
// Ensure that calling register again and unregister do not create errors
|
||||
// due to the PharStreamWrapperManager singleton.
|
||||
$stream_wrapper_manager->register();
|
||||
$this->assertContains('public', stream_get_wrappers());
|
||||
$this->assertContains('phar', stream_get_wrappers());
|
||||
$stream_wrapper_manager->unregister();
|
||||
$this->assertNotContains('public', stream_get_wrappers());
|
||||
// This will have reverted to the builtin phar stream wrapper.
|
||||
$this->assertContains('phar', stream_get_wrappers());
|
||||
$stream_wrapper_manager->register();
|
||||
$this->assertContains('public', stream_get_wrappers());
|
||||
$this->assertContains('phar', stream_get_wrappers());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\KernelTests\Core\Plugin;
|
||||
|
||||
use Drupal\Core\Entity\Entity\EntityViewDisplay;
|
||||
use Drupal\Core\Plugin\Context\EntityContext;
|
||||
use Drupal\KernelTests\KernelTestBase;
|
||||
|
||||
/**
|
||||
* Tests the interaction between entity context and typed data.
|
||||
*
|
||||
* @group Context
|
||||
*/
|
||||
class EntityContextTypedDataTest extends KernelTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $modules = ['entity_test'];
|
||||
|
||||
/**
|
||||
* Tests that entity contexts wrapping a config entity can be validated.
|
||||
*/
|
||||
public function testValidateConfigEntityContext() {
|
||||
$display = EntityViewDisplay::create([
|
||||
'targetEntityType' => 'entity_test',
|
||||
'bundle' => 'entity_test',
|
||||
'mode' => 'default',
|
||||
'status' => TRUE,
|
||||
]);
|
||||
$display->save();
|
||||
|
||||
$violations = EntityContext::fromEntity($display)->validate();
|
||||
$this->assertCount(0, $violations);
|
||||
}
|
||||
|
||||
}
|
|
@ -32,6 +32,14 @@ class MessageTest extends KernelTestBase {
|
|||
$this->render($messages);
|
||||
$this->assertRaw('messages messages--error');
|
||||
$this->assertRaw('messages messages--status');
|
||||
// Tests display of only one type of messages.
|
||||
\Drupal::messenger()->addError('An error occurred');
|
||||
$messages = [
|
||||
'#type' => 'status_messages',
|
||||
'#display' => 'error',
|
||||
];
|
||||
$this->render($messages);
|
||||
$this->assertRaw('messages messages--error');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Reference in a new issue