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
|
@ -3,7 +3,6 @@
|
|||
namespace Drupal\FunctionalJavascriptTests;
|
||||
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
use Symfony\Component\CssSelector\CssSelector;
|
||||
use Zumba\Mink\Driver\PhantomJSDriver;
|
||||
|
||||
/**
|
||||
|
@ -46,7 +45,7 @@ abstract class JavascriptTestBase extends BrowserTestBase {
|
|||
* \Behat\Mink\Element\NodeElement::isVisible() instead.
|
||||
*/
|
||||
protected function assertElementVisible($css_selector, $message = '') {
|
||||
$this->assertTrue($this->getSession()->getDriver()->isVisible(CssSelector::toXPath($css_selector)), $message);
|
||||
$this->assertTrue($this->getSession()->getDriver()->isVisible($this->cssSelectToXpath($css_selector)), $message);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -61,7 +60,7 @@ abstract class JavascriptTestBase extends BrowserTestBase {
|
|||
* \Behat\Mink\Element\NodeElement::isVisible() instead.
|
||||
*/
|
||||
protected function assertElementNotVisible($css_selector, $message = '') {
|
||||
$this->assertFalse($this->getSession()->getDriver()->isVisible(CssSelector::toXPath($css_selector)), $message);
|
||||
$this->assertFalse($this->getSession()->getDriver()->isVisible($this->cssSelectToXpath($css_selector)), $message);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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.');
|
||||
}
|
||||
}
|
|
@ -10,7 +10,6 @@ use Drupal\Component\Utility\Html;
|
|||
use Drupal\Component\Utility\SafeMarkup;
|
||||
use Drupal\Component\Utility\UrlHelper;
|
||||
use Drupal\Core\Cache\Cache;
|
||||
use Drupal\Core\Database\ConnectionNotDefinedException;
|
||||
use Drupal\Core\Database\Database;
|
||||
use Drupal\Core\DrupalKernel;
|
||||
use Drupal\Core\Session\AccountInterface;
|
||||
|
@ -20,10 +19,11 @@ use Drupal\Core\Site\Settings;
|
|||
use Drupal\Core\StreamWrapper\StreamWrapperInterface;
|
||||
use Drupal\Core\Test\TestRunnerKernel;
|
||||
use Drupal\Core\Url;
|
||||
use Drupal\Core\Test\TestDatabase;
|
||||
use Drupal\user\Entity\Role;
|
||||
use Drupal\user\Entity\User;
|
||||
use Drupal\user\UserInterface;
|
||||
use Symfony\Component\CssSelector\CssSelector;
|
||||
use Symfony\Component\CssSelector\CssSelectorConverter;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
|
@ -549,7 +549,7 @@ abstract class BrowserTestBase extends \PHPUnit_Framework_TestCase {
|
|||
/**
|
||||
* Retrieves a Drupal path or an absolute path.
|
||||
*
|
||||
* @param string $path
|
||||
* @param string|\Drupal\Core\Url $path
|
||||
* Drupal path or URL to load into Mink controlled browser.
|
||||
* @param array $options
|
||||
* (optional) Options to be forwarded to the url generator.
|
||||
|
@ -560,9 +560,15 @@ abstract class BrowserTestBase extends \PHPUnit_Framework_TestCase {
|
|||
protected function drupalGet($path, array $options = array()) {
|
||||
$options['absolute'] = TRUE;
|
||||
|
||||
if ($path instanceof Url) {
|
||||
$url_options = $path->getOptions();
|
||||
$options = $url_options + $options;
|
||||
$path->setOptions($options);
|
||||
$url = $path->setAbsolute()->toString();
|
||||
}
|
||||
// The URL generator service is not necessarily available yet; e.g., in
|
||||
// interactive installer tests.
|
||||
if ($this->container->has('url_generator')) {
|
||||
elseif ($this->container->has('url_generator')) {
|
||||
if (UrlHelper::isExternal($path)) {
|
||||
$url = Url::fromUri($path, $options)->toString();
|
||||
}
|
||||
|
@ -1244,26 +1250,7 @@ abstract class BrowserTestBase extends \PHPUnit_Framework_TestCase {
|
|||
* The database connection to use for inserting assertions.
|
||||
*/
|
||||
public static function getDatabaseConnection() {
|
||||
// Check whether there is a test runner connection.
|
||||
// @see run-tests.sh
|
||||
try {
|
||||
$connection = Database::getConnection('default', 'test-runner');
|
||||
}
|
||||
catch (ConnectionNotDefinedException $e) {
|
||||
// Check whether there is a backup of the original default connection.
|
||||
// @see BrowserTestBase::prepareEnvironment()
|
||||
try {
|
||||
$connection = Database::getConnection('default', 'simpletest_original_default');
|
||||
}
|
||||
catch (ConnectionNotDefinedException $e) {
|
||||
// If BrowserTestBase::prepareEnvironment() or
|
||||
// BrowserTestBase::restoreEnvironment() failed, the test-specific
|
||||
// database connection does not exist yet/anymore, so fall back to the
|
||||
// default of the (UI) test runner.
|
||||
$connection = Database::getConnection('default', 'default');
|
||||
}
|
||||
}
|
||||
return $connection;
|
||||
return TestDatabase::getConnection();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1441,7 +1428,7 @@ abstract class BrowserTestBase extends \PHPUnit_Framework_TestCase {
|
|||
* Optional message to show alongside the assertion.
|
||||
*/
|
||||
protected function assertElementPresent($css_selector, $message = '') {
|
||||
$this->assertNotEmpty($this->getSession()->getDriver()->find(CssSelector::toXPath($css_selector)), $message);
|
||||
$this->assertNotEmpty($this->getSession()->getDriver()->find($this->cssSelectToXpath($css_selector)), $message);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1453,7 +1440,7 @@ abstract class BrowserTestBase extends \PHPUnit_Framework_TestCase {
|
|||
* Optional message to show alongside the assertion.
|
||||
*/
|
||||
protected function assertElementNotPresent($css_selector, $message = '') {
|
||||
$this->assertEmpty($this->getSession()->getDriver()->find(CssSelector::toXPath($css_selector)), $message);
|
||||
$this->assertEmpty($this->getSession()->getDriver()->find($this->cssSelectToXpath($css_selector)), $message);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1463,7 +1450,7 @@ abstract class BrowserTestBase extends \PHPUnit_Framework_TestCase {
|
|||
* The CSS selector identifying the element to click.
|
||||
*/
|
||||
protected function click($css_selector) {
|
||||
$this->getSession()->getDriver()->click(CssSelector::toXPath($css_selector));
|
||||
$this->getSession()->getDriver()->click($this->cssSelectToXpath($css_selector));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1523,4 +1510,23 @@ abstract class BrowserTestBase extends \PHPUnit_Framework_TestCase {
|
|||
return '<hr />Headers: <pre>' . Html::escape(var_export($headers, TRUE)) . '</pre>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Translates a CSS expression to its XPath equivalent.
|
||||
*
|
||||
* The search is relative to the root element (HTML tag normally) of the page.
|
||||
*
|
||||
* @param string $selector
|
||||
* CSS selector to use in the search.
|
||||
* @param bool $html
|
||||
* (optional) Enables HTML support. Disable it for XML documents.
|
||||
* @param string $prefix
|
||||
* (optional) The prefix for the XPath expression.
|
||||
*
|
||||
* @return string
|
||||
* The equivalent XPath of a CSS expression.
|
||||
*/
|
||||
protected function cssSelectToXpath($selector, $html = TRUE, $prefix = 'descendant-or-self::') {
|
||||
return (new CssSelectorConverter($html))->toXPath($selector, $prefix);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -116,4 +116,5 @@ class ZfExtensionManagerSfContainerTest extends UnitTestCase {
|
|||
),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -55,6 +55,42 @@ class DateTimePlusTest extends UnitTestCase {
|
|||
$this->assertEquals($expected, $value, sprintf("Test new DateTimePlus(%s, %s): should be %s, found %s.", $input, $timezone, $expected, $value));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test date diffs.
|
||||
*
|
||||
* @param mixed $input1
|
||||
* A DateTimePlus object.
|
||||
* @param mixed $input2
|
||||
* Date argument for DateTimePlus::diff method.
|
||||
* @param bool $absolute
|
||||
* Absolute flag for DateTimePlus::diff method.
|
||||
* @param \DateInterval $expected
|
||||
* The expected result of the DateTimePlus::diff operation.
|
||||
*
|
||||
* @dataProvider providerTestDateDiff
|
||||
*/
|
||||
public function testDateDiff($input1, $input2, $absolute, \DateInterval $expected) {
|
||||
$interval = $input1->diff($input2, $absolute);
|
||||
$this->assertEquals($interval, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test date diff exception caused by invalid input.
|
||||
*
|
||||
* @param mixed $input1
|
||||
* A DateTimePlus object.
|
||||
* @param mixed $input2
|
||||
* Date argument for DateTimePlus::diff method.
|
||||
* @param bool $absolute
|
||||
* Absolute flag for DateTimePlus::diff method.
|
||||
*
|
||||
* @dataProvider providerTestInvalidDateDiff
|
||||
*/
|
||||
public function testInvalidDateDiff($input1, $input2, $absolute) {
|
||||
$this->setExpectedException(\BadMethodCallException::class, 'Method Drupal\Component\Datetime\DateTimePlus::diff expects parameter 1 to be a \DateTime or \Drupal\Component\Datetime\DateTimePlus object');
|
||||
$interval = $input1->diff($input2, $absolute);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test creating dates from invalid array input.
|
||||
*
|
||||
|
@ -250,7 +286,7 @@ class DateTimePlusTest extends UnitTestCase {
|
|||
* An array of arrays, each containing the input parameters for
|
||||
* DateTimePlusTest::testDates().
|
||||
*
|
||||
* @see DateTimePlusTest::testDates().
|
||||
* @see DateTimePlusTest::testDates()
|
||||
*/
|
||||
public function providerTestDates() {
|
||||
return array(
|
||||
|
@ -277,7 +313,7 @@ class DateTimePlusTest extends UnitTestCase {
|
|||
* An array of arrays, each containing the input parameters for
|
||||
* DateTimePlusTest::testDates().
|
||||
*
|
||||
* @see DateTimePlusTest::testDates().
|
||||
* @see DateTimePlusTest::testDates()
|
||||
*/
|
||||
public function providerTestDateArrays() {
|
||||
return array(
|
||||
|
@ -528,4 +564,106 @@ class DateTimePlusTest extends UnitTestCase {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides data for date tests.
|
||||
*
|
||||
* @return array
|
||||
* An array of arrays, each containing the input parameters for
|
||||
* DateTimePlusTest::testDateDiff().
|
||||
*
|
||||
* @see DateTimePlusTest::testDateDiff()
|
||||
*/
|
||||
public function providerTestDateDiff() {
|
||||
|
||||
$empty_interval = new \DateInterval('PT0S');
|
||||
|
||||
$positive_19_hours = new \DateInterval('PT19H');
|
||||
|
||||
$positive_18_hours = new \DateInterval('PT18H');
|
||||
|
||||
$positive_1_hour = new \DateInterval('PT1H');
|
||||
|
||||
$negative_1_hour = new \DateInterval('PT1H');
|
||||
$negative_1_hour->invert = 1;
|
||||
|
||||
return array(
|
||||
// There should be a 19 hour time interval between
|
||||
// new years in Sydney and new years in LA in year 2000.
|
||||
array(
|
||||
'input2' => DateTimePlus::createFromFormat('Y-m-d H:i:s', '2000-01-01 00:00:00', new \DateTimeZone('Australia/Sydney')),
|
||||
'input1' => DateTimePlus::createFromFormat('Y-m-d H:i:s', '2000-01-01 00:00:00', new \DateTimeZone('America/Los_Angeles')),
|
||||
'absolute' => FALSE,
|
||||
'expected' => $positive_19_hours,
|
||||
),
|
||||
// In 1970 Sydney did not observe daylight savings time
|
||||
// So there is only a 18 hour time interval.
|
||||
array(
|
||||
'input2' => DateTimePlus::createFromFormat('Y-m-d H:i:s', '1970-01-01 00:00:00', new \DateTimeZone('Australia/Sydney')),
|
||||
'input1' => DateTimePlus::createFromFormat('Y-m-d H:i:s', '1970-01-01 00:00:00', new \DateTimeZone('America/Los_Angeles')),
|
||||
'absolute' => FALSE,
|
||||
'expected' => $positive_18_hours,
|
||||
),
|
||||
array(
|
||||
'input1' => DateTimePlus::createFromFormat('U', 3600, new \DateTimeZone('America/Los_Angeles')),
|
||||
'input2' => DateTimePlus::createFromFormat('U', 0, new \DateTimeZone('UTC')),
|
||||
'absolute' => FALSE,
|
||||
'expected' => $negative_1_hour,
|
||||
),
|
||||
array(
|
||||
'input1' => DateTimePlus::createFromFormat('U', 3600),
|
||||
'input2' => DateTimePlus::createFromFormat('U', 0),
|
||||
'absolute' => FALSE,
|
||||
'expected' => $negative_1_hour,
|
||||
),
|
||||
array(
|
||||
'input1' => DateTimePlus::createFromFormat('U', 3600),
|
||||
'input2' => \DateTime::createFromFormat('U', 0),
|
||||
'absolute' => FALSE,
|
||||
'expected' => $negative_1_hour,
|
||||
),
|
||||
array(
|
||||
'input1' => DateTimePlus::createFromFormat('U', 3600),
|
||||
'input2' => DateTimePlus::createFromFormat('U', 0),
|
||||
'absolute' => TRUE,
|
||||
'expected' => $positive_1_hour,
|
||||
),
|
||||
array(
|
||||
'input1' => DateTimePlus::createFromFormat('U', 3600),
|
||||
'input2' => \DateTime::createFromFormat('U', 0),
|
||||
'absolute' => TRUE,
|
||||
'expected' => $positive_1_hour,
|
||||
),
|
||||
array(
|
||||
'input1' => DateTimePlus::createFromFormat('U', 0),
|
||||
'input2' => DateTimePlus::createFromFormat('U', 0),
|
||||
'absolute' => FALSE,
|
||||
'expected' => $empty_interval,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides data for date tests.
|
||||
*
|
||||
* @return array
|
||||
* An array of arrays, each containing the input parameters for
|
||||
* DateTimePlusTest::testInvalidDateDiff().
|
||||
*
|
||||
* @see DateTimePlusTest::testInvalidDateDiff()
|
||||
*/
|
||||
public function providerTestInvalidDateDiff() {
|
||||
return array(
|
||||
array(
|
||||
'input1' => DateTimePlus::createFromFormat('U', 3600),
|
||||
'input2' => '1970-01-01 00:00:00',
|
||||
'absolute' => FALSE,
|
||||
),
|
||||
array(
|
||||
'input1' => DateTimePlus::createFromFormat('U', 3600),
|
||||
'input2' => NULL,
|
||||
'absolute' => FALSE,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -442,7 +442,7 @@ class ContainerTest extends \PHPUnit_Framework_TestCase {
|
|||
public function testGetForInstantiationWithVariousArgumentLengths() {
|
||||
$args = array();
|
||||
for ($i = 0; $i < 12; $i++) {
|
||||
$instantiation_service = $this->container->get('service_test_instantiation_'. $i);
|
||||
$instantiation_service = $this->container->get('service_test_instantiation_' . $i);
|
||||
$this->assertEquals($args, $instantiation_service->getArguments());
|
||||
$args[] = 'arg_' . $i;
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
<?php
|
||||
// @codingStandardsIgnoreFile
|
||||
|
||||
namespace Drupal\Tests\Component\EventDispatcher;
|
||||
|
||||
|
|
|
@ -149,6 +149,7 @@ class StubReflectionFactory extends ReflectionFactory {
|
|||
// Return the class name from the plugin definition.
|
||||
return $plugin_definition[$plugin_id]['class'];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -184,4 +184,5 @@ class PhpTransliterationTest extends UnitTestCase {
|
|||
$transliterated = $transliteration->transliterate(chr(0xC2) . chr(0x82), '../index');
|
||||
$this->assertSame($transliterated, 'safe');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -199,6 +199,7 @@ class ArgumentsResolverTest extends UnitTestCase {
|
|||
class TestClass {
|
||||
public function access($foo) {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -320,4 +320,5 @@ class HtmlTest extends UnitTestCase {
|
|||
$result = Html::serialize($document);
|
||||
$this->assertSame('', $result);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -163,4 +163,5 @@ class RandomTest extends UnitTestCase {
|
|||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -229,4 +229,5 @@ class SafeMarkupTestString {
|
|||
*/
|
||||
class SafeMarkupTestMarkup implements MarkupInterface {
|
||||
use MarkupTrait;
|
||||
|
||||
}
|
||||
|
|
|
@ -370,7 +370,7 @@ class UrlHelperTest extends UnitTestCase {
|
|||
array(json_decode('"\u00AD"') . "//www.example.com", TRUE),
|
||||
array(json_decode('"\u200E"') . "//www.example.com", TRUE),
|
||||
array(json_decode('"\uE0020"') . "//www.example.com", TRUE),
|
||||
array(json_decode('"\uE000"') . "//www.example.com", TRUE),
|
||||
array(json_decode('"\uE000"') . "//www.example.com", TRUE),
|
||||
// Backslashes should be normalized to forward.
|
||||
array('\\\\example.com', TRUE),
|
||||
// Local URLs.
|
||||
|
@ -584,4 +584,5 @@ class UrlHelperTest extends UnitTestCase {
|
|||
array('http://', 'http://example.com/foo'),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -93,4 +93,5 @@ class UuidTest extends UnitTestCase {
|
|||
array('0ab26e6b-f074-4e44-9daf-1205fa0e9761f', FALSE, 'Invalid length was validated'),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -52,6 +52,7 @@ class ComposerIntegrationTest extends UnitTestCase {
|
|||
$this->root . '/core/lib/Drupal/Component/Discovery',
|
||||
$this->root . '/core/lib/Drupal/Component/EventDispatcher',
|
||||
$this->root . '/core/lib/Drupal/Component/FileCache',
|
||||
$this->root . '/core/lib/Drupal/Component/FileSystem',
|
||||
$this->root . '/core/lib/Drupal/Component/Gettext',
|
||||
$this->root . '/core/lib/Drupal/Component/Graph',
|
||||
$this->root . '/core/lib/Drupal/Component/HttpFoundation',
|
||||
|
|
|
@ -568,4 +568,5 @@ class AccessManagerTest extends UnitTestCase {
|
|||
*/
|
||||
interface TestAccessCheckInterface extends AccessCheckInterface {
|
||||
public function access();
|
||||
|
||||
}
|
||||
|
|
|
@ -91,5 +91,4 @@ class AjaxResponseTest extends UnitTestCase {
|
|||
$this->assertEquals($response->getContent(), '<textarea>[]</textarea>');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -165,4 +165,5 @@ class TestMemoryBackend extends MemoryBackend {
|
|||
public function getAllCids() {
|
||||
return array_keys($this->cache);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -500,5 +500,6 @@ class CssCollectionRendererUnitTest extends UnitTestCase {
|
|||
);
|
||||
$this->renderer->render($css_group);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -77,7 +77,7 @@ class CssOptimizerUnitTest extends UnitTestCase {
|
|||
*/
|
||||
function providerTestOptimize() {
|
||||
$path = 'core/tests/Drupal/Tests/Core/Asset/css_test_files/';
|
||||
$absolute_path = dirname(__FILE__) . '/css_test_files/';
|
||||
$absolute_path = dirname(__FILE__) . '/css_test_files/';
|
||||
return array(
|
||||
// File. Tests:
|
||||
// - Stripped comments and white-space.
|
||||
|
@ -188,7 +188,7 @@ class CssOptimizerUnitTest extends UnitTestCase {
|
|||
'browsers' => array('IE' => TRUE, '!IE' => TRUE),
|
||||
'basename' => 'css_input_with_bom.css',
|
||||
),
|
||||
'.byte-order-mark-test{content:"☃";}'. "\n",
|
||||
'.byte-order-mark-test{content:"☃";}' . "\n",
|
||||
),
|
||||
array(
|
||||
array(
|
||||
|
|
|
@ -31,13 +31,13 @@ class JsOptimizerUnitTest extends UnitTestCase {
|
|||
/**
|
||||
* Provides data for the JS asset cleaning test.
|
||||
*
|
||||
* @see \Drupal\Core\Asset\JsOptimizer::clean().
|
||||
* @see \Drupal\Core\Asset\JsOptimizer::clean()
|
||||
*
|
||||
* @returns array
|
||||
* An array of test data.
|
||||
*/
|
||||
function providerTestClean() {
|
||||
$path = dirname(__FILE__) . '/js_test_files/';
|
||||
$path = dirname(__FILE__) . '/js_test_files/';
|
||||
return array(
|
||||
// File. Tests:
|
||||
// - Stripped sourceMappingURL with comment # syntax.
|
||||
|
@ -78,13 +78,13 @@ class JsOptimizerUnitTest extends UnitTestCase {
|
|||
/**
|
||||
* Provides data for the JS asset optimize test.
|
||||
*
|
||||
* @see \Drupal\Core\Asset\JsOptimizer::optimize().
|
||||
* @see \Drupal\Core\Asset\JsOptimizer::optimize()
|
||||
*
|
||||
* @returns array
|
||||
* An array of test data.
|
||||
*/
|
||||
function providerTestOptimize() {
|
||||
$path = dirname(__FILE__) . '/js_test_files/';
|
||||
$path = dirname(__FILE__) . '/js_test_files/';
|
||||
return array(
|
||||
0 => array(
|
||||
array(
|
||||
|
|
|
@ -14,7 +14,7 @@ class BlockBaseTest extends UnitTestCase {
|
|||
/**
|
||||
* Tests the machine name suggestion.
|
||||
*
|
||||
* @see \Drupal\Core\Block\BlockBase::getMachineNameSuggestion().
|
||||
* @see \Drupal\Core\Block\BlockBase::getMachineNameSuggestion()
|
||||
*/
|
||||
public function testGetMachineNameSuggestion() {
|
||||
$module_handler = $this->getMock('Drupal\Core\Extension\ModuleHandlerInterface');
|
||||
|
|
|
@ -297,4 +297,5 @@ class BackendChainImplementationUnitTest extends UnitTestCase {
|
|||
|
||||
$chain->removeBin();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ class PathParentCacheContextTest extends UnitTestCase {
|
|||
*
|
||||
* @dataProvider providerTestGetContext
|
||||
*/
|
||||
public function testgetContext($original_path, $context) {
|
||||
public function testGetContext($original_path, $context) {
|
||||
$request_stack = new RequestStack();
|
||||
$request = Request::create($original_path);
|
||||
$request_stack->push($request);
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\Core\Cache\Context;
|
||||
|
||||
use Drupal\Core\Cache\Context\QueryArgsCacheContext;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Component\HttpFoundation\RequestStack;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \Drupal\Core\Cache\Context\QueryArgsCacheContext
|
||||
* @group Cache
|
||||
*/
|
||||
class QueryArgsCacheContextTest extends UnitTestCase {
|
||||
|
||||
/**
|
||||
* @covers ::getContext
|
||||
*
|
||||
* @dataProvider providerTestGetContext
|
||||
*/
|
||||
public function testGetContext(array $query_args, $cache_context_parameter, $context) {
|
||||
$request_stack = new RequestStack();
|
||||
$request = Request::create('/', 'GET', $query_args);
|
||||
$request_stack->push($request);
|
||||
$cache_context = new QueryArgsCacheContext($request_stack);
|
||||
$this->assertSame($cache_context->getContext($cache_context_parameter), $context);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a list of query arguments and expected cache contexts.
|
||||
*/
|
||||
public function providerTestGetContext() {
|
||||
return [
|
||||
[[], NULL, NULL],
|
||||
[[], 'foo', NULL],
|
||||
// Non-empty query arguments.
|
||||
[['llama' => 'rocks', 'alpaca' => '', 'panda' => 'drools', 'z' => '0'], NULL, 'alpaca=&llama=rocks&panda=drools&z=0'],
|
||||
[['llama' => 'rocks', 'alpaca' => '', 'panda' => 'drools', 'z' => '0'], 'llama', 'rocks'],
|
||||
[['llama' => 'rocks', 'alpaca' => '', 'panda' => 'drools', 'z' => '0'], 'alpaca', '?valueless?'],
|
||||
[['llama' => 'rocks', 'alpaca' => '', 'panda' => 'drools', 'z' => '0'], 'panda', 'drools'],
|
||||
[['llama' => 'rocks', 'alpaca' => '', 'panda' => 'drools', 'z' => '0'], 'z', '0'],
|
||||
[['llama' => 'rocks', 'alpaca' => '', 'panda' => 'drools', 'z' => '0'], 'chicken', NULL],
|
||||
];
|
||||
}
|
||||
|
||||
}
|
|
@ -24,4 +24,5 @@ class NullBackendTest extends UnitTestCase {
|
|||
$null_cache->set($key, $value);
|
||||
$this->assertFalse($null_cache->get($key));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -88,4 +88,5 @@ class TestConditionAccessResolverTrait {
|
|||
use \Drupal\Core\Condition\ConditionAccessResolverTrait {
|
||||
resolveConditions as public;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -130,4 +130,5 @@ class QueryFactoryTest extends UnitTestCase {
|
|||
->getMock();
|
||||
return $config->setName($name);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -278,14 +278,17 @@ class MockContainerInjection implements ContainerInjectionInterface {
|
|||
public function getResult() {
|
||||
return $this->result;
|
||||
}
|
||||
|
||||
}
|
||||
class MockContainerAware extends ContainerAware {
|
||||
public function getResult() {
|
||||
return 'This is container aware.';
|
||||
}
|
||||
|
||||
}
|
||||
class MockInvokeController {
|
||||
public function __invoke() {
|
||||
return 'This used __invoke().';
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -38,4 +38,5 @@ class EmptyStatementTest extends UnitTestCase {
|
|||
|
||||
$this->assertEquals($result->fetchAll(), array(), 'Empty array returned from empty result set.');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -46,4 +46,5 @@ class OrderByTest extends UnitTestCase {
|
|||
$sql = $this->query->__toString();
|
||||
$this->assertStringEndsWith('ORDER BY xDROPtablenode ASC', $sql, 'Order by field is escaped correctly.');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
159
core/tests/Drupal/Tests/Core/Datetime/DrupalDateTimeTest.php
Normal file
159
core/tests/Drupal/Tests/Core/Datetime/DrupalDateTimeTest.php
Normal file
|
@ -0,0 +1,159 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\Core\Datetime;
|
||||
|
||||
use Drupal\Core\Datetime\DrupalDateTime;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
|
||||
/**
|
||||
* @coversDefaultClass \Drupal\Core\Datetime\DrupalDateTime
|
||||
* @group Datetime
|
||||
*/
|
||||
class DrupalDateTimeTest extends UnitTestCase {
|
||||
|
||||
/**
|
||||
* Test date diffs.
|
||||
*
|
||||
* @param mixed $input1
|
||||
* A DrupalDateTime object.
|
||||
* @param mixed $input2
|
||||
* Date argument for DrupalDateTime::diff method.
|
||||
* @param bool $absolute
|
||||
* Absolute flag for DrupalDateTime::diff method.
|
||||
* @param \DateInterval $expected
|
||||
* The expected result of the DrupalDateTime::diff operation.
|
||||
*
|
||||
* @dataProvider providerTestDateDiff
|
||||
*/
|
||||
public function testDateDiff($input1, $input2, $absolute, \DateInterval $expected) {
|
||||
$interval = $input1->diff($input2, $absolute);
|
||||
$this->assertEquals($interval, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test date diff exception caused by invalid input.
|
||||
*
|
||||
* @param mixed $input1
|
||||
* A DateTimePlus object.
|
||||
* @param mixed $input2
|
||||
* Date argument for DateTimePlus::diff method.
|
||||
* @param bool $absolute
|
||||
* Absolute flag for DateTimePlus::diff method.
|
||||
*
|
||||
* @dataProvider providerTestInvalidDateDiff
|
||||
*/
|
||||
public function testInvalidDateDiff($input1, $input2, $absolute) {
|
||||
$this->setExpectedException(\BadMethodCallException::class, 'Method Drupal\Component\Datetime\DateTimePlus::diff expects parameter 1 to be a \DateTime or \Drupal\Component\Datetime\DateTimePlus object');
|
||||
$interval = $input1->diff($input2, $absolute);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides data for date tests.
|
||||
*
|
||||
* @return array
|
||||
* An array of arrays, each containing the input parameters for
|
||||
* DrupalDateTimeTest::testDateDiff().
|
||||
*
|
||||
* @see DrupalDateTimeTest::testDateDiff()
|
||||
*/
|
||||
public function providerTestDateDiff() {
|
||||
|
||||
$settings = ['langcode' => 'en'];
|
||||
|
||||
$utc_tz = new \DateTimeZone('UTC');
|
||||
|
||||
$empty_interval = new \DateInterval('PT0S');
|
||||
|
||||
$positive_19_hours = new \DateInterval('PT19H');
|
||||
|
||||
$positive_18_hours = new \DateInterval('PT18H');
|
||||
|
||||
$positive_1_hour = new \DateInterval('PT1H');
|
||||
|
||||
$negative_1_hour = new \DateInterval('PT1H');
|
||||
$negative_1_hour->invert = 1;
|
||||
|
||||
return array(
|
||||
|
||||
// There should be a 19 hour time interval between
|
||||
// new years in Sydney and new years in LA in year 2000.
|
||||
array(
|
||||
'input2' => DrupalDateTime::createFromFormat('Y-m-d H:i:s', '2000-01-01 00:00:00', new \DateTimeZone('Australia/Sydney'), $settings),
|
||||
'input1' => DrupalDateTime::createFromFormat('Y-m-d H:i:s', '2000-01-01 00:00:00', new \DateTimeZone('America/Los_Angeles'), $settings),
|
||||
'absolute' => FALSE,
|
||||
'expected' => $positive_19_hours,
|
||||
),
|
||||
// In 1970 Sydney did not observe daylight savings time
|
||||
// So there is only a 18 hour time interval.
|
||||
array(
|
||||
'input2' => DrupalDateTime::createFromFormat('Y-m-d H:i:s', '1970-01-01 00:00:00', new \DateTimeZone('Australia/Sydney'), $settings),
|
||||
'input1' => DrupalDateTime::createFromFormat('Y-m-d H:i:s', '1970-01-01 00:00:00', new \DateTimeZone('America/Los_Angeles'), $settings),
|
||||
'absolute' => FALSE,
|
||||
'expected' => $positive_18_hours,
|
||||
),
|
||||
array(
|
||||
'input1' => DrupalDateTime::createFromFormat('U', 3600, new \DateTimeZone('America/Los_Angeles'), $settings),
|
||||
'input2' => DrupalDateTime::createFromFormat('U', 0, $utc_tz, $settings),
|
||||
'absolute' => FALSE,
|
||||
'expected' => $negative_1_hour,
|
||||
),
|
||||
array(
|
||||
'input1' => DrupalDateTime::createFromFormat('U', 3600, $utc_tz, $settings),
|
||||
'input2' => DrupalDateTime::createFromFormat('U', 0, $utc_tz, $settings),
|
||||
'absolute' => FALSE,
|
||||
'expected' => $negative_1_hour,
|
||||
),
|
||||
array(
|
||||
'input1' => DrupalDateTime::createFromFormat('U', 3600, $utc_tz, $settings),
|
||||
'input2' => \DateTime::createFromFormat('U', 0),
|
||||
'absolute' => FALSE,
|
||||
'expected' => $negative_1_hour,
|
||||
),
|
||||
array(
|
||||
'input1' => DrupalDateTime::createFromFormat('U', 3600, $utc_tz, $settings),
|
||||
'input2' => DrupalDateTime::createFromFormat('U', 0, $utc_tz, $settings),
|
||||
'absolute' => TRUE,
|
||||
'expected' => $positive_1_hour,
|
||||
),
|
||||
array(
|
||||
'input1' => DrupalDateTime::createFromFormat('U', 3600, $utc_tz, $settings),
|
||||
'input2' => \DateTime::createFromFormat('U', 0),
|
||||
'absolute' => TRUE,
|
||||
'expected' => $positive_1_hour,
|
||||
),
|
||||
array(
|
||||
'input1' => DrupalDateTime::createFromFormat('U', 0, $utc_tz, $settings),
|
||||
'input2' => DrupalDateTime::createFromFormat('U', 0, $utc_tz, $settings),
|
||||
'absolute' => FALSE,
|
||||
'expected' => $empty_interval,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides data for date tests.
|
||||
*
|
||||
* @return array
|
||||
* An array of arrays, each containing the input parameters for
|
||||
* DateTimePlusTest::testInvalidDateDiff().
|
||||
*
|
||||
* @see DateTimePlusTest::testInvalidDateDiff()
|
||||
*/
|
||||
public function providerTestInvalidDateDiff() {
|
||||
$settings = ['langcode' => 'en'];
|
||||
$utc_tz = new \DateTimeZone('UTC');
|
||||
return array(
|
||||
array(
|
||||
'input1' => DrupalDateTime::createFromFormat('U', 3600, $utc_tz, $settings),
|
||||
'input2' => '1970-01-01 00:00:00',
|
||||
'absolute' => FALSE,
|
||||
),
|
||||
array(
|
||||
'input1' => DrupalDateTime::createFromFormat('U', 3600, $utc_tz, $settings),
|
||||
'input2' => NULL,
|
||||
'absolute' => FALSE,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
|
@ -359,10 +359,12 @@ class ValidConsumer {
|
|||
}
|
||||
public function addWithId(HandlerInterface $instance, $id, $priority = 0) {
|
||||
}
|
||||
|
||||
}
|
||||
class InvalidConsumer {
|
||||
public function addHandler($instance, $priority = 0) {
|
||||
}
|
||||
|
||||
}
|
||||
class ValidConsumerWithExtraArguments {
|
||||
public function addHandler(HandlerInterface $instance, $priority = 0, $extra1 = '', $extra2 = '') {
|
||||
|
@ -373,6 +375,7 @@ class ValidConsumerWithExtraArguments {
|
|||
}
|
||||
public function addWithDifferentOrder(HandlerInterface $instance, $extra1, $priority = 0, $extra2 = 'default2', $extra3 = 'default3') {
|
||||
}
|
||||
|
||||
}
|
||||
class ValidHandler implements HandlerInterface {
|
||||
}
|
||||
|
|
|
@ -90,4 +90,5 @@ class DependencySerializationTestDummy implements ContainerAwareInterface {
|
|||
public function getServiceIds() {
|
||||
return $this->_serviceIds;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -133,6 +133,7 @@ EOD;
|
|||
$request->server->set('SCRIPT_NAME', '/index.php');
|
||||
$this->assertEquals('sites/example', DrupalKernel::findSitePath($request));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@ use Drupal\Core\DependencyInjection\ContainerBuilder;
|
|||
use Drupal\Core\Entity\ContentEntityInterface;
|
||||
use Drupal\Core\Field\BaseFieldDefinition;
|
||||
use Drupal\Core\Language\LanguageInterface;
|
||||
use Drupal\Core\TypedData\TypedDataManagerInterface;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
use Drupal\Core\Language\Language;
|
||||
|
||||
|
@ -130,9 +131,7 @@ class ContentEntityBaseUnitTest extends UnitTestCase {
|
|||
|
||||
$this->uuid = $this->getMock('\Drupal\Component\Uuid\UuidInterface');
|
||||
|
||||
$this->typedDataManager = $this->getMockBuilder('\Drupal\Core\TypedData\TypedDataManager')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$this->typedDataManager = $this->getMock(TypedDataManagerInterface::class);
|
||||
$this->typedDataManager->expects($this->any())
|
||||
->method('getDefinition')
|
||||
->with('entity')
|
||||
|
|
|
@ -784,6 +784,7 @@ class TestEntityFieldManager extends EntityFieldManager {
|
|||
$this->fieldDefinitions = [];
|
||||
$this->fieldStorageDefinitions = [];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -143,4 +143,5 @@ class TestEntityListBuilder extends EntityTestListBuilder {
|
|||
public function buildOperations(EntityInterface $entity) {
|
||||
return array();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -218,6 +218,15 @@ class DefaultTableMappingTest extends UnitTestCase {
|
|||
$table_mapping = new DefaultTableMapping($this->entityType, $definitions);
|
||||
$expected = ['value' => 'test__value', 'format' => 'test__format'];
|
||||
$this->assertSame($expected, $table_mapping->getColumnNames('test'));
|
||||
|
||||
$definitions['test'] = $this->setUpDefinition('test', ['value']);
|
||||
// Set custom storage.
|
||||
$definitions['test']->expects($this->any())
|
||||
->method('hasCustomStorage')
|
||||
->wilLReturn(TRUE);
|
||||
$table_mapping = new DefaultTableMapping($this->entityType, $definitions);
|
||||
// Should return empty for column names.
|
||||
$this->assertSame([], $table_mapping->getColumnNames('test'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -6,6 +6,7 @@ use Drupal\Core\DependencyInjection\ContainerBuilder;
|
|||
use Drupal\Core\Entity\Plugin\DataType\EntityAdapter;
|
||||
use Drupal\Core\Field\BaseFieldDefinition;
|
||||
use Drupal\Core\Language\LanguageInterface;
|
||||
use Drupal\Core\TypedData\TypedDataManagerInterface;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
use Drupal\Core\Language\Language;
|
||||
|
||||
|
@ -136,9 +137,7 @@ class EntityAdapterUnitTest extends UnitTestCase {
|
|||
|
||||
$this->uuid = $this->getMock('\Drupal\Component\Uuid\UuidInterface');
|
||||
|
||||
$this->typedDataManager = $this->getMockBuilder('\Drupal\Core\TypedData\TypedDataManager')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$this->typedDataManager = $this->getMock(TypedDataManagerInterface::class);
|
||||
$this->typedDataManager->expects($this->any())
|
||||
->method('getDefinition')
|
||||
->with('entity')
|
||||
|
@ -412,4 +411,5 @@ class EntityAdapterUnitTest extends UnitTestCase {
|
|||
$this->entityAdapter->setValue(NULL);
|
||||
$this->assertEquals(new \ArrayIterator([]), $this->entityAdapter->getIterator());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -267,4 +267,5 @@ class RedirectResponseSubscriberTest extends UnitTestCase {
|
|||
|
||||
return $data;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -0,0 +1,157 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\Core\Extension;
|
||||
|
||||
use Drupal\Core\Extension\Extension;
|
||||
use Drupal\Core\Extension\ExtensionDiscovery;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
use org\bovigo\vfs\vfsStream;
|
||||
use Symfony\Component\Yaml\Yaml;
|
||||
|
||||
/**
|
||||
* Tests discovery of extensions.
|
||||
*
|
||||
* @coversDefaultClass \Drupal\Core\Extension\ExtensionDiscovery
|
||||
* @group Extension
|
||||
*/
|
||||
class ExtensionDiscoveryTest extends UnitTestCase {
|
||||
|
||||
/**
|
||||
* Tests extension discovery in a virtual filesystem with vfsStream.
|
||||
*
|
||||
* @covers ::scan
|
||||
*/
|
||||
public function testExtensionDiscoveryVfs() {
|
||||
|
||||
// Set up the file system.
|
||||
$filesystem = [];
|
||||
$files_by_type_and_name_expected = $this->populateFilesystemStructure($filesystem);
|
||||
|
||||
$vfs = vfsStream::setup('root', NULL, $filesystem);
|
||||
$root = $vfs->url();
|
||||
|
||||
$this->assertFileExists($root . '/core/modules/system/system.module');
|
||||
$this->assertFileExists($root . '/core/modules/system/system.info.yml');
|
||||
|
||||
// Create an ExtensionDiscovery with $root.
|
||||
$extension_discovery = new ExtensionDiscovery($root, FALSE, NULL, 'sites/default');
|
||||
|
||||
/** @var \Drupal\Core\Extension\Extension[][] $extensions_by_type */
|
||||
$extensions_by_type = [];
|
||||
$files_by_type_and_name = [];
|
||||
foreach (['profile', 'module', 'theme', 'theme_engine'] as $type) {
|
||||
$extensions_by_type[$type] = $extension_discovery->scan($type, FALSE);
|
||||
foreach ($extensions_by_type[$type] as $name => $extension) {
|
||||
$files_by_type_and_name[$type][$name] = $extension->getPathname();
|
||||
}
|
||||
if ($type === 'profile') {
|
||||
// Set profile directories for discovery of the other extension types.
|
||||
$extension_discovery->setProfileDirectories(['myprofile' => 'profiles/myprofile']);
|
||||
}
|
||||
}
|
||||
|
||||
$this->assertEquals($files_by_type_and_name_expected, $files_by_type_and_name);
|
||||
|
||||
$extension_expected = new Extension($root, 'module', 'core/modules/system/system.info.yml', 'system.module');
|
||||
$extension_expected->subpath = 'modules/system';
|
||||
$extension_expected->origin = 'core';
|
||||
$this->assertEquals($extension_expected, $extensions_by_type['module']['system'], 'system');
|
||||
|
||||
$extension_expected = new Extension($root, 'theme_engine', 'core/themes/engines/twig/twig.info.yml', 'twig.engine');
|
||||
$extension_expected->subpath = 'themes/engines/twig';
|
||||
$extension_expected->origin = 'core';
|
||||
$this->assertEquals($extension_expected, $extensions_by_type['theme_engine']['twig'], 'twig');
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds example files to the filesystem structure.
|
||||
*
|
||||
* @param array $filesystem_structure
|
||||
*
|
||||
* @return string[][]
|
||||
* Format: $[$type][$name] = $yml_file
|
||||
* E.g. $['module']['system'] = 'system.info.yml'
|
||||
*/
|
||||
protected function populateFilesystemStructure(array &$filesystem_structure) {
|
||||
$info_by_file = [
|
||||
'core/profiles/standard/standard.info.yml' => [
|
||||
'type' => 'profile',
|
||||
],
|
||||
'core/profiles/minimal/minimal.info.yml' => [
|
||||
'type' => 'profile',
|
||||
],
|
||||
// Override the core instance of the 'minimal' profile.
|
||||
'sites/default/profiles/minimal/minimal.info.yml' => [
|
||||
'type' => 'profile',
|
||||
],
|
||||
'profiles/myprofile/myprofile.info.yml' => [
|
||||
'type' => 'profile',
|
||||
],
|
||||
'profiles/myprofile/modules/myprofile_nested_module/myprofile_nested_module.info.yml' => [],
|
||||
'profiles/otherprofile/otherprofile.info.yml' => [
|
||||
'type' => 'profile',
|
||||
],
|
||||
'core/modules/user/user.info.yml' => [],
|
||||
'profiles/otherprofile/modules/otherprofile_nested_module/otherprofile_nested_module.info.yml' => [],
|
||||
'core/modules/system/system.info.yml' => [],
|
||||
'core/themes/seven/seven.info.yml' => [
|
||||
'type' => 'theme',
|
||||
],
|
||||
// Override the core instance of the 'seven' theme.
|
||||
'sites/default/themes/seven/seven.info.yml' => [
|
||||
'type' => 'theme',
|
||||
],
|
||||
'modules/devel/devel.info.yml' => [],
|
||||
'modules/poorly_placed_theme/poorly_placed_theme.info.yml' => [
|
||||
'type' => 'theme',
|
||||
],
|
||||
'core/themes/engines/twig/twig.info.yml' => [
|
||||
'type' => 'theme_engine',
|
||||
],
|
||||
];
|
||||
|
||||
$files_by_type_and_name_expected = [];
|
||||
$content_by_file = [];
|
||||
foreach ($info_by_file as $file => $info) {
|
||||
$name = basename($file, '.info.yml');
|
||||
$info += [
|
||||
'type' => 'module',
|
||||
'name' => "Name of ($name)",
|
||||
'core' => '8.x',
|
||||
];
|
||||
$type = $info['type'];
|
||||
$content_by_file[$file] = Yaml::dump($info);
|
||||
$files_by_type_and_name_expected[$type][$name] = $file;
|
||||
}
|
||||
|
||||
$content_by_file['core/modules/system/system.module'] = '<?php';
|
||||
$content_by_file['core/themes/engines/twig/twig.engine'] = '<?php';
|
||||
|
||||
foreach ($content_by_file as $file => $content) {
|
||||
$pieces = explode('/', $file);
|
||||
$this->addFileToFilesystemStructure($filesystem_structure, $pieces, $content);
|
||||
}
|
||||
|
||||
unset($files_by_type_and_name_expected['module']['otherprofile_nested_module']);
|
||||
|
||||
return $files_by_type_and_name_expected;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $filesystem_structure
|
||||
* @param string[] $pieces
|
||||
* Fragments of the file path.
|
||||
* @param string $content
|
||||
*/
|
||||
protected function addFileToFilesystemStructure(array &$filesystem_structure, array $pieces, $content) {
|
||||
$piece = array_shift($pieces);
|
||||
if ($pieces !== []) {
|
||||
$filesystem_structure += [$piece => []];
|
||||
$this->addFileToFilesystemStructure($filesystem_structure[$piece], $pieces, $content);
|
||||
}
|
||||
else {
|
||||
$filesystem_structure[$piece] = $content;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -511,4 +511,5 @@ class ModuleHandlerTest extends UnitTestCase {
|
|||
$this->moduleHandler->addModule('module', 'place');
|
||||
$this->assertEquals(array('module' => $this->root . '/place'), $this->moduleHandler->getModuleDirectories());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,5 +5,7 @@
|
|||
* Test module.
|
||||
*/
|
||||
|
||||
// return an array to test nested merge in invoke all.
|
||||
/**
|
||||
* Returns an array to test nested merge in invoke all.
|
||||
*/
|
||||
function module_handler_test_all1_hook($arg) { return array($arg); }
|
||||
|
|
|
@ -5,6 +5,7 @@ namespace Drupal\Tests\Core\Field;
|
|||
use Drupal\Core\DependencyInjection\ContainerBuilder;
|
||||
use Drupal\Core\Field\BaseFieldDefinition;
|
||||
use Drupal\Core\Field\FieldTypePluginManager;
|
||||
use Drupal\Core\TypedData\TypedDataManagerInterface;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
|
||||
/**
|
||||
|
@ -35,9 +36,7 @@ abstract class BaseFieldDefinitionTestBase extends UnitTestCase {
|
|||
->method('moduleExists')
|
||||
->with($module_name)
|
||||
->will($this->returnValue(TRUE));
|
||||
$typed_data_manager = $this->getMockBuilder('\Drupal\Core\TypedData\TypedDataManager')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$typed_data_manager = $this->getMock(TypedDataManagerInterface::class);
|
||||
$plugin_manager = new FieldTypePluginManager(
|
||||
$namespaces,
|
||||
$this->getMock('Drupal\Core\Cache\CacheBackendInterface'),
|
||||
|
|
|
@ -208,4 +208,5 @@ class FieldItemListTest extends UnitTestCase {
|
|||
|
||||
$this->assertNull($field_list->defaultValuesFormSubmit([], $form, $form_state));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -886,11 +886,13 @@ class TestForm implements FormInterface {
|
|||
}
|
||||
public function validateForm(array &$form, FormStateInterface $form_state) { }
|
||||
public function submitForm(array &$form, FormStateInterface $form_state) { }
|
||||
|
||||
}
|
||||
class TestFormInjected extends TestForm implements ContainerInjectionInterface {
|
||||
public static function create(ContainerInterface $container) {
|
||||
return new static();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -583,6 +583,7 @@ class FormStateTest extends UnitTestCase {
|
|||
$form_state->setValue('value_to_keep', 'magic_ponies');
|
||||
$this->assertSame($form_state->cleanValues()->getValues(), ['value_to_keep' => 'magic_ponies']);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -596,4 +597,5 @@ class PrepareCallbackTestForm implements FormInterface {
|
|||
public function buildForm(array $form, FormStateInterface $form_state) {}
|
||||
public function validateForm(array &$form, FormStateInterface $form_state) { }
|
||||
public function submitForm(array &$form, FormStateInterface $form_state) { }
|
||||
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Reference in a new issue