Update to Drupal 8.1.2. For more information, see https://www.drupal.org/project/drupal/releases/8.1.2
This commit is contained in:
parent
9eae24d844
commit
28556d630e
1322 changed files with 6699 additions and 2064 deletions
|
@ -75,7 +75,7 @@ trait AssertConfigTrait {
|
|||
}
|
||||
foreach ($op->closing as $closing) {
|
||||
// The UUIDs don't exist in the default config.
|
||||
if (strpos($closing, 'uuid: ') === 0) {
|
||||
if (strpos($closing, 'uuid: ') === 0) {
|
||||
continue;
|
||||
}
|
||||
throw new \Exception($config_name . ': ' . var_export($op, TRUE));
|
||||
|
|
|
@ -32,7 +32,6 @@ class SafeMarkupKernelTest extends KernelTestBase {
|
|||
*
|
||||
* @param string $uri
|
||||
* The URI of the resource.
|
||||
*
|
||||
* @param array $options
|
||||
* The options to pass to Url::fromUri().
|
||||
*
|
||||
|
|
|
@ -263,7 +263,7 @@ class ConfigCRUDTest extends KernelTestBase {
|
|||
$this->assertIdentical($config->get(), $data);
|
||||
|
||||
// Re-set each key using Config::set().
|
||||
foreach($data as $key => $value) {
|
||||
foreach ($data as $key => $value) {
|
||||
$config->set($key, $value);
|
||||
}
|
||||
$config->save();
|
||||
|
|
|
@ -473,9 +473,10 @@ class ConfigDependencyTest extends EntityKernelTestBase {
|
|||
*/
|
||||
protected function getDependentIds(array $dependents) {
|
||||
$dependent_ids = array();
|
||||
foreach($dependents as $dependent) {
|
||||
foreach ($dependents as $dependent) {
|
||||
$dependent_ids[] = $dependent->getEntityTypeId() . ':' . $dependent->id();
|
||||
}
|
||||
return $dependent_ids;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -227,4 +227,5 @@ class ConfigFileContentTest extends KernelTestBase {
|
|||
$key = 'invalid xml';
|
||||
$this->assertIdentical($config_data[$key], $config_parsed[$key]);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -116,4 +116,5 @@ class ConfigLanguageOverrideTest extends KernelTestBase {
|
|||
$this->assertTrue($override->isNew());
|
||||
$this->assertEqual($override->get('value'), NULL);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -47,4 +47,5 @@ class ConfigModuleOverridesTest extends KernelTestBase {
|
|||
|
||||
unset($GLOBALS['config_test_run_module_overrides']);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -92,4 +92,5 @@ class ConfigOverridesPriorityTest extends KernelTestBase {
|
|||
|
||||
unset($GLOBALS['config_test_run_module_overrides']);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -40,4 +40,5 @@ class DatabaseStorageTest extends ConfigStorageTestBase {
|
|||
protected function delete($name) {
|
||||
db_delete('config')->condition('name', $name)->execute();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -147,4 +147,5 @@ class AlterTest extends DatabaseTestBase {
|
|||
$this->assertEqual($record->$name_field, 'George', 'Fetched name is correct.');
|
||||
$this->assertEqual($record->$age_field, 27 * 3, 'Fetched age expression is correct.');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -27,4 +27,5 @@ class CaseSensitivityTest extends DatabaseTestBase {
|
|||
$saved_age = db_query('SELECT age FROM {test} WHERE name = :name', array(':name' => 'john'))->fetchField();
|
||||
$this->assertIdentical($saved_age, '2', 'Can retrieve after inserting.');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -143,4 +143,5 @@ abstract class DatabaseTestBase extends KernelTestBase {
|
|||
))
|
||||
->execute();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -80,4 +80,5 @@ class DeleteTruncateTest extends DatabaseTestBase {
|
|||
$num_records_after = db_query('SELECT COUNT(*) FROM {test_special_columns}')->fetchField();
|
||||
$this->assertEqual($num_records_before, $num_records_after + $num_deleted, 'Deletion adds up.');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -34,7 +34,8 @@ class InsertDefaultsTest extends DatabaseTestBase {
|
|||
db_insert('test')->execute();
|
||||
// This is only executed if no exception has been thrown.
|
||||
$this->fail('Expected exception NoFieldsException has not been thrown.');
|
||||
} catch (NoFieldsException $e) {
|
||||
}
|
||||
catch (NoFieldsException $e) {
|
||||
$this->pass('Expected exception NoFieldsException has been thrown.');
|
||||
}
|
||||
|
||||
|
@ -56,4 +57,5 @@ class InsertDefaultsTest extends DatabaseTestBase {
|
|||
$job = db_query('SELECT job FROM {test} WHERE id = :id', array(':id' => $id))->fetchField();
|
||||
$this->assertEqual($job, $schema['fields']['job']['default'], 'Default field value is set.');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -35,4 +35,5 @@ class InsertLobTest extends DatabaseTestBase {
|
|||
$r = db_query('SELECT * FROM {test_two_blobs} WHERE id = :id', array(':id' => $id))->fetchAssoc();
|
||||
$this->assertTrue($r['blob1'] === 'This is' && $r['blob2'] === 'a test', 'Can insert multiple blobs per row.');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -206,4 +206,5 @@ class InsertTest extends DatabaseTestBase {
|
|||
$saved_value = db_query('SELECT "offset" FROM {test_special_columns} WHERE id = :id', array(':id' => 2))->fetchField();
|
||||
$this->assertIdentical($saved_value, 'Offset value 2', 'Can retrieve special column name value after inserting.');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -31,7 +31,8 @@ class LargeQueryTest extends DatabaseTestBase {
|
|||
try {
|
||||
db_query('SELECT name FROM {test} WHERE name = :name', array(':name' => $long_name));
|
||||
$this->fail("An exception should be thrown for queries larger than 'max_allowed_packet'");
|
||||
} catch (DatabaseException $e) {
|
||||
}
|
||||
catch (DatabaseException $e) {
|
||||
// Close and re-open the connection. Otherwise we will run into error
|
||||
// 2006 "MySQL server had gone away" afterwards.
|
||||
Database::closeConnection();
|
||||
|
|
|
@ -125,4 +125,5 @@ class LoggingTest extends DatabaseTestBase {
|
|||
$this->assertEqual(count($queries1), 1, 'Correct number of queries recorded for first connection.');
|
||||
$this->assertEqual(count($queries2), 1, 'Correct number of queries recorded for second connection.');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -229,4 +229,5 @@ class MergeTest extends DatabaseTestBase {
|
|||
}
|
||||
$this->fail('No InvalidMergeQueryException thrown');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -35,4 +35,5 @@ class NextIdTest extends KernelTestBase {
|
|||
$result = db_next_id(1000);
|
||||
$this->assertEqual($result, 1001, 'Sequence provides a larger number than the existing ID.');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -29,4 +29,5 @@ class RangeQueryTest extends DatabaseTestBase {
|
|||
$raw_rows = array_slice($raw_rows, 1, 3);
|
||||
$this->assertEqual($range_rows, $raw_rows);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -56,4 +56,5 @@ class RegressionTest extends DatabaseTestBase {
|
|||
$this->assertIdentical(TRUE, db_index_exists('test', 'ages'), 'Returns true for existent index.');
|
||||
$this->assertIdentical(FALSE, db_index_exists('test', 'nosuchindex'), 'Returns false for nonexistent index.');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -230,7 +230,8 @@ class SchemaTest extends KernelTestBase {
|
|||
try {
|
||||
db_create_table('test_timestamp', $table_specification);
|
||||
}
|
||||
catch (\Exception $e) {}
|
||||
catch (\Exception $e) {
|
||||
}
|
||||
$this->assertTrue(db_table_exists('test_timestamp'), 'Table with database specific datatype was created.');
|
||||
}
|
||||
|
||||
|
|
|
@ -33,4 +33,5 @@ class SelectCloneTest extends DatabaseTestBase {
|
|||
$this->assertEqual(3, $clone_result, 'The cloned query returns the expected number of rows');
|
||||
$this->assertEqual(2, $query_result, 'The query returns the expected number of rows');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -81,4 +81,5 @@ class SelectOrderedTest extends DatabaseTestBase {
|
|||
|
||||
$this->assertEqual($num_records, 4, 'Returned the correct number of rows.');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -175,4 +175,5 @@ class SelectSubqueryTest extends DatabaseTestBase {
|
|||
$people = $query->execute()->fetchCol();
|
||||
$this->assertEqual(count($people), 3, 'NOT EXISTS query returned the correct results.');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,4 +21,5 @@ class SerializeQueryTest extends DatabaseTestBase {
|
|||
$results = $query->execute()->fetchCol();
|
||||
$this->assertEqual($results[0], 28, 'Query properly executed after unserialization.');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -124,4 +124,5 @@ class TaggingTest extends DatabaseTestBase {
|
|||
$return = $query->getMetaData('nothere');
|
||||
$this->assertNull($return, 'Non-existent key returned NULL.');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -48,4 +48,5 @@ class UpdateLobTest extends DatabaseTestBase {
|
|||
$r = db_query('SELECT * FROM {test_two_blobs} WHERE id = :id', array(':id' => $id))->fetchAssoc();
|
||||
$this->assertTrue($r['blob1'] === 'and so' && $r['blob2'] === 'is this', 'Can update multiple blobs per row.');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -154,4 +154,5 @@ class UpdateTest extends DatabaseTestBase {
|
|||
$saved_value = db_query('SELECT "offset" FROM {test_special_columns} WHERE id = :id', array(':id' => 1))->fetchField();
|
||||
$this->assertIdentical($saved_value, 'New offset value', 'Updated special column name value successfully.');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -68,4 +68,5 @@ class BundleConstraintValidatorTest extends KernelTestBase {
|
|||
$this->assertEqual($violation->getRoot(), $typed_data, 'Violation root is correct.');
|
||||
$this->assertEqual($violation->getInvalidValue(), $page_node, 'The invalid value is set correctly in the violation.');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ class ConfigEntityQueryTest extends KernelTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
static $modules = array('config_test');
|
||||
public static $modules = array('config_test');
|
||||
|
||||
/**
|
||||
* Stores the search results for alter comparison.
|
||||
|
|
|
@ -310,6 +310,31 @@ class EntityAutocompleteElementFormTest extends EntityKernelTestBase implements
|
|||
$this->assertEqual($form['tags_access']['#value'], $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests ID input is handled correctly.
|
||||
*
|
||||
* E.g. This can happen with GET form parameters.
|
||||
*/
|
||||
public function testEntityAutocompleteIdInput() {
|
||||
/** @var \Drupal\Core\Form\FormBuilderInterface $form_builder */
|
||||
$form_builder = $this->container->get('form_builder');
|
||||
//$form = $form_builder->getForm($this);
|
||||
$form_state = (new FormState())
|
||||
->setMethod('GET')
|
||||
->setValues([
|
||||
'single' => [['target_id' => $this->referencedEntities[0]->id()]],
|
||||
'single_no_validate' => [['target_id' => $this->referencedEntities[0]->id()]],
|
||||
]);
|
||||
|
||||
$form_builder->submitForm($this, $form_state);
|
||||
|
||||
$form = $form_state->getCompleteForm();
|
||||
|
||||
$expected_label = $this->getAutocompleteInput($this->referencedEntities[0]);
|
||||
$this->assertSame($expected_label, $form['single']['#value']);
|
||||
$this->assertSame($expected_label, $form['single_no_validate']['#value']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an entity label in the format needed by the EntityAutocomplete
|
||||
* element.
|
||||
|
|
|
@ -18,7 +18,7 @@ use Drupal\user\Entity\User;
|
|||
*
|
||||
* @group Entity
|
||||
*/
|
||||
class EntityAccessControlHandlerTest extends EntityLanguageTestBase {
|
||||
class EntityAccessControlHandlerTest extends EntityLanguageTestBase {
|
||||
|
||||
/**
|
||||
* Asserts entity access correctly grants or denies access.
|
||||
|
@ -222,4 +222,5 @@ class EntityAccessControlHandlerTest extends EntityLanguageTestBase {
|
|||
$this->assertEqual($state->get('entity_test_entity_access'), TRUE);
|
||||
$this->assertEqual($state->get('entity_test_entity_test_access'), TRUE);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -170,4 +170,5 @@ class EntityApiTest extends EntityKernelTestBase {
|
|||
$this->assertNotEqual($e->getCode(), 2, 'Entity predelete EntityStorageException thrown.');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ namespace Drupal\KernelTests\Core\Entity;
|
|||
*
|
||||
* @group Entity
|
||||
*/
|
||||
class EntityBundleFieldTest extends EntityKernelTestBase {
|
||||
class EntityBundleFieldTest extends EntityKernelTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
|
|
|
@ -556,4 +556,5 @@ class EntityCrudHookTest extends EntityKernelTestBase {
|
|||
$this->assertFalse(empty($ids), 'Transactions not supported, and entity found in database.');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -368,7 +368,8 @@ class EntityDefinitionUpdateTest extends EntityKernelTestBase {
|
|||
->fields($values)
|
||||
->execute();
|
||||
$this->pass($message);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
// Keep throwing it.
|
||||
throw $e;
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ use Drupal\Component\Utility\SafeMarkup;
|
|||
*
|
||||
* @group Entity
|
||||
*/
|
||||
class EntityFieldDefaultValueTest extends EntityKernelTestBase {
|
||||
class EntityFieldDefaultValueTest extends EntityKernelTestBase {
|
||||
|
||||
/**
|
||||
* The UUID object to be used for generating UUIDs.
|
||||
|
|
|
@ -23,7 +23,7 @@ use Drupal\node\Entity\NodeType;
|
|||
*
|
||||
* @group Entity
|
||||
*/
|
||||
class EntityFieldTest extends EntityKernelTestBase {
|
||||
class EntityFieldTest extends EntityKernelTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
|
@ -410,9 +410,9 @@ class EntityFieldTest extends EntityKernelTestBase {
|
|||
// Test getting metadata upfront. The entity types used for this test have
|
||||
// a default bundle that is the same as the entity type.
|
||||
$definitions = \Drupal::entityManager()->getFieldDefinitions($entity_type, $entity_type);
|
||||
$this->assertEqual($definitions['name']->getType(), 'string', $entity_type .': Name field found.');
|
||||
$this->assertEqual($definitions['user_id']->getType(), 'entity_reference', $entity_type .': User field found.');
|
||||
$this->assertEqual($definitions['field_test_text']->getType(), 'text', $entity_type .': Test-text-field field found.');
|
||||
$this->assertEqual($definitions['name']->getType(), 'string', $entity_type . ': Name field found.');
|
||||
$this->assertEqual($definitions['user_id']->getType(), 'entity_reference', $entity_type . ': User field found.');
|
||||
$this->assertEqual($definitions['field_test_text']->getType(), 'text', $entity_type . ': Test-text-field field found.');
|
||||
|
||||
// Test deriving further metadata.
|
||||
$this->assertTrue($definitions['name'] instanceof FieldDefinitionInterface);
|
||||
|
@ -450,21 +450,21 @@ class EntityFieldTest extends EntityKernelTestBase {
|
|||
->create();
|
||||
|
||||
$definitions = $entity->getFieldDefinitions();
|
||||
$this->assertEqual($definitions['name']->getType(), 'string', $entity_type .': Name field found.');
|
||||
$this->assertEqual($definitions['user_id']->getType(), 'entity_reference', $entity_type .': User field found.');
|
||||
$this->assertEqual($definitions['field_test_text']->getType(), 'text', $entity_type .': Test-text-field field found.');
|
||||
$this->assertEqual($definitions['name']->getType(), 'string', $entity_type . ': Name field found.');
|
||||
$this->assertEqual($definitions['user_id']->getType(), 'entity_reference', $entity_type . ': User field found.');
|
||||
$this->assertEqual($definitions['field_test_text']->getType(), 'text', $entity_type . ': Test-text-field field found.');
|
||||
|
||||
$name_properties = $entity->name->getFieldDefinition()->getPropertyDefinitions();
|
||||
$this->assertEqual($name_properties['value']->getDataType(), 'string', $entity_type .': String value property of the name found.');
|
||||
$this->assertEqual($name_properties['value']->getDataType(), 'string', $entity_type . ': String value property of the name found.');
|
||||
|
||||
$userref_properties = $entity->user_id->getFieldDefinition()->getPropertyDefinitions();
|
||||
$this->assertEqual($userref_properties['target_id']->getDataType(), 'integer', $entity_type .': Entity id property of the user found.');
|
||||
$this->assertEqual($userref_properties['entity']->getDataType(), 'entity_reference', $entity_type .': Entity reference property of the user found.');
|
||||
$this->assertEqual($userref_properties['target_id']->getDataType(), 'integer', $entity_type . ': Entity id property of the user found.');
|
||||
$this->assertEqual($userref_properties['entity']->getDataType(), 'entity_reference', $entity_type . ': Entity reference property of the user found.');
|
||||
|
||||
$textfield_properties = $entity->field_test_text->getFieldDefinition()->getFieldStorageDefinition()->getPropertyDefinitions();
|
||||
$this->assertEqual($textfield_properties['value']->getDataType(), 'string', $entity_type .': String value property of the test-text field found.');
|
||||
$this->assertEqual($textfield_properties['format']->getDataType(), 'filter_format', $entity_type .': String format field of the test-text field found.');
|
||||
$this->assertEqual($textfield_properties['processed']->getDataType(), 'string', $entity_type .': String processed property of the test-text field found.');
|
||||
$this->assertEqual($textfield_properties['value']->getDataType(), 'string', $entity_type . ': String value property of the test-text field found.');
|
||||
$this->assertEqual($textfield_properties['format']->getDataType(), 'filter_format', $entity_type . ': String format field of the test-text field found.');
|
||||
$this->assertEqual($textfield_properties['processed']->getDataType(), 'string', $entity_type . ': String processed property of the test-text field found.');
|
||||
|
||||
// Make sure provided contextual information is right.
|
||||
$entity_adapter = $entity->getTypedData();
|
||||
|
|
|
@ -189,8 +189,7 @@ abstract class EntityKernelTestBase extends KernelTestBase {
|
|||
// Drupal supported databases and is known to work for other databases
|
||||
// like SQL Server 2014 and Oracle 10 too.
|
||||
$id = $string ? $this->randomMachineName() : mt_rand(1, 0x7FFFFFFF);
|
||||
}
|
||||
while (isset($this->generatedIds[$id]));
|
||||
} while (isset($this->generatedIds[$id]));
|
||||
$this->generatedIds[$id] = $id;
|
||||
return $id;
|
||||
}
|
||||
|
|
|
@ -581,4 +581,5 @@ class EntityQueryAggregateTest extends EntityKernelTestBase {
|
|||
protected function assertSortedResults($expected) {
|
||||
return $this->assertResults($expected, TRUE);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -169,4 +169,5 @@ class EntityQueryRelationshipTest extends EntityKernelTestBase {
|
|||
$this->assertEqual($this->queryResults[$id], $id);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -862,4 +862,5 @@ class EntityQueryTest extends EntityKernelTestBase {
|
|||
$this->pass('SQL Injection attempt in Entity Query condition in operator should result in an exception.');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -9,7 +9,7 @@ use Drupal\Component\Utility\SafeMarkup;
|
|||
*
|
||||
* @group system
|
||||
*/
|
||||
class EntitySchemaTest extends EntityKernelTestBase {
|
||||
class EntitySchemaTest extends EntityKernelTestBase {
|
||||
|
||||
/**
|
||||
* The database connection used.
|
||||
|
|
|
@ -57,4 +57,5 @@ class EntityTypeConstraintValidatorTest extends EntityKernelTestBase {
|
|||
$this->assertEqual($violation->getRoot(), $typed_data, 'Violation root is correct.');
|
||||
$this->assertEqual($violation->getInvalidValue(), $account, 'The invalid value is set correctly in the violation.');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -76,7 +76,7 @@ class EntityUUIDTest extends EntityKernelTestBase {
|
|||
// Creating a duplicate needs to result in a new UUID.
|
||||
$entity_duplicate = $entity->createDuplicate();
|
||||
foreach ($entity->getFields() as $property => $value) {
|
||||
switch($property) {
|
||||
switch ($property) {
|
||||
case 'uuid':
|
||||
$this->assertNotNull($entity_duplicate->uuid());
|
||||
$this->assertNotNull($entity->uuid());
|
||||
|
@ -100,4 +100,5 @@ class EntityUUIDTest extends EntityKernelTestBase {
|
|||
$entity_duplicate->save();
|
||||
$this->assertNotEqual($entity->id(), $entity_duplicate->id());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -75,4 +75,5 @@ class FieldAccessTest extends KernelTestBase {
|
|||
$this->assertTrue($entity->field_test_text->access('view', $account), 'Access to the field was granted.');
|
||||
$this->assertEqual(AccessResult::allowed(), $entity->field_test_text->access('view', $account, TRUE), 'Access to the field was granted.');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -113,7 +113,7 @@ class FieldModuleUninstallValidatorTest extends EntityKernelTestBase {
|
|||
$this->enableModules([$module_name]);
|
||||
}
|
||||
$this->entityDefinitionUpdateManager->applyUpdates();
|
||||
$this->assertTrue($this->getModuleHandler()->moduleExists($module_name), $module_name .' module is enabled.');
|
||||
$this->assertTrue($this->getModuleHandler()->moduleExists($module_name), $module_name . ' module is enabled.');
|
||||
$this->getModuleInstaller()->uninstall([$module_name]);
|
||||
$this->entityDefinitionUpdateManager->applyUpdates();
|
||||
$this->assertFalse($this->getModuleHandler()->moduleExists($module_name), $module_name . ' module is disabled.');
|
||||
|
|
|
@ -8,9 +8,11 @@
|
|||
namespace Drupal\KernelTests\Core\Theme;
|
||||
|
||||
use Drupal\Component\Utility\Html;
|
||||
use Drupal\Core\GeneratedLink;
|
||||
use Drupal\Core\Link;
|
||||
use Drupal\Core\Render\RenderContext;
|
||||
use Drupal\Core\Render\Markup;
|
||||
use Drupal\Core\Url;
|
||||
use Drupal\KernelTests\KernelTestBase;
|
||||
|
||||
/**
|
||||
|
@ -87,6 +89,50 @@ class ThemeRenderAndAutoescapeTest extends KernelTestBase {
|
|||
theme_render_and_autoescape(new NonPrintable());
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure cache metadata is bubbled when using theme_render_and_autoescape().
|
||||
*/
|
||||
public function testBubblingMetadata() {
|
||||
$link = new GeneratedLink();
|
||||
$link->setGeneratedLink('<a href="http://example.com"></a>');
|
||||
$link->addCacheTags(['foo']);
|
||||
$link->addAttachments(['library' => ['system/base']]);
|
||||
|
||||
$context = new RenderContext();
|
||||
// Use a closure here since we need to render with a render context.
|
||||
$theme_render_and_autoescape = function () use ($link) {
|
||||
return theme_render_and_autoescape($link);
|
||||
};
|
||||
/** @var \Drupal\Core\Render\RendererInterface $renderer */
|
||||
$renderer = \Drupal::service('renderer');
|
||||
$output = $renderer->executeInRenderContext($context, $theme_render_and_autoescape);
|
||||
$this->assertEquals('<a href="http://example.com"></a>', $output);
|
||||
/** @var \Drupal\Core\Render\BubbleableMetadata $metadata */
|
||||
$metadata = $context->pop();
|
||||
$this->assertEquals(['foo'], $metadata->getCacheTags());
|
||||
$this->assertEquals(['library' => ['system/base']], $metadata->getAttachments());
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensure cache metadata is bubbled when using theme_render_and_autoescape().
|
||||
*/
|
||||
public function testBubblingMetadataWithRenderable() {
|
||||
$link = new Link('', Url::fromRoute('<current>'));
|
||||
|
||||
$context = new RenderContext();
|
||||
// Use a closure here since we need to render with a render context.
|
||||
$theme_render_and_autoescape = function () use ($link) {
|
||||
return theme_render_and_autoescape($link);
|
||||
};
|
||||
/** @var \Drupal\Core\Render\RendererInterface $renderer */
|
||||
$renderer = \Drupal::service('renderer');
|
||||
$output = $renderer->executeInRenderContext($context, $theme_render_and_autoescape);
|
||||
$this->assertEquals('<a href="/' . urlencode('<none>') . '"></a>', $output);
|
||||
/** @var \Drupal\Core\Render\BubbleableMetadata $metadata */
|
||||
$metadata = $context->pop();
|
||||
$this->assertEquals(['route'], $metadata->getCacheContexts());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
class NonPrintable { }
|
||||
|
|
|
@ -850,7 +850,7 @@ abstract class KernelTestBase extends \PHPUnit_Framework_TestCase implements Ser
|
|||
* To install test modules outside of the testing environment, add
|
||||
* @code
|
||||
* $settings['extension_discovery_scan_tests'] = TRUE;
|
||||
* @encode
|
||||
* @endcode
|
||||
* to your settings.php.
|
||||
*
|
||||
* @param string[] $modules
|
||||
|
|
|
@ -1,21 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\simpletest\Tests;
|
||||
|
||||
use Drupal\KernelTests\KernelTestBase;
|
||||
|
||||
/**
|
||||
* This test should not load since it requires a module that is not found.
|
||||
*
|
||||
* @group simpletest
|
||||
* @dependencies simpletest_missing_module
|
||||
*/
|
||||
class MissingDependentModuleUnitTest extends KernelTestBase {
|
||||
|
||||
/**
|
||||
* Ensure that this test will not be loaded despite its dependency.
|
||||
*/
|
||||
function testFail() {
|
||||
$this->fail('Running test with missing required module.');
|
||||
}
|
||||
}
|
Reference in a new issue