diff --git a/core/modules/system/src/Tests/Ajax/FormValuesTest.php b/core/modules/system/src/Tests/Ajax/FormValuesTest.php index 17e74f680f2d45cad6bc2961130b33247235d065..c8f164b46ed0178556a073bf1c77ee461a5b4e07 100644 --- a/core/modules/system/src/Tests/Ajax/FormValuesTest.php +++ b/core/modules/system/src/Tests/Ajax/FormValuesTest.php @@ -18,8 +18,7 @@ class FormValuesTest extends AjaxTestBase { protected function setUp() { parent::setUp(); - $this->web_user = $this->drupalCreateUser(array('access content')); - $this->drupalLogin($this->web_user); + $this->drupalLogin($this->drupalCreateUser(array('access content'))); } /** diff --git a/core/modules/system/src/Tests/Ajax/MultiFormTest.php b/core/modules/system/src/Tests/Ajax/MultiFormTest.php index 5710b70133ea65cdee09e293f664d493e9254c25..449861c0f431cefd62845d33ee6fea13df52a989 100644 --- a/core/modules/system/src/Tests/Ajax/MultiFormTest.php +++ b/core/modules/system/src/Tests/Ajax/MultiFormTest.php @@ -47,8 +47,7 @@ protected function setUp() { ->save(); // Login a user who can create 'page' nodes. - $this->web_user = $this->drupalCreateUser(array('create page content')); - $this->drupalLogin($this->web_user); + $this->drupalLogin ($this->drupalCreateUser(array('create page content'))); } /** diff --git a/core/modules/system/src/Tests/Cache/CacheTestBase.php b/core/modules/system/src/Tests/Cache/CacheTestBase.php index 251e528fcac6add226275238e6057353c3f3de7d..df52a3768ea1bfe7017aa7163064e2dddf8b64a4 100644 --- a/core/modules/system/src/Tests/Cache/CacheTestBase.php +++ b/core/modules/system/src/Tests/Cache/CacheTestBase.php @@ -14,9 +14,9 @@ */ abstract class CacheTestBase extends WebTestBase { - protected $default_bin = 'render'; - protected $default_cid = 'test_temporary'; - protected $default_value = 'CacheTest'; + protected $defaultBin = 'render'; + protected $defaultCid = 'test_temporary'; + protected $defaultValue = 'CacheTest'; /** * Checks whether or not a cache entry exists. @@ -32,7 +32,7 @@ abstract class CacheTestBase extends WebTestBase { */ protected function checkCacheExists($cid, $var, $bin = NULL) { if ($bin == NULL) { - $bin = $this->default_bin; + $bin = $this->defaultBin; } $cached = \Drupal::cache($bin)->get($cid); @@ -54,13 +54,13 @@ protected function checkCacheExists($cid, $var, $bin = NULL) { */ protected function assertCacheExists($message, $var = NULL, $cid = NULL, $bin = NULL) { if ($bin == NULL) { - $bin = $this->default_bin; + $bin = $this->defaultBin; } if ($cid == NULL) { - $cid = $this->default_cid; + $cid = $this->defaultCid; } if ($var == NULL) { - $var = $this->default_value; + $var = $this->defaultValue; } $this->assertTrue($this->checkCacheExists($cid, $var, $bin), $message); @@ -78,10 +78,10 @@ protected function assertCacheExists($message, $var = NULL, $cid = NULL, $bin = */ function assertCacheRemoved($message, $cid = NULL, $bin = NULL) { if ($bin == NULL) { - $bin = $this->default_bin; + $bin = $this->defaultBin; } if ($cid == NULL) { - $cid = $this->default_cid; + $cid = $this->defaultCid; } $cached = \Drupal::cache($bin)->get($cid); diff --git a/core/modules/system/src/Tests/Cache/ClearTest.php b/core/modules/system/src/Tests/Cache/ClearTest.php index 1a152ed2041ef545cae870b95e9621a9a48af69e..7ba9419b612ca08c50e2fbae4ef9d2bc7c26f8ff 100644 --- a/core/modules/system/src/Tests/Cache/ClearTest.php +++ b/core/modules/system/src/Tests/Cache/ClearTest.php @@ -17,8 +17,8 @@ class ClearTest extends CacheTestBase { protected function setUp() { - $this->default_bin = 'render'; - $this->default_value = $this->randomMachineName(10); + $this->defaultBin = 'render'; + $this->defaultValue = $this->randomMachineName(10); parent::setUp(); } @@ -32,7 +32,7 @@ function testFlushAllCaches() { $this->assertTrue($bins, 'Cache::getBins() returned bins to flush.'); foreach ($bins as $bin => $cache_backend) { $cid = 'test_cid_clear' . $bin; - $cache_backend->set($cid, $this->default_value); + $cache_backend->set($cid, $this->defaultValue); } // Remove all caches then make sure that they are cleared. @@ -40,7 +40,7 @@ function testFlushAllCaches() { foreach ($bins as $bin => $cache_backend) { $cid = 'test_cid_clear' . $bin; - $this->assertFalse($this->checkCacheExists($cid, $this->default_value, $bin), format_string('All cache entries removed from @bin.', array('@bin' => $bin))); + $this->assertFalse($this->checkCacheExists($cid, $this->defaultValue, $bin), format_string('All cache entries removed from @bin.', array('@bin' => $bin))); } } } diff --git a/core/modules/system/src/Tests/Common/FormatDateTest.php b/core/modules/system/src/Tests/Common/FormatDateTest.php index 9d9a265f225206a5f0e3ce9b33c76a3466662202..33a7f91c057135c7cbe30c1cb9619e238a9614a8 100644 --- a/core/modules/system/src/Tests/Common/FormatDateTest.php +++ b/core/modules/system/src/Tests/Common/FormatDateTest.php @@ -56,9 +56,8 @@ protected function setUp() { * Tests admin-defined formats in format_date(). */ function testAdminDefinedFormatDate() { - // Create an admin user. - $this->admin_user = $this->drupalCreateUser(array('administer site configuration')); - $this->drupalLogin($this->admin_user); + // Create and log in an admin user. + $this->drupalLogin($this->drupalCreateUser(array('administer site configuration'))); // Add new date format. $edit = array( diff --git a/core/modules/system/src/Tests/Common/SizeUnitTest.php b/core/modules/system/src/Tests/Common/SizeUnitTest.php index 76fe65273ca5bd12065b276d7c1cca71b6e8a0c6..afe1d3a70dcf11d1ebd9dd707462141178a6e603 100644 --- a/core/modules/system/src/Tests/Common/SizeUnitTest.php +++ b/core/modules/system/src/Tests/Common/SizeUnitTest.php @@ -17,13 +17,13 @@ * @group Common */ class SizeUnitTest extends KernelTestBase { - protected $exact_test_cases; - protected $rounded_test_cases; + protected $exactTestCases; + protected $roundedTestCases; protected function setUp() { parent::setUp(); $kb = Bytes::KILOBYTE; - $this->exact_test_cases = array( + $this->exactTestCases = array( '1 byte' => 1, '1 KB' => $kb, '1 MB' => $kb * $kb, @@ -34,12 +34,12 @@ protected function setUp() { '1 ZB' => $kb * $kb * $kb * $kb * $kb * $kb * $kb, '1 YB' => $kb * $kb * $kb * $kb * $kb * $kb * $kb * $kb, ); - $this->rounded_test_cases = array( + $this->roundedTestCases = array( '2 bytes' => 2, '1 MB' => ($kb * $kb) - 1, // rounded to 1 MB (not 1000 or 1024 kilobyte!) - round(3623651 / ($this->exact_test_cases['1 MB']), 2) . ' MB' => 3623651, // megabytes - round(67234178751368124 / ($this->exact_test_cases['1 PB']), 2) . ' PB' => 67234178751368124, // petabytes - round(235346823821125814962843827 / ($this->exact_test_cases['1 YB']), 2) . ' YB' => 235346823821125814962843827, // yottabytes + round(3623651 / ($this->exactTestCases['1 MB']), 2) . ' MB' => 3623651, // megabytes + round(67234178751368124 / ($this->exactTestCases['1 PB']), 2) . ' PB' => 67234178751368124, // petabytes + round(235346823821125814962843827 / ($this->exactTestCases['1 YB']), 2) . ' YB' => 235346823821125814962843827, // yottabytes ); } @@ -47,7 +47,7 @@ protected function setUp() { * Checks that format_size() returns the expected string. */ function testCommonFormatSize() { - foreach (array($this->exact_test_cases, $this->rounded_test_cases) as $test_cases) { + foreach (array($this->exactTestCases, $this->roundedTestCases) as $test_cases) { foreach ($test_cases as $expected => $input) { $this->assertEqual( ($result = format_size($input, NULL)), @@ -62,7 +62,7 @@ function testCommonFormatSize() { * Cross-tests Bytes::toInt() and format_size(). */ function testCommonParseSizeFormatSize() { - foreach ($this->exact_test_cases as $size) { + foreach ($this->exactTestCases as $size) { $this->assertEqual( $size, ($parsed_size = Bytes::toInt($string = format_size($size, NULL))), diff --git a/core/modules/system/src/Tests/Database/SchemaTest.php b/core/modules/system/src/Tests/Database/SchemaTest.php index 6b96e3dcc8dfdc92778a734cde47686a6a3fd998..a59b9d9a0ed9dc12a68ee0b3158d072c2e7fc57a 100644 --- a/core/modules/system/src/Tests/Database/SchemaTest.php +++ b/core/modules/system/src/Tests/Database/SchemaTest.php @@ -23,7 +23,7 @@ class SchemaTest extends KernelTestBase { /** * A global counter for table and field creation. */ - var $counter; + protected $counter; /** * Tests database interactions. diff --git a/core/modules/system/src/Tests/Entity/EntityCacheTagsTestBase.php b/core/modules/system/src/Tests/Entity/EntityCacheTagsTestBase.php index df0b6d76a3db1ad1fc3c2d023fb462df2bef1de5..23d5f793a94495476ff745f959f6210e8ad060a6 100644 --- a/core/modules/system/src/Tests/Entity/EntityCacheTagsTestBase.php +++ b/core/modules/system/src/Tests/Entity/EntityCacheTagsTestBase.php @@ -42,14 +42,14 @@ abstract class EntityCacheTagsTestBase extends PageCacheTagsTestBase { * * @var \Drupal\Core\Entity\EntityInterface */ - protected $referencing_entity; + protected $referencingEntity; /** * The entity instance not referencing the main entity. * * @var \Drupal\Core\Entity\EntityInterface */ - protected $non_referencing_entity; + protected $nonReferencingEntity; /** * {@inheritdoc} @@ -96,8 +96,8 @@ protected function setUp() { // Create a referencing and a non-referencing entity. list( - $this->referencing_entity, - $this->non_referencing_entity, + $this->referencingEntity, + $this->nonReferencingEntity, ) = $this->createReferenceTestEntities($this->entity); } @@ -305,8 +305,8 @@ protected function createReferenceTestEntities($referenced_entity) { */ public function testReferencedEntity() { $entity_type = $this->entity->getEntityTypeId(); - $referencing_entity_url = $this->referencing_entity->urlInfo('canonical'); - $non_referencing_entity_url = $this->non_referencing_entity->urlInfo('canonical'); + $referencing_entity_url = $this->referencingEntity->urlInfo('canonical'); + $non_referencing_entity_url = $this->nonReferencingEntity->urlInfo('canonical'); $listing_url = Url::fromRoute('entity.entity_test.collection_referencing_entities', [ 'entity_reference_field_name' => $entity_type . '_reference', 'referenced_entity_type' => $entity_type, @@ -335,7 +335,7 @@ public function testReferencedEntity() { // Generate the cache tags for the (non) referencing entities. $referencing_entity_cache_tags = Cache::mergeTags( - $this->referencing_entity->getCacheTags(), + $this->referencingEntity->getCacheTags(), \Drupal::entityManager()->getViewBuilder('entity_test')->getCacheTags(), // Includes the main entity's cache tags, since this entity references it. $this->entity->getCacheTags(), @@ -344,7 +344,7 @@ public function testReferencedEntity() { ['rendered'] ); $non_referencing_entity_cache_tags = Cache::mergeTags( - $this->non_referencing_entity->getCacheTags(), + $this->nonReferencingEntity->getCacheTags(), \Drupal::entityManager()->getViewBuilder('entity_test')->getCacheTags(), ['rendered'] ); @@ -368,7 +368,7 @@ public function testReferencedEntity() { // Verify a cache hit, but also the presence of the correct cache tags. $this->verifyPageCache($referencing_entity_url, 'HIT', Cache::mergeTags($referencing_entity_cache_tags, $page_cache_tags)); // Also verify the existence of an entity render cache entry. - $cache_keys = ['entity_view', 'entity_test', $this->referencing_entity->id(), 'full']; + $cache_keys = ['entity_view', 'entity_test', $this->referencingEntity->id(), 'full']; $cid = $this->createCacheId($cache_keys, $entity_cache_contexts); $redirected_cid = $this->createRedirectedCacheId($cache_keys, $entity_cache_contexts); $this->verifyRenderCache($cid, $referencing_entity_cache_tags, $redirected_cid); @@ -378,7 +378,7 @@ public function testReferencedEntity() { // Verify a cache hit, but also the presence of the correct cache tags. $this->verifyPageCache($non_referencing_entity_url, 'HIT', Cache::mergeTags($non_referencing_entity_cache_tags, $page_cache_tags)); // Also verify the existence of an entity render cache entry. - $cache_keys = ['entity_view', 'entity_test', $this->non_referencing_entity->id(), 'full']; + $cache_keys = ['entity_view', 'entity_test', $this->nonReferencingEntity->id(), 'full']; $cid = $this->createCacheId($cache_keys, $entity_cache_contexts); $this->verifyRenderCache($cid, $non_referencing_entity_cache_tags); @@ -431,7 +431,7 @@ public function testReferencedEntity() { // for every route except the ones for the non-referencing entity and the // empty entity listing. $this->pass("Test modification of referencing entity.", 'Debug'); - $this->referencing_entity->save(); + $this->referencingEntity->save(); $this->verifyPageCache($referencing_entity_url, 'MISS'); $this->verifyPageCache($listing_url, 'MISS'); $this->verifyPageCache($nonempty_entity_listing_url, 'HIT'); @@ -447,7 +447,7 @@ public function testReferencedEntity() { // Verify that after modifying the non-referencing entity, there is a cache // miss only for the non-referencing entity route. $this->pass("Test modification of non-referencing entity.", 'Debug'); - $this->non_referencing_entity->save(); + $this->nonReferencingEntity->save(); $this->verifyPageCache($referencing_entity_url, 'HIT'); $this->verifyPageCache($listing_url, 'HIT'); $this->verifyPageCache($empty_entity_listing_url, 'HIT'); @@ -608,7 +608,7 @@ public function testReferencedEntity() { // Verify cache hits. $referencing_entity_cache_tags = Cache::mergeTags( - $this->referencing_entity->getCacheTags(), + $this->referencingEntity->getCacheTags(), \Drupal::entityManager()->getViewBuilder('entity_test')->getCacheTags(), ['rendered'] ); @@ -655,7 +655,7 @@ protected function createCacheId(array $keys, array $contexts) { * The redirected (post-bubbling) CID, if any. */ protected function createRedirectedCacheId(array $keys, array $contexts) { - $additional_cache_contexts = $this->getAdditionalCacheContextsForEntity($this->referencing_entity); + $additional_cache_contexts = $this->getAdditionalCacheContextsForEntity($this->referencingEntity); if (count($additional_cache_contexts)) { return $this->createCacheId($keys, Cache::mergeContexts($contexts, $additional_cache_contexts)); } diff --git a/core/modules/system/src/Tests/Entity/EntityFieldTest.php b/core/modules/system/src/Tests/Entity/EntityFieldTest.php index 8be7a1da3e15bab01bae693906f5f6f8f3c47ec5..4f562a92b8e8c45f1e84ba604f18d27cae64c0da 100644 --- a/core/modules/system/src/Tests/Entity/EntityFieldTest.php +++ b/core/modules/system/src/Tests/Entity/EntityFieldTest.php @@ -35,17 +35,17 @@ class EntityFieldTest extends EntityUnitTestBase { /** * @var string */ - protected $entity_name; + protected $entityName; /** * @var \Drupal\user\Entity\User */ - protected $entity_user; + protected $entityUser; /** * @var string */ - protected $entity_field_text; + protected $entityFieldText; protected function setUp() { parent::setUp(); @@ -70,18 +70,18 @@ protected function setUp() { * @return \Drupal\Core\Entity\EntityInterface */ protected function createTestEntity($entity_type) { - $this->entity_name = $this->randomMachineName(); - $this->entity_user = $this->createUser(); - $this->entity_field_text = $this->randomMachineName(); + $this->entityName = $this->randomMachineName(); + $this->entityUser = $this->createUser(); + $this->entityFieldText = $this->randomMachineName(); // Pass in the value of the name field when creating. With the user // field we test setting a field after creation. $entity = entity_create($entity_type); - $entity->user_id->target_id = $this->entity_user->id(); - $entity->name->value = $this->entity_name; + $entity->user_id->target_id = $this->entityUser->id(); + $entity->name->value = $this->entityName; // Set a value for the test field. - $entity->field_test_text->value = $this->entity_field_text; + $entity->field_test_text->value = $this->entityFieldText; return $entity; } @@ -111,9 +111,9 @@ protected function doTestReadWrite($entity_type) { $this->assertTrue($entity->name instanceof FieldItemListInterface, format_string('%entity_type: Field implements interface', array('%entity_type' => $entity_type))); $this->assertTrue($entity->name[0] instanceof FieldItemInterface, format_string('%entity_type: Field item implements interface', array('%entity_type' => $entity_type))); - $this->assertEqual($this->entity_name, $entity->name->value, format_string('%entity_type: Name value can be read.', array('%entity_type' => $entity_type))); - $this->assertEqual($this->entity_name, $entity->name[0]->value, format_string('%entity_type: Name value can be read through list access.', array('%entity_type' => $entity_type))); - $this->assertEqual($entity->name->getValue(), array(0 => array('value' => $this->entity_name)), format_string('%entity_type: Plain field value returned.', array('%entity_type' => $entity_type))); + $this->assertEqual($this->entityName, $entity->name->value, format_string('%entity_type: Name value can be read.', array('%entity_type' => $entity_type))); + $this->assertEqual($this->entityName, $entity->name[0]->value, format_string('%entity_type: Name value can be read through list access.', array('%entity_type' => $entity_type))); + $this->assertEqual($entity->name->getValue(), array(0 => array('value' => $this->entityName)), format_string('%entity_type: Plain field value returned.', array('%entity_type' => $entity_type))); // Change the name. $new_name = $this->randomMachineName(); @@ -129,8 +129,8 @@ protected function doTestReadWrite($entity_type) { $this->assertTrue($entity->user_id instanceof FieldItemListInterface, format_string('%entity_type: Field implements interface', array('%entity_type' => $entity_type))); $this->assertTrue($entity->user_id[0] instanceof FieldItemInterface, format_string('%entity_type: Field item implements interface', array('%entity_type' => $entity_type))); - $this->assertEqual($this->entity_user->id(), $entity->user_id->target_id, format_string('%entity_type: User id can be read.', array('%entity_type' => $entity_type))); - $this->assertEqual($this->entity_user->getUsername(), $entity->user_id->entity->name->value, format_string('%entity_type: User name can be read.', array('%entity_type' => $entity_type))); + $this->assertEqual($this->entityUser->id(), $entity->user_id->target_id, format_string('%entity_type: User id can be read.', array('%entity_type' => $entity_type))); + $this->assertEqual($this->entityUser->getUsername(), $entity->user_id->entity->name->value, format_string('%entity_type: User name can be read.', array('%entity_type' => $entity_type))); // Change the assigned user by entity. $new_user1 = $this->createUser(); @@ -241,28 +241,28 @@ protected function doTestReadWrite($entity_type) { $this->assertEqual(\Drupal::languageManager()->getDefaultLanguage(), $entity->{$langcode_key}->language, format_string('%entity_type: Language object can be read.', array('%entity_type' => $entity_type))); // Access the text field and test updating. - $this->assertEqual($entity->field_test_text->value, $this->entity_field_text, format_string('%entity_type: Text field can be read.', array('%entity_type' => $entity_type))); + $this->assertEqual($entity->field_test_text->value, $this->entityFieldText, format_string('%entity_type: Text field can be read.', array('%entity_type' => $entity_type))); $new_text = $this->randomMachineName(); $entity->field_test_text->value = $new_text; $this->assertEqual($entity->field_test_text->value, $new_text, format_string('%entity_type: Updated text field can be read.', array('%entity_type' => $entity_type))); // Test creating the entity by passing in plain values. - $this->entity_name = $this->randomMachineName(); - $name_item[0]['value'] = $this->entity_name; - $this->entity_user = $this->createUser(); - $user_item[0]['target_id'] = $this->entity_user->id(); - $this->entity_field_text = $this->randomMachineName(); - $text_item[0]['value'] = $this->entity_field_text; + $this->entityName = $this->randomMachineName(); + $name_item[0]['value'] = $this->entityName; + $this->entityUser = $this->createUser(); + $user_item[0]['target_id'] = $this->entityUser->id(); + $this->entityFieldText = $this->randomMachineName(); + $text_item[0]['value'] = $this->entityFieldText; $entity = entity_create($entity_type, array( 'name' => $name_item, 'user_id' => $user_item, 'field_test_text' => $text_item, )); - $this->assertEqual($this->entity_name, $entity->name->value, format_string('%entity_type: Name value can be read.', array('%entity_type' => $entity_type))); - $this->assertEqual($this->entity_user->id(), $entity->user_id->target_id, format_string('%entity_type: User id can be read.', array('%entity_type' => $entity_type))); - $this->assertEqual($this->entity_user->getUsername(), $entity->user_id->entity->name->value, format_string('%entity_type: User name can be read.', array('%entity_type' => $entity_type))); - $this->assertEqual($this->entity_field_text, $entity->field_test_text->value, format_string('%entity_type: Text field can be read.', array('%entity_type' => $entity_type))); + $this->assertEqual($this->entityName, $entity->name->value, format_string('%entity_type: Name value can be read.', array('%entity_type' => $entity_type))); + $this->assertEqual($this->entityUser->id(), $entity->user_id->target_id, format_string('%entity_type: User id can be read.', array('%entity_type' => $entity_type))); + $this->assertEqual($this->entityUser->getUsername(), $entity->user_id->entity->name->value, format_string('%entity_type: User name can be read.', array('%entity_type' => $entity_type))); + $this->assertEqual($this->entityFieldText, $entity->field_test_text->value, format_string('%entity_type: Text field can be read.', array('%entity_type' => $entity_type))); // Tests copying field values by assigning the TypedData objects. $entity2 = $this->createTestEntity($entity_type); @@ -374,9 +374,9 @@ protected function doTestSave($entity_type) { $this->assertTrue(is_string($entity->uuid->value), format_string('%entity_type: UUID value can be read.', array('%entity_type' => $entity_type))); $this->assertEqual('en', $entity->{$langcode_key}->value, format_string('%entity_type: Language code can be read.', array('%entity_type' => $entity_type))); $this->assertEqual(\Drupal::languageManager()->getLanguage('en'), $entity->{$langcode_key}->language, format_string('%entity_type: Language object can be read.', array('%entity_type' => $entity_type))); - $this->assertEqual($this->entity_user->id(), $entity->user_id->target_id, format_string('%entity_type: User id can be read.', array('%entity_type' => $entity_type))); - $this->assertEqual($this->entity_user->getUsername(), $entity->user_id->entity->name->value, format_string('%entity_type: User name can be read.', array('%entity_type' => $entity_type))); - $this->assertEqual($this->entity_field_text, $entity->field_test_text->value, format_string('%entity_type: Text field can be read.', array('%entity_type' => $entity_type))); + $this->assertEqual($this->entityUser->id(), $entity->user_id->target_id, format_string('%entity_type: User id can be read.', array('%entity_type' => $entity_type))); + $this->assertEqual($this->entityUser->getUsername(), $entity->user_id->entity->name->value, format_string('%entity_type: User name can be read.', array('%entity_type' => $entity_type))); + $this->assertEqual($this->entityFieldText, $entity->field_test_text->value, format_string('%entity_type: Text field can be read.', array('%entity_type' => $entity_type))); } /** @@ -550,10 +550,10 @@ protected function doTestDataStructureInterfaces($entity_type) { $target_strings = array( $entity->uuid->value, 'en', - $this->entity_name, + $this->entityName, // Bundle name. $entity->bundle(), - $this->entity_field_text, + $this->entityFieldText, // Field format. NULL, ); diff --git a/core/modules/system/src/Tests/Entity/EntityLanguageTestBase.php b/core/modules/system/src/Tests/Entity/EntityLanguageTestBase.php index d453b92e7b27329be806c460fc8c6dd1b1d3f1c9..48eac845127c3866f132263775d7457e6a4f41c4 100644 --- a/core/modules/system/src/Tests/Entity/EntityLanguageTestBase.php +++ b/core/modules/system/src/Tests/Entity/EntityLanguageTestBase.php @@ -35,14 +35,14 @@ abstract class EntityLanguageTestBase extends EntityUnitTestBase { * * @var string */ - protected $field_name; + protected $fieldName; /** * The untranslatable test field name. * * @var string */ - protected $untranslatable_field_name; + protected $untranslatableFieldName; public static $modules = array('language', 'entity_test'); @@ -67,35 +67,35 @@ protected function setUp() { $this->state->set('entity_test.translation', TRUE); // Create a translatable test field. - $this->field_name = Unicode::strtolower($this->randomMachineName() . '_field_name'); + $this->fieldName = Unicode::strtolower($this->randomMachineName() . '_field_name'); // Create an untranslatable test field. - $this->untranslatable_field_name = Unicode::strtolower($this->randomMachineName() . '_field_name'); + $this->untranslatableFieldName = Unicode::strtolower($this->randomMachineName() . '_field_name'); // Create field fields in all entity variations. foreach (entity_test_entity_types() as $entity_type) { entity_create('field_storage_config', array( - 'field_name' => $this->field_name, + 'field_name' => $this->fieldName, 'entity_type' => $entity_type, 'type' => 'text', 'cardinality' => 4, ))->save(); entity_create('field_config', array( - 'field_name' => $this->field_name, + 'field_name' => $this->fieldName, 'entity_type' => $entity_type, 'bundle' => $entity_type, 'translatable' => TRUE, ))->save(); - $this->field[$entity_type] = FieldConfig::load($entity_type . '.' . $entity_type . '.' . $this->field_name); + $this->field[$entity_type] = FieldConfig::load($entity_type . '.' . $entity_type . '.' . $this->fieldName); entity_create('field_storage_config', array( - 'field_name' => $this->untranslatable_field_name, + 'field_name' => $this->untranslatableFieldName, 'entity_type' => $entity_type, 'type' => 'text', 'cardinality' => 4, ))->save(); entity_create('field_config', array( - 'field_name' => $this->untranslatable_field_name, + 'field_name' => $this->untranslatableFieldName, 'entity_type' => $entity_type, 'bundle' => $entity_type, 'translatable' => FALSE, @@ -125,7 +125,7 @@ protected function setUp() { * The type of the entity fields are attached to. */ protected function toggleFieldTranslatability($entity_type, $bundle) { - $fields = array($this->field_name, $this->untranslatable_field_name); + $fields = array($this->fieldName, $this->untranslatableFieldName); foreach ($fields as $field_name) { $field = FieldConfig::loadByName($entity_type, $bundle, $field_name); $translatable = !$field->isTranslatable(); diff --git a/core/modules/system/src/Tests/Entity/EntityListBuilderTest.php b/core/modules/system/src/Tests/Entity/EntityListBuilderTest.php index 10becbf5c85524bc7e3d27b6527a0eaea3a7ee6d..485e72c209a0295fe9eeeef39ac751ebf390d9d8 100644 --- a/core/modules/system/src/Tests/Entity/EntityListBuilderTest.php +++ b/core/modules/system/src/Tests/Entity/EntityListBuilderTest.php @@ -29,10 +29,10 @@ protected function setUp() { parent::setUp(); // Create and login user. - $this->web_user = $this->drupalCreateUser(array( + $this->webUser = $this->drupalCreateUser(array( 'administer entity_test content', )); - $this->drupalLogin($this->web_user); + $this->drupalLogin($this->webUser); } /** diff --git a/core/modules/system/src/Tests/Entity/EntityOperationsTest.php b/core/modules/system/src/Tests/Entity/EntityOperationsTest.php index 4593bd9bfee43c852508ac9aba318c0d0966c1d0..fbd77dfdd4d0daa6c0f8534bd7eddab8e8498902 100644 --- a/core/modules/system/src/Tests/Entity/EntityOperationsTest.php +++ b/core/modules/system/src/Tests/Entity/EntityOperationsTest.php @@ -27,10 +27,7 @@ protected function setUp() { parent::setUp(); // Create and login user. - $this->web_user = $this->drupalCreateUser(array( - 'administer permissions', - )); - $this->drupalLogin($this->web_user); + $this->drupalLogin($this->drupalCreateUser(array('administer permissions'))); } /** diff --git a/core/modules/system/src/Tests/Entity/EntityRevisionsTest.php b/core/modules/system/src/Tests/Entity/EntityRevisionsTest.php index 06168a211fffddfc6732b2ac15b96a567b2cbf74..8ce6e3df5e24635a2cfe69b2fc52c33885432092 100644 --- a/core/modules/system/src/Tests/Entity/EntityRevisionsTest.php +++ b/core/modules/system/src/Tests/Entity/EntityRevisionsTest.php @@ -24,14 +24,21 @@ class EntityRevisionsTest extends WebTestBase { */ public static $modules = array('entity_test'); + /** + * A user with permission to administer entity_test content. + * + * @var \Drupal\user\UserInterface + */ + protected $webUser; + protected function setUp() { parent::setUp(); // Create and login user. - $this->web_user = $this->drupalCreateUser(array( + $this->webUser = $this->drupalCreateUser(array( 'administer entity_test content', )); - $this->drupalLogin($this->web_user); + $this->drupalLogin($this->webUser); } /** @@ -56,7 +63,7 @@ protected function assertRevisions($entity_type) { // Create initial entity. $entity = entity_create($entity_type, array( 'name' => 'foo', - 'user_id' => $this->web_user->id(), + 'user_id' => $this->webUser->id(), )); $entity->field_test_text->value = 'bar'; $entity->save(); diff --git a/core/modules/system/src/Tests/Entity/EntityTranslationTest.php b/core/modules/system/src/Tests/Entity/EntityTranslationTest.php index 03300afa104765e991a90b113ba4daa0d84263f8..70ed45b85c86064340898f18be05be01b36f39a6 100644 --- a/core/modules/system/src/Tests/Entity/EntityTranslationTest.php +++ b/core/modules/system/src/Tests/Entity/EntityTranslationTest.php @@ -52,22 +52,22 @@ protected function doTestEntityLanguageMethods($entity_type) { $this->assertFalse($entity->getTranslationLanguages(FALSE), format_string('%entity_type: No translations are available', array('%entity_type' => $entity_type))); // Set the value in default language. - $entity->set($this->field_name, array(0 => array('value' => 'default value'))); + $entity->set($this->fieldName, array(0 => array('value' => 'default value'))); // Get the value. - $field = $entity->getTranslation(LanguageInterface::LANGCODE_DEFAULT)->get($this->field_name); + $field = $entity->getTranslation(LanguageInterface::LANGCODE_DEFAULT)->get($this->fieldName); $this->assertEqual($field->value, 'default value', format_string('%entity_type: Untranslated value retrieved.', array('%entity_type' => $entity_type))); $this->assertEqual($field->getLangcode(), LanguageInterface::LANGCODE_NOT_SPECIFIED, format_string('%entity_type: Field object has the expected langcode.', array('%entity_type' => $entity_type))); // Set the value in a certain language. As the entity is not // language-specific it should use the default language and so ignore the // specified language. - $entity->getTranslation($this->langcodes[1])->set($this->field_name, array(0 => array('value' => 'default value2'))); - $this->assertEqual($entity->get($this->field_name)->value, 'default value2', format_string('%entity_type: Untranslated value updated.', array('%entity_type' => $entity_type))); + $entity->getTranslation($this->langcodes[1])->set($this->fieldName, array(0 => array('value' => 'default value2'))); + $this->assertEqual($entity->get($this->fieldName)->value, 'default value2', format_string('%entity_type: Untranslated value updated.', array('%entity_type' => $entity_type))); $this->assertFalse($entity->getTranslationLanguages(FALSE), format_string('%entity_type: No translations are available', array('%entity_type' => $entity_type))); // Test getting a field value using a specific language for a not // language-specific entity. - $field = $entity->getTranslation($this->langcodes[1])->get($this->field_name); + $field = $entity->getTranslation($this->langcodes[1])->get($this->fieldName); $this->assertEqual($field->value, 'default value2', format_string('%entity_type: Untranslated value retrieved.', array('%entity_type' => $entity_type))); $this->assertEqual($field->getLangcode(), LanguageInterface::LANGCODE_NOT_SPECIFIED, format_string('%entity_type: Field object has the expected langcode.', array('%entity_type' => $entity_type))); @@ -75,25 +75,25 @@ protected function doTestEntityLanguageMethods($entity_type) { // translating it. $default_langcode = $this->langcodes[0]; $entity->{$langcode_key}->value = $default_langcode; - $entity->{$this->field_name} = array(); + $entity->{$this->fieldName} = array(); $this->assertEqual($entity->language(), \Drupal::languageManager()->getLanguage($this->langcodes[0]), format_string('%entity_type: Entity language retrieved.', array('%entity_type' => $entity_type))); $this->assertFalse($entity->getTranslationLanguages(FALSE), format_string('%entity_type: No translations are available', array('%entity_type' => $entity_type))); // Set the value in default language. - $entity->set($this->field_name, array(0 => array('value' => 'default value'))); + $entity->set($this->fieldName, array(0 => array('value' => 'default value'))); // Get the value. - $field = $entity->get($this->field_name); + $field = $entity->get($this->fieldName); $this->assertEqual($field->value, 'default value', format_string('%entity_type: Untranslated value retrieved.', array('%entity_type' => $entity_type))); $this->assertEqual($field->getLangcode(), $default_langcode, format_string('%entity_type: Field object has the expected langcode.', array('%entity_type' => $entity_type))); // Set a translation. - $entity->getTranslation($this->langcodes[1])->set($this->field_name, array(0 => array('value' => 'translation 1'))); - $field = $entity->getTranslation($this->langcodes[1])->{$this->field_name}; + $entity->getTranslation($this->langcodes[1])->set($this->fieldName, array(0 => array('value' => 'translation 1'))); + $field = $entity->getTranslation($this->langcodes[1])->{$this->fieldName}; $this->assertEqual($field->value, 'translation 1', format_string('%entity_type: Translated value set.', array('%entity_type' => $entity_type))); $this->assertEqual($field->getLangcode(), $this->langcodes[1], format_string('%entity_type: Field object has the expected langcode.', array('%entity_type' => $entity_type))); // Make sure the untranslated value stays. - $field = $entity->get($this->field_name); + $field = $entity->get($this->fieldName); $this->assertEqual($field->value, 'default value', 'Untranslated value stays.'); $this->assertEqual($field->getLangcode(), $default_langcode, 'Untranslated value has the expected langcode.'); @@ -101,11 +101,11 @@ protected function doTestEntityLanguageMethods($entity_type) { $this->assertEqual($entity->getTranslationLanguages(FALSE), $translations, 'Translations retrieved.'); // Try to get a not available translation. - $this->assertNull($entity->getTranslation($this->langcodes[2])->get($this->field_name)->value, format_string('%entity_type: A translation that is not available is NULL.', array('%entity_type' => $entity_type))); + $this->assertNull($entity->getTranslation($this->langcodes[2])->get($this->fieldName)->value, format_string('%entity_type: A translation that is not available is NULL.', array('%entity_type' => $entity_type))); // Try to get a value using an invalid language code. try { - $entity->getTranslation('invalid')->get($this->field_name)->value; + $entity->getTranslation('invalid')->get($this->fieldName)->value; $this->fail('Getting a translation for an invalid language is NULL.'); } catch (\InvalidArgumentException $e) { @@ -114,7 +114,7 @@ protected function doTestEntityLanguageMethods($entity_type) { // Try to set a value using an invalid language code. try { - $entity->getTranslation('invalid')->set($this->field_name, NULL); + $entity->getTranslation('invalid')->set($this->fieldName, NULL); $this->fail(format_string('%entity_type: Setting a translation for an invalid language throws an exception.', array('%entity_type' => $entity_type))); } catch (\InvalidArgumentException $e) { @@ -278,7 +278,7 @@ protected function doTestMultilingualProperties($entity_type) { // Test mixed property and field conditions. $entity = entity_load($entity_type, reset($result), TRUE); $field_value = $this->randomString(); - $entity->getTranslation($langcode)->set($this->field_name, array(array('value' => $field_value))); + $entity->getTranslation($langcode)->set($this->fieldName, array(array('value' => $field_value))); $entity->save(); $query = \Drupal::entityQuery($entity_type); $default_langcode_group = $query->andConditionGroup() @@ -286,7 +286,7 @@ protected function doTestMultilingualProperties($entity_type) { ->condition('name', $properties[$default_langcode]['name'][0], '=', $default_langcode); $langcode_group = $query->andConditionGroup() ->condition('name', $properties[$langcode]['name'][0], '=', $langcode) - ->condition("$this->field_name.value", $field_value, '=', $langcode); + ->condition("$this->fieldName.value", $field_value, '=', $langcode); $result = $query ->condition($langcode_key, $default_langcode) ->condition($default_langcode_group) @@ -681,11 +681,11 @@ protected function doTestLanguageChange($entity_type) { // translatability. $values = array( $langcode_key => $langcode, - $this->field_name => $this->randomMachineName(), - $this->untranslatable_field_name => $this->randomMachineName(), + $this->fieldName => $this->randomMachineName(), + $this->untranslatableFieldName => $this->randomMachineName(), ); $entity = $controller->create($values); - foreach (array($this->field_name, $this->untranslatable_field_name) as $field_name) { + foreach (array($this->fieldName, $this->untranslatableFieldName) as $field_name) { $this->assertEqual($entity->get($field_name)->getLangcode(), $langcode, 'Field language works as expected.'); } @@ -693,16 +693,16 @@ protected function doTestLanguageChange($entity_type) { // changing it. $langcode = $this->langcodes[1]; $entity->{$langcode_key}->value = $langcode; - foreach (array($this->field_name, $this->untranslatable_field_name) as $field_name) { + foreach (array($this->fieldName, $this->untranslatableFieldName) as $field_name) { $this->assertEqual($entity->get($field_name)->getLangcode(), $langcode, 'Field language works as expected after changing entity language.'); } // Check that entity translation does not affect the language of original // field values and untranslatable ones. $langcode = $this->langcodes[0]; - $entity->addTranslation($this->langcodes[2], array($this->field_name => $this->randomMachineName())); + $entity->addTranslation($this->langcodes[2], array($this->fieldName => $this->randomMachineName())); $entity->{$langcode_key}->value = $langcode; - foreach (array($this->field_name, $this->untranslatable_field_name) as $field_name) { + foreach (array($this->fieldName, $this->untranslatableFieldName) as $field_name) { $this->assertEqual($entity->get($field_name)->getLangcode(), $langcode, 'Field language works as expected after translating the entity and changing language.'); } diff --git a/core/modules/system/src/Tests/Entity/EntityValidationTest.php b/core/modules/system/src/Tests/Entity/EntityValidationTest.php index 96e5d8b93149e1bcb86a41c9232dd5fad9045ae1..07823fbbbe0b1dda5820071b6140d1e25740b7f5 100644 --- a/core/modules/system/src/Tests/Entity/EntityValidationTest.php +++ b/core/modules/system/src/Tests/Entity/EntityValidationTest.php @@ -24,17 +24,17 @@ class EntityValidationTest extends EntityUnitTestBase { /** * @var string */ - protected $entity_name; + protected $entityName; /** * @var \Drupal\user\Entity\User */ - protected $entity_user; + protected $entityUser; /** * @var string */ - protected $entity_field_text; + protected $entityFieldText; /** * {@inheritdoc} @@ -59,18 +59,18 @@ protected function setUp() { * The created test entity. */ protected function createTestEntity($entity_type) { - $this->entity_name = $this->randomMachineName(); - $this->entity_user = $this->createUser(); - $this->entity_field_text = $this->randomMachineName(); + $this->entityName = $this->randomMachineName(); + $this->entityUser = $this->createUser(); + $this->entityFieldText = $this->randomMachineName(); // Pass in the value of the name field when creating. With the user // field we test setting a field after creation. $entity = entity_create($entity_type); - $entity->user_id->target_id = $this->entity_user->id(); - $entity->name->value = $this->entity_name; + $entity->user_id->target_id = $this->entityUser->id(); + $entity->name->value = $this->entityName; // Set a value for the test field. - $entity->field_test_text->value = $this->entity_field_text; + $entity->field_test_text->value = $this->entityFieldText; return $entity; } diff --git a/core/modules/system/src/Tests/Entity/FieldSqlStorageTest.php b/core/modules/system/src/Tests/Entity/FieldSqlStorageTest.php index 688daf203463ab33da049c7b28947144235e34bc..a6d1f8d68168c80d36cdf202a7cddd8eb04101f7 100644 --- a/core/modules/system/src/Tests/Entity/FieldSqlStorageTest.php +++ b/core/modules/system/src/Tests/Entity/FieldSqlStorageTest.php @@ -34,12 +34,12 @@ class FieldSqlStorageTest extends EntityUnitTestBase { * * @var string */ - protected $field_name; + protected $fieldName; /** * @var int */ - protected $field_cardinality; + protected $fieldCardinality; /** * A field storage to use in this class. @@ -67,14 +67,14 @@ class FieldSqlStorageTest extends EntityUnitTestBase { * * @var string */ - protected $revision_table; + protected $revisionTable; /** * The table mapping for the tested entity type. * * @var \Drupal\Core\Entity\Sql\DefaultTableMapping $table_mapping */ - protected $table_mapping; + protected $tableMapping; protected function setUp() { parent::setUp(); @@ -82,13 +82,13 @@ protected function setUp() { $this->installEntitySchema('entity_test_rev'); $entity_type = 'entity_test_rev'; - $this->field_name = strtolower($this->randomMachineName()); - $this->field_cardinality = 4; + $this->fieldName = strtolower($this->randomMachineName()); + $this->fieldCardinality = 4; $this->fieldStorage = entity_create('field_storage_config', array( - 'field_name' => $this->field_name, + 'field_name' => $this->fieldName, 'entity_type' => $entity_type, 'type' => 'test_field', - 'cardinality' => $this->field_cardinality, + 'cardinality' => $this->fieldCardinality, )); $this->fieldStorage->save(); $this->field = entity_create('field_config', array( @@ -99,9 +99,9 @@ protected function setUp() { /** @var \Drupal\Core\Entity\Sql\DefaultTableMapping $table_mapping */ $table_mapping = \Drupal::entityManager()->getStorage($entity_type)->getTableMapping(); - $this->table_mapping = $table_mapping; + $this->tableMapping = $table_mapping; $this->table = $table_mapping->getDedicatedDataTableName($this->fieldStorage); - $this->revision_table = $table_mapping->getDedicatedRevisionTableName($this->fieldStorage); + $this->revisionTable = $table_mapping->getDedicatedRevisionTableName($this->fieldStorage); } /** @@ -111,7 +111,7 @@ function testFieldLoad() { $entity_type = $bundle = 'entity_test_rev'; $storage = $this->container->get('entity.manager')->getStorage($entity_type); - $columns = array('bundle', 'deleted', 'entity_id', 'revision_id', 'delta', 'langcode', $this->table_mapping->getFieldColumnName($this->fieldStorage, 'value')); + $columns = array('bundle', 'deleted', 'entity_id', 'revision_id', 'delta', 'langcode', $this->tableMapping->getFieldColumnName($this->fieldStorage, 'value')); // Create an entity with four revisions. $revision_ids = array(); @@ -126,10 +126,10 @@ function testFieldLoad() { // Generate values and insert them directly in the storage tables. $values = array(); - $query = db_insert($this->revision_table)->fields($columns); + $query = db_insert($this->revisionTable)->fields($columns); foreach ($revision_ids as $revision_id) { // Put one value too many. - for ($delta = 0; $delta <= $this->field_cardinality; $delta++) { + for ($delta = 0; $delta <= $this->fieldCardinality; $delta++) { $value = mt_rand(1, 127); $values[$revision_id][] = $value; $query->values(array($bundle, 0, $entity->id(), $revision_id, $delta, $entity->language()->getId(), $value)); @@ -146,11 +146,11 @@ function testFieldLoad() { foreach ($revision_ids as $revision_id) { $entity = $storage->loadRevision($revision_id); foreach ($values[$revision_id] as $delta => $value) { - if ($delta < $this->field_cardinality) { - $this->assertEqual($entity->{$this->field_name}[$delta]->value, $value); + if ($delta < $this->fieldCardinality) { + $this->assertEqual($entity->{$this->fieldName}[$delta]->value, $value); } else { - $this->assertFalse(array_key_exists($delta, $entity->{$this->field_name})); + $this->assertFalse(array_key_exists($delta, $entity->{$this->fieldName})); } } } @@ -158,11 +158,11 @@ function testFieldLoad() { // Load the "current revision" and check the values. $entity = $storage->load($entity->id()); foreach ($values[$revision_id] as $delta => $value) { - if ($delta < $this->field_cardinality) { - $this->assertEqual($entity->{$this->field_name}[$delta]->value, $value); + if ($delta < $this->fieldCardinality) { + $this->assertEqual($entity->{$this->fieldName}[$delta]->value, $value); } else { - $this->assertFalse(array_key_exists($delta, $entity->{$this->field_name})); + $this->assertFalse(array_key_exists($delta, $entity->{$this->fieldName})); } } @@ -171,9 +171,9 @@ function testFieldLoad() { $unavailable_langcode = 'xx'; $values = array($bundle, 0, $entity->id(), $entity->getRevisionId(), 0, $unavailable_langcode, mt_rand(1, 127)); db_insert($this->table)->fields($columns)->values($values)->execute(); - db_insert($this->revision_table)->fields($columns)->values($values)->execute(); + db_insert($this->revisionTable)->fields($columns)->values($values)->execute(); $entity = $storage->load($entity->id()); - $this->assertFalse(array_key_exists($unavailable_langcode, $entity->{$this->field_name})); + $this->assertFalse(array_key_exists($unavailable_langcode, $entity->{$this->fieldName})); } /** @@ -187,15 +187,15 @@ function testFieldWrite() { // Check insert. Add one value too many. $values = array(); - for ($delta = 0; $delta <= $this->field_cardinality; $delta++) { + for ($delta = 0; $delta <= $this->fieldCardinality; $delta++) { $values[$delta]['value'] = mt_rand(1, 127); } - $entity->{$this->field_name} = $values; + $entity->{$this->fieldName} = $values; $entity->save(); // Read the tables and check the correct values have been stored. $rows = db_select($this->table, 't')->fields('t')->execute()->fetchAllAssoc('delta', \PDO::FETCH_ASSOC); - $this->assertEqual(count($rows), $this->field_cardinality); + $this->assertEqual(count($rows), $this->fieldCardinality); foreach ($rows as $delta => $row) { $expected = array( 'bundle' => $bundle, @@ -204,7 +204,7 @@ function testFieldWrite() { 'revision_id' => $entity->getRevisionId(), 'langcode' => $entity->language()->getId(), 'delta' => $delta, - $this->field_name . '_value' => $values[$delta]['value'], + $this->fieldName . '_value' => $values[$delta]['value'], ); $this->assertEqual($row, $expected, "Row $delta was stored as expected."); } @@ -212,10 +212,10 @@ function testFieldWrite() { // Test update. Add less values and check that the previous values did not // persist. $values = array(); - for ($delta = 0; $delta <= $this->field_cardinality - 2; $delta++) { + for ($delta = 0; $delta <= $this->fieldCardinality - 2; $delta++) { $values[$delta]['value'] = mt_rand(1, 127); } - $entity->{$this->field_name} = $values; + $entity->{$this->fieldName} = $values; $entity->save(); $rows = db_select($this->table, 't')->fields('t')->execute()->fetchAllAssoc('delta', \PDO::FETCH_ASSOC); $this->assertEqual(count($rows), count($values)); @@ -227,7 +227,7 @@ function testFieldWrite() { 'revision_id' => $entity->getRevisionId(), 'langcode' => $entity->language()->getId(), 'delta' => $delta, - $this->field_name . '_value' => $values[$delta]['value'], + $this->fieldName . '_value' => $values[$delta]['value'], ); $this->assertEqual($row, $expected, "Row $delta was stored as expected."); } @@ -235,18 +235,18 @@ function testFieldWrite() { // Create a new revision. $revision_values[$entity->getRevisionId()] = $values; $values = array(); - for ($delta = 0; $delta < $this->field_cardinality; $delta++) { + for ($delta = 0; $delta < $this->fieldCardinality; $delta++) { $values[$delta]['value'] = mt_rand(1, 127); } - $entity->{$this->field_name} = $values; + $entity->{$this->fieldName} = $values; $entity->setNewRevision(); $entity->save(); $revision_values[$entity->getRevisionId()] = $values; // Check that data for both revisions are in the revision table. foreach ($revision_values as $revision_id => $values) { - $rows = db_select($this->revision_table, 't')->fields('t')->condition('revision_id', $revision_id)->execute()->fetchAllAssoc('delta', \PDO::FETCH_ASSOC); - $this->assertEqual(count($rows), min(count($values), $this->field_cardinality)); + $rows = db_select($this->revisionTable, 't')->fields('t')->condition('revision_id', $revision_id)->execute()->fetchAllAssoc('delta', \PDO::FETCH_ASSOC); + $this->assertEqual(count($rows), min(count($values), $this->fieldCardinality)); foreach ($rows as $delta => $row) { $expected = array( 'bundle' => $bundle, @@ -255,14 +255,14 @@ function testFieldWrite() { 'revision_id' => $revision_id, 'langcode' => $entity->language()->getId(), 'delta' => $delta, - $this->field_name . '_value' => $values[$delta]['value'], + $this->fieldName . '_value' => $values[$delta]['value'], ); $this->assertEqual($row, $expected, "Row $delta was stored as expected."); } } // Test emptying the field. - $entity->{$this->field_name} = NULL; + $entity->{$this->fieldName} = NULL; $entity->save(); $rows = db_select($this->table, 't')->fields('t')->execute()->fetchAllAssoc('delta', \PDO::FETCH_ASSOC); $this->assertEqual(count($rows), 0); @@ -368,8 +368,8 @@ function testFieldUpdateFailure() { // Ensure that the field tables are still there. $tables = array( - $this->table_mapping->getDedicatedDataTableName($prior_field_storage), - $this->table_mapping->getDedicatedRevisionTableName($prior_field_storage), + $this->tableMapping->getDedicatedDataTableName($prior_field_storage), + $this->tableMapping->getDedicatedRevisionTableName($prior_field_storage), ); foreach ($tables as $table_name) { $this->assertTrue(db_table_exists($table_name), t('Table %table exists.', array('%table' => $table_name))); @@ -394,7 +394,7 @@ function testFieldUpdateIndexesWithData() { 'bundle' => $entity_type, )); $field->save(); - $tables = array($this->table_mapping->getDedicatedDataTableName($field_storage), $this->table_mapping->getDedicatedRevisionTableName($field_storage)); + $tables = array($this->tableMapping->getDedicatedDataTableName($field_storage), $this->tableMapping->getDedicatedRevisionTableName($field_storage)); // Verify the indexes we will create do not exist yet. foreach ($tables as $table) { @@ -511,9 +511,9 @@ public function testTableNames() { 'type' => 'test_field', )); $expected = 'short_entity_type__short_field_name'; - $this->assertEqual($this->table_mapping->getDedicatedDataTableName($field_storage), $expected); + $this->assertEqual($this->tableMapping->getDedicatedDataTableName($field_storage), $expected); $expected = 'short_entity_type_revision__short_field_name'; - $this->assertEqual($this->table_mapping->getDedicatedRevisionTableName($field_storage), $expected); + $this->assertEqual($this->tableMapping->getDedicatedRevisionTableName($field_storage), $expected); // Short entity type, long field name $entity_type = 'short_entity_type'; @@ -524,9 +524,9 @@ public function testTableNames() { 'type' => 'test_field', )); $expected = 'short_entity_type__' . substr(hash('sha256', $field_storage->uuid()), 0, 10); - $this->assertEqual($this->table_mapping->getDedicatedDataTableName($field_storage), $expected); + $this->assertEqual($this->tableMapping->getDedicatedDataTableName($field_storage), $expected); $expected = 'short_entity_type_r__' . substr(hash('sha256', $field_storage->uuid()), 0, 10); - $this->assertEqual($this->table_mapping->getDedicatedRevisionTableName($field_storage), $expected); + $this->assertEqual($this->tableMapping->getDedicatedRevisionTableName($field_storage), $expected); // Long entity type, short field name $entity_type = 'long_entity_type_abcdefghijklmnopqrstuvwxyz'; @@ -537,9 +537,9 @@ public function testTableNames() { 'type' => 'test_field', )); $expected = 'long_entity_type_abcdefghijklmnopq__' . substr(hash('sha256', $field_storage->uuid()), 0, 10); - $this->assertEqual($this->table_mapping->getDedicatedDataTableName($field_storage), $expected); + $this->assertEqual($this->tableMapping->getDedicatedDataTableName($field_storage), $expected); $expected = 'long_entity_type_abcdefghijklmnopq_r__' . substr(hash('sha256', $field_storage->uuid()), 0, 10); - $this->assertEqual($this->table_mapping->getDedicatedRevisionTableName($field_storage), $expected); + $this->assertEqual($this->tableMapping->getDedicatedRevisionTableName($field_storage), $expected); // Long entity type and field name. $entity_type = 'long_entity_type_abcdefghijklmnopqrstuvwxyz'; @@ -550,17 +550,17 @@ public function testTableNames() { 'type' => 'test_field', )); $expected = 'long_entity_type_abcdefghijklmnopq__' . substr(hash('sha256', $field_storage->uuid()), 0, 10); - $this->assertEqual($this->table_mapping->getDedicatedDataTableName($field_storage), $expected); + $this->assertEqual($this->tableMapping->getDedicatedDataTableName($field_storage), $expected); $expected = 'long_entity_type_abcdefghijklmnopq_r__' . substr(hash('sha256', $field_storage->uuid()), 0, 10); - $this->assertEqual($this->table_mapping->getDedicatedRevisionTableName($field_storage), $expected); + $this->assertEqual($this->tableMapping->getDedicatedRevisionTableName($field_storage), $expected); // Try creating a second field and check there are no clashes. $field_storage2 = entity_create('field_storage_config', array( 'entity_type' => $entity_type, 'field_name' => $field_name . '2', 'type' => 'test_field', )); - $this->assertNotEqual($this->table_mapping->getDedicatedDataTableName($field_storage), $this->table_mapping->getDedicatedDataTableName($field_storage2)); - $this->assertNotEqual($this->table_mapping->getDedicatedRevisionTableName($field_storage), $this->table_mapping->getDedicatedRevisionTableName($field_storage2)); + $this->assertNotEqual($this->tableMapping->getDedicatedDataTableName($field_storage), $this->tableMapping->getDedicatedDataTableName($field_storage2)); + $this->assertNotEqual($this->tableMapping->getDedicatedRevisionTableName($field_storage), $this->tableMapping->getDedicatedRevisionTableName($field_storage2)); // Deleted field. $field_storage = entity_create('field_storage_config', array( @@ -570,9 +570,9 @@ public function testTableNames() { 'deleted' => TRUE, )); $expected = 'field_deleted_data_' . substr(hash('sha256', $field_storage->uuid()), 0, 10); - $this->assertEqual($this->table_mapping->getDedicatedDataTableName($field_storage, TRUE), $expected); + $this->assertEqual($this->tableMapping->getDedicatedDataTableName($field_storage, TRUE), $expected); $expected = 'field_deleted_revision_' . substr(hash('sha256', $field_storage->uuid()), 0, 10); - $this->assertEqual($this->table_mapping->getDedicatedRevisionTableName($field_storage, TRUE), $expected); + $this->assertEqual($this->tableMapping->getDedicatedRevisionTableName($field_storage, TRUE), $expected); } } diff --git a/core/modules/system/src/Tests/Entity/FieldTranslationSqlStorageTest.php b/core/modules/system/src/Tests/Entity/FieldTranslationSqlStorageTest.php index 68c50637570b485c37d6f4501ba7e0b28a43124c..af3461eccafcce23526d9477f5f35c9c085307a8 100644 --- a/core/modules/system/src/Tests/Entity/FieldTranslationSqlStorageTest.php +++ b/core/modules/system/src/Tests/Entity/FieldTranslationSqlStorageTest.php @@ -26,8 +26,8 @@ public function testFieldSqlStorage() { $controller = $this->entityManager->getStorage($entity_type); $values = array( - $this->field_name => $this->randomMachineName(), - $this->untranslatable_field_name => $this->randomMachineName(), + $this->fieldName => $this->randomMachineName(), + $this->untranslatableFieldName => $this->randomMachineName(), ); $entity = $controller->create($values); $entity->save(); @@ -50,7 +50,7 @@ public function testFieldSqlStorage() { // before. $this->toggleFieldTranslatability($entity_type, $entity_type); $entity = $this->reloadEntity($entity); - foreach (array($this->field_name, $this->untranslatable_field_name) as $field_name) { + foreach (array($this->fieldName, $this->untranslatableFieldName) as $field_name) { $this->assertEqual($entity->get($field_name)->value, $values[$field_name], 'Field language works as expected after switching translatability.'); } @@ -61,11 +61,11 @@ public function testFieldSqlStorage() { $entity->langcode->value = $this->langcodes[0]; $translation = $entity->addTranslation($this->langcodes[1]); $translated_value = $this->randomMachineName(); - $translation->get($this->field_name)->value = $translated_value; + $translation->get($this->fieldName)->value = $translated_value; $translation->save(); $this->toggleFieldTranslatability($entity_type, $entity_type); $entity = $this->reloadEntity($entity); - $this->assertEqual($entity->getTranslation($this->langcodes[1])->get($this->field_name)->value, $values[$this->field_name], 'Existing field translations are not loaded for untranslatable fields.'); + $this->assertEqual($entity->getTranslation($this->langcodes[1])->get($this->fieldName)->value, $values[$this->fieldName], 'Existing field translations are not loaded for untranslatable fields.'); } /** @@ -81,7 +81,7 @@ protected function assertFieldStorageLangcode(FieldableEntityInterface $entity, $entity_type = $entity->getEntityTypeId(); $id = $entity->id(); $langcode = $entity->getUntranslated()->language()->getId(); - $fields = array($this->field_name, $this->untranslatable_field_name); + $fields = array($this->fieldName, $this->untranslatableFieldName); /** @var \Drupal\Core\Entity\Sql\DefaultTableMapping $table_mapping */ $table_mapping = \Drupal::entityManager()->getStorage($entity_type)->getTableMapping(); diff --git a/core/modules/system/src/Tests/File/ConfigTest.php b/core/modules/system/src/Tests/File/ConfigTest.php index 4eb7bf143bb076e67494a9edabb43d3a324f168b..183d95adb3f7ec9b9f2e3f9e03e2a4c5e7a36976 100644 --- a/core/modules/system/src/Tests/File/ConfigTest.php +++ b/core/modules/system/src/Tests/File/ConfigTest.php @@ -18,8 +18,7 @@ class ConfigTest extends WebTestBase { protected function setUp(){ parent::setUp(); - $this->web_user = $this->drupalCreateUser(array('administer site configuration')); - $this->drupalLogin($this->web_user); + $this->drupalLogin ($this->drupalCreateUser(array('administer site configuration'))); } /** diff --git a/core/modules/system/src/Tests/File/NameMungingTest.php b/core/modules/system/src/Tests/File/NameMungingTest.php index 06f44c8f4d148c053dbfad9e3506ebaf72ab6fb9..cf3fd8940fa3b738052fbd3344cea48ac0847986 100644 --- a/core/modules/system/src/Tests/File/NameMungingTest.php +++ b/core/modules/system/src/Tests/File/NameMungingTest.php @@ -17,7 +17,7 @@ class NameMungingTest extends FileTestBase { /** * @var string */ - protected $bad_extension; + protected $badExtension; /** * @var string @@ -27,13 +27,13 @@ class NameMungingTest extends FileTestBase { /** * @var string */ - protected $name_with_uc_ext; + protected $nameWithUcExt; protected function setUp() { parent::setUp(); - $this->bad_extension = 'php'; - $this->name = $this->randomMachineName() . '.' . $this->bad_extension . '.txt'; - $this->name_with_uc_ext = $this->randomMachineName() . '.' . strtoupper($this->bad_extension) . '.txt'; + $this->badExtension = 'php'; + $this->name = $this->randomMachineName() . '.' . $this->badExtension . '.txt'; + $this->nameWithUcExt = $this->randomMachineName() . '.' . strtoupper($this->badExtension) . '.txt'; } /** @@ -53,8 +53,8 @@ function testMunging() { */ function testMungeNullByte() { $prefix = $this->randomMachineName(); - $filename = $prefix . '.' . $this->bad_extension . "\0.txt"; - $this->assertEqual(file_munge_filename($filename, ''), $prefix . '.' . $this->bad_extension . '_.txt', 'A filename with a null byte is correctly munged to remove the null byte.'); + $filename = $prefix . '.' . $this->badExtension . "\0.txt"; + $this->assertEqual(file_munge_filename($filename, ''), $prefix . '.' . $this->badExtension . '_.txt', 'A filename with a null byte is correctly munged to remove the null byte.'); } /** @@ -73,10 +73,10 @@ function testMungeIgnoreInsecure() { function testMungeIgnoreWhitelisted() { // Declare our extension as whitelisted. The declared extensions should // be case insensitive so test using one with a different case. - $munged_name = file_munge_filename($this->name_with_uc_ext, $this->bad_extension); - $this->assertIdentical($munged_name, $this->name_with_uc_ext, format_string('The new filename (%munged) matches the original (%original) once the extension has been whitelisted.', array('%munged' => $munged_name, '%original' => $this->name_with_uc_ext))); + $munged_name = file_munge_filename($this->nameWithUcExt, $this->badExtension); + $this->assertIdentical($munged_name, $this->nameWithUcExt, format_string('The new filename (%munged) matches the original (%original) once the extension has been whitelisted.', array('%munged' => $munged_name, '%original' => $this->nameWithUcExt))); // The allowed extensions should also be normalized. - $munged_name = file_munge_filename($this->name, strtoupper($this->bad_extension)); + $munged_name = file_munge_filename($this->name, strtoupper($this->badExtension)); $this->assertIdentical($munged_name, $this->name, format_string('The new filename (%munged) matches the original (%original) also when the whitelisted extension is in uppercase.', array('%munged' => $munged_name, '%original' => $this->name))); } diff --git a/core/modules/system/src/Tests/FileTransfer/MockTestConnection.php b/core/modules/system/src/Tests/FileTransfer/MockTestConnection.php index b1b787a33fa2f1294da54a7575d10736b1542134..55548ad6e6f8937ba785a7fd8da222739f60ed94 100644 --- a/core/modules/system/src/Tests/FileTransfer/MockTestConnection.php +++ b/core/modules/system/src/Tests/FileTransfer/MockTestConnection.php @@ -12,8 +12,8 @@ */ class MockTestConnection { - var $commandsRun = array(); - var $connectionString; + protected $commandsRun = array(); + public $connectionString; function run($cmd) { $this->commandsRun[] = $cmd; diff --git a/core/modules/system/src/Tests/Form/ElementsVerticalTabsTest.php b/core/modules/system/src/Tests/Form/ElementsVerticalTabsTest.php index 29610f07d2a1961c27ca6c67aaa5c929049ded23..44f331f98b8ad0fffb4dbdb8059d204c5e2ce506 100644 --- a/core/modules/system/src/Tests/Form/ElementsVerticalTabsTest.php +++ b/core/modules/system/src/Tests/Form/ElementsVerticalTabsTest.php @@ -25,12 +25,26 @@ class ElementsVerticalTabsTest extends WebTestBase { */ public static $modules = array('form_test'); + /** + * A user with permission to access vertical_tab_test_tabs. + * + * @var \Drupal\user\UserInterface + */ + protected $adminUser; + + /** + * A normal user. + * + * @var \Drupal\user\UserInterface + */ + protected $webUser; + protected function setUp() { parent::setUp(); - $this->admin_user = $this->drupalCreateUser(array('access vertical_tab_test tabs')); - $this->web_user = $this->drupalCreateUser(); - $this->drupalLogin($this->admin_user); + $this->adminUser = $this->drupalCreateUser(array('access vertical_tab_test tabs')); + $this->webUser = $this->drupalCreateUser(); + $this->drupalLogin($this->adminUser); } /** @@ -55,7 +69,7 @@ function testWrapperNotShownWhenEmpty() { $this->assertTrue(isset($wrapper[0]), 'Vertical tab panes found.'); // Test wrapper markup not present for non-privileged web user. - $this->drupalLogin($this->web_user); + $this->drupalLogin($this->webUser); $this->drupalGet('form_test/vertical-tabs'); $wrapper = $this->xpath("//div[@data-vertical-tabs-panes]"); $this->assertFalse(isset($wrapper[0]), 'Vertical tab wrappers are not displayed to unprivileged users.'); diff --git a/core/modules/system/src/Tests/Form/FormCacheTest.php b/core/modules/system/src/Tests/Form/FormCacheTest.php index fbbb0f4cb843e88729abc8bfb68eacbac7745400..77d259e9e91a828cde9754899f1b76e5999ae444 100644 --- a/core/modules/system/src/Tests/Form/FormCacheTest.php +++ b/core/modules/system/src/Tests/Form/FormCacheTest.php @@ -30,7 +30,7 @@ class FormCacheTest extends KernelTestBase { /** * @var string */ - protected $form_build_id; + protected $formBuildId; /** * @var array @@ -40,18 +40,18 @@ class FormCacheTest extends KernelTestBase { /** * @var array */ - protected $form_state; + protected $formState; protected function setUp() { parent::setUp(); $this->installSchema('system', array('key_value_expire')); - $this->form_build_id = $this->randomMachineName(); + $this->formBuildId = $this->randomMachineName(); $this->form = array( '#property' => $this->randomMachineName(), ); - $this->form_state = new FormState(); - $this->form_state->set('example', $this->randomMachineName()); + $this->formState = new FormState(); + $this->formState->set('example', $this->randomMachineName()); } /** @@ -59,20 +59,20 @@ protected function setUp() { */ function testCacheToken() { \Drupal::currentUser()->setAccount(new UserSession(array('uid' => 1))); - \Drupal::formBuilder()->setCache($this->form_build_id, $this->form, $this->form_state); + \Drupal::formBuilder()->setCache($this->formBuildId, $this->form, $this->formState); $cached_form_state = new FormState(); - $cached_form = \Drupal::formBuilder()->getCache($this->form_build_id, $cached_form_state); + $cached_form = \Drupal::formBuilder()->getCache($this->formBuildId, $cached_form_state); $this->assertEqual($this->form['#property'], $cached_form['#property']); $this->assertTrue(!empty($cached_form['#cache_token']), 'Form has a cache token'); - $this->assertEqual($this->form_state->get('example'), $cached_form_state->get('example')); + $this->assertEqual($this->formState->get('example'), $cached_form_state->get('example')); // Test that the form cache isn't loaded when the session/token has changed. // Change the private key. (We cannot change the session ID because this // will break the parent site test runner batch.) \Drupal::state()->set('system.private_key', 'invalid'); $cached_form_state = new FormState(); - $cached_form = \Drupal::formBuilder()->getCache($this->form_build_id, $cached_form_state); + $cached_form = \Drupal::formBuilder()->getCache($this->formBuildId, $cached_form_state); $this->assertFalse($cached_form, 'No form returned from cache'); $cached_form_state_example = $cached_form_state->get('example'); $this->assertTrue(empty($cached_form_state_example)); @@ -93,14 +93,14 @@ function testNoCacheToken() { $account_switcher = \Drupal::service('account_switcher'); $account_switcher->switchTo(new AnonymousUserSession()); - $this->form_state->set('example', $this->randomMachineName()); - \Drupal::formBuilder()->setCache($this->form_build_id, $this->form, $this->form_state); + $this->formState->set('example', $this->randomMachineName()); + \Drupal::formBuilder()->setCache($this->formBuildId, $this->form, $this->formState); $cached_form_state = new FormState(); - $cached_form = \Drupal::formBuilder()->getCache($this->form_build_id, $cached_form_state); + $cached_form = \Drupal::formBuilder()->getCache($this->formBuildId, $cached_form_state); $this->assertEqual($this->form['#property'], $cached_form['#property']); $this->assertTrue(empty($cached_form['#cache_token']), 'Form has no cache token'); - $this->assertEqual($this->form_state->get('example'), $cached_form_state->get('example')); + $this->assertEqual($this->formState->get('example'), $cached_form_state->get('example')); // Restore user account. $account_switcher->switchBack(); diff --git a/core/modules/system/src/Tests/Form/RebuildTest.php b/core/modules/system/src/Tests/Form/RebuildTest.php index eb806529cb50e26ae76ff59ae2ed5dbbe5ae7743..e993b49d65957c1c0d52490646a363c111e6bf08 100644 --- a/core/modules/system/src/Tests/Form/RebuildTest.php +++ b/core/modules/system/src/Tests/Form/RebuildTest.php @@ -26,13 +26,20 @@ class RebuildTest extends WebTestBase { */ public static $modules = array('node', 'form_test'); + /** + * A user for testing. + * + * @var \Drupal\user\UserInterface + */ + protected $webUser; + protected function setUp() { parent::setUp(); $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page')); - $this->web_user = $this->drupalCreateUser(array('access content')); - $this->drupalLogin($this->web_user); + $this->webUser = $this->drupalCreateUser(array('access content')); + $this->drupalLogin($this->webUser); } /** @@ -82,8 +89,8 @@ function testPreserveFormActionAfterAJAX() { ->save(); // Log in a user who can create 'page' nodes. - $this->web_user = $this->drupalCreateUser(array('create page content')); - $this->drupalLogin($this->web_user); + $this->webUser = $this->drupalCreateUser(array('create page content')); + $this->drupalLogin($this->webUser); // Get the form for adding a 'page' node. Submit an "add another item" Ajax // submission and verify it worked by ensuring the updated page has two text diff --git a/core/modules/system/src/Tests/Form/StorageTest.php b/core/modules/system/src/Tests/Form/StorageTest.php index 9e99ec3884be4e427100f1c4242980e1f01a890c..f77c567324fe767567ef9b1319bcdca28d35eb02 100644 --- a/core/modules/system/src/Tests/Form/StorageTest.php +++ b/core/modules/system/src/Tests/Form/StorageTest.php @@ -33,8 +33,7 @@ class StorageTest extends WebTestBase { protected function setUp() { parent::setUp(); - $this->web_user = $this->drupalCreateUser(); - $this->drupalLogin($this->web_user); + $this->drupalLogin ($this->drupalCreateUser()); } /** diff --git a/core/modules/system/src/Tests/Image/ToolkitGdTest.php b/core/modules/system/src/Tests/Image/ToolkitGdTest.php index c45bee36fdf54d0da88f2209928ca20e2c9abd56..9b25182ab04330ad31ad3e1ced91dfa0f05549b7 100644 --- a/core/modules/system/src/Tests/Image/ToolkitGdTest.php +++ b/core/modules/system/src/Tests/Image/ToolkitGdTest.php @@ -36,7 +36,7 @@ class ToolkitGdTest extends KernelTestBase { protected $transparent = array(0, 0, 0, 127); // Used as rotate background colors. protected $fuchsia = array(255, 0, 255, 0); - protected $rotate_transparent = array(255, 255, 255, 127); + protected $rotateTransparent = array(255, 255, 255, 127); protected $width = 40; protected $height = 20; @@ -219,7 +219,7 @@ function testManipulations() { 'arguments' => array('degrees' => 5), 'width' => 42, 'height' => 24, - 'corners' => array_fill(0, 4, $this->rotate_transparent), + 'corners' => array_fill(0, 4, $this->rotateTransparent), ), 'rotate_transparent_90' => array( 'function' => 'rotate', diff --git a/core/modules/system/src/Tests/Image/ToolkitSetupFormTest.php b/core/modules/system/src/Tests/Image/ToolkitSetupFormTest.php index 1317040d18f2cac17714ccdc809956234a8ca379..2422e380ca712f9fd8e9b2a7b02a67c1b0bf1006 100644 --- a/core/modules/system/src/Tests/Image/ToolkitSetupFormTest.php +++ b/core/modules/system/src/Tests/Image/ToolkitSetupFormTest.php @@ -21,7 +21,7 @@ class ToolkitSetupFormTest extends WebTestBase { * * @var \Drupal\user\Entity\User */ - protected $admin_user; + protected $adminUser; /** * Modules to enable. @@ -35,10 +35,10 @@ class ToolkitSetupFormTest extends WebTestBase { */ protected function setUp() { parent::setUp(); - $this->admin_user = $this->drupalCreateUser(array( + $this->adminUser = $this->drupalCreateUser(array( 'administer site configuration', )); - $this->drupalLogin($this->admin_user); + $this->drupalLogin($this->adminUser); } /** diff --git a/core/modules/system/src/Tests/Mail/MailTest.php b/core/modules/system/src/Tests/Mail/MailTest.php index 36033329440047c62194a4f5b7f2608814de3779..469f82e55235ddb79e60b6352dbe5208d3c4f07c 100644 --- a/core/modules/system/src/Tests/Mail/MailTest.php +++ b/core/modules/system/src/Tests/Mail/MailTest.php @@ -25,14 +25,6 @@ class MailTest extends WebTestBase { */ public static $modules = array('simpletest', 'system_mail_failure_test'); - /** - * The most recent message that was sent through the test case. - * - * We take advantage here of the fact that static variables are shared among - * all instance of the same class. - */ - private static $sent_message; - /** * Assert that the pluggable mail system is functional. */ diff --git a/core/modules/system/src/Tests/Menu/BreadcrumbTest.php b/core/modules/system/src/Tests/Menu/BreadcrumbTest.php index 96d627780d7fdbcf3b1c0ca368244ade61b9d1f5..4b3d5311bdc556241d5cb9fdcc608e8085240b01 100644 --- a/core/modules/system/src/Tests/Menu/BreadcrumbTest.php +++ b/core/modules/system/src/Tests/Menu/BreadcrumbTest.php @@ -25,6 +25,20 @@ class BreadcrumbTest extends MenuTestBase { */ public static $modules = array('menu_test', 'block'); + /** + * An administrative user. + * + * @var \Drupal\user\UserInterface + */ + protected $adminUser; + + /** + * A regular user. + * + * @var \Drupal\user\UserInterface + */ + protected $webUser; + /** * Test paths in the Standard profile. */ @@ -34,8 +48,8 @@ protected function setUp() { parent::setUp(); $perms = array_keys(\Drupal::service('user.permissions')->getPermissions()); - $this->admin_user = $this->drupalCreateUser($perms); - $this->drupalLogin($this->admin_user); + $this->adminUser = $this->drupalCreateUser($perms); + $this->drupalLogin($this->adminUser); // This test puts menu links in the Tools menu and then tests for their // presence on the page, so we need to ensure that the Tools block will be @@ -302,47 +316,47 @@ function testBreadCrumbs() { // Verify breadcrumb on user pages (without menu link) for anonymous user. $trail = $home; $this->assertBreadcrumb('user', $trail, t('Log in')); - $this->assertBreadcrumb('user/' . $this->admin_user->id(), $trail, $this->admin_user->getUsername()); + $this->assertBreadcrumb('user/' . $this->adminUser->id(), $trail, $this->adminUser->getUsername()); // Verify breadcrumb on user pages (without menu link) for registered users. - $this->drupalLogin($this->admin_user); + $this->drupalLogin($this->adminUser); $trail = $home; - $this->assertBreadcrumb('user', $trail, $this->admin_user->getUsername()); - $this->assertBreadcrumb('user/' . $this->admin_user->id(), $trail, $this->admin_user->getUsername()); + $this->assertBreadcrumb('user', $trail, $this->adminUser->getUsername()); + $this->assertBreadcrumb('user/' . $this->adminUser->id(), $trail, $this->adminUser->getUsername()); $trail += array( - 'user/' . $this->admin_user->id() => $this->admin_user->getUsername(), + 'user/' . $this->adminUser->id() => $this->adminUser->getUsername(), ); - $this->assertBreadcrumb('user/' . $this->admin_user->id() . '/edit', $trail, $this->admin_user->getUsername()); + $this->assertBreadcrumb('user/' . $this->adminUser->id() . '/edit', $trail, $this->adminUser->getUsername()); // Create a second user to verify breadcrumb on user pages again. - $this->web_user = $this->drupalCreateUser(array( + $this->webUser = $this->drupalCreateUser(array( 'administer users', 'access user profiles', )); - $this->drupalLogin($this->web_user); + $this->drupalLogin($this->webUser); // Verify correct breadcrumb and page title on another user's account pages. $trail = $home; - $this->assertBreadcrumb('user/' . $this->admin_user->id(), $trail, $this->admin_user->getUsername()); + $this->assertBreadcrumb('user/' . $this->adminUser->id(), $trail, $this->adminUser->getUsername()); $trail += array( - 'user/' . $this->admin_user->id() => $this->admin_user->getUsername(), + 'user/' . $this->adminUser->id() => $this->adminUser->getUsername(), ); - $this->assertBreadcrumb('user/' . $this->admin_user->id() . '/edit', $trail, $this->admin_user->getUsername()); + $this->assertBreadcrumb('user/' . $this->adminUser->id() . '/edit', $trail, $this->adminUser->getUsername()); // Verify correct breadcrumb and page title when viewing own user account. $trail = $home; - $this->assertBreadcrumb('user/' . $this->web_user->id(), $trail, $this->web_user->getUsername()); + $this->assertBreadcrumb('user/' . $this->webUser->id(), $trail, $this->webUser->getUsername()); $trail += array( - 'user/' . $this->web_user->id() => $this->web_user->getUsername(), + 'user/' . $this->webUser->id() => $this->webUser->getUsername(), ); - $this->assertBreadcrumb('user/' . $this->web_user->id() . '/edit', $trail, $this->web_user->getUsername()); + $this->assertBreadcrumb('user/' . $this->webUser->id() . '/edit', $trail, $this->webUser->getUsername()); // Create an only slightly privileged user being able to access site reports // but not administration pages. - $this->web_user = $this->drupalCreateUser(array( + $this->webUser = $this->drupalCreateUser(array( 'access site reports', )); - $this->drupalLogin($this->web_user); + $this->drupalLogin($this->webUser); // Verify that we can access recent log entries, there is a corresponding // page title, and that the breadcrumb is just the Home link (because the diff --git a/core/modules/system/src/Tests/Menu/MenuRouterTest.php b/core/modules/system/src/Tests/Menu/MenuRouterTest.php index d9e943c72d5cd54e8e6a7f7ef0634e8367d5fcc4..c8ca38c47c0c82474e013ca98ea991a66ea4c055 100644 --- a/core/modules/system/src/Tests/Menu/MenuRouterTest.php +++ b/core/modules/system/src/Tests/Menu/MenuRouterTest.php @@ -22,21 +22,21 @@ class MenuRouterTest extends WebTestBase { * * @var array */ - public static $modules = array('block', 'menu_test', 'test_page_test'); + public static $modules = ['block', 'menu_test', 'test_page_test']; /** * Name of the administrative theme to use for tests. * * @var string */ - protected $admin_theme; + protected $adminTheme; /** * Name of the default theme to use for tests. * * @var string */ - protected $default_theme; + protected $defaultTheme; protected function setUp() { // Enable dummy module that implements hook_menu. @@ -240,14 +240,14 @@ public function testAuthUserUserLogin() { * Tests theme integration. */ public function testThemeIntegration() { - $this->default_theme = 'bartik'; - $this->admin_theme = 'seven'; + $this->defaultTheme = 'bartik'; + $this->adminTheme = 'seven'; $theme_handler = $this->container->get('theme_handler'); - $theme_handler->install(array($this->default_theme, $this->admin_theme)); + $theme_handler->install([$this->defaultTheme, $this->adminTheme]); $this->config('system.theme') - ->set('default', $this->default_theme) - ->set('admin', $this->admin_theme) + ->set('default', $this->defaultTheme) + ->set('admin', $this->adminTheme) ->save(); $this->doTestThemeCallbackMaintenanceMode(); diff --git a/core/modules/system/src/Tests/Module/ModuleTestBase.php b/core/modules/system/src/Tests/Module/ModuleTestBase.php index 4023b57afbb16c1194f2f6ee38d5d77eaab5d626..66a08b20101f3112287f147260dd0a3042eb319c 100644 --- a/core/modules/system/src/Tests/Module/ModuleTestBase.php +++ b/core/modules/system/src/Tests/Module/ModuleTestBase.php @@ -25,13 +25,13 @@ abstract class ModuleTestBase extends WebTestBase { */ public static $modules = array('system_test'); - protected $admin_user; + protected $adminUser; protected function setUp() { parent::setUp(); - $this->admin_user = $this->drupalCreateUser(array('access administration pages', 'administer modules')); - $this->drupalLogin($this->admin_user); + $this->adminUser = $this->drupalCreateUser(array('access administration pages', 'administer modules')); + $this->drupalLogin($this->adminUser); } /** diff --git a/core/modules/system/src/Tests/Pager/PagerTest.php b/core/modules/system/src/Tests/Pager/PagerTest.php index e3269fe8c49fb114883fe60bed07892c510c30df..d7dd6b61fa69a9364fa20a07d8b95629fb325e76 100644 --- a/core/modules/system/src/Tests/Pager/PagerTest.php +++ b/core/modules/system/src/Tests/Pager/PagerTest.php @@ -23,6 +23,13 @@ class PagerTest extends WebTestBase { */ public static $modules = array('dblog', 'pager_test'); + /** + * A user with permission to access site reports. + * + * @var \Drupal\user\UserInterface + */ + protected $adminUser; + protected $profile = 'testing'; protected function setUp() { @@ -34,10 +41,10 @@ protected function setUp() { $logger->debug($this->randomString()); } - $this->admin_user = $this->drupalCreateUser(array( + $this->adminUser = $this->drupalCreateUser(array( 'access site reports', )); - $this->drupalLogin($this->admin_user); + $this->drupalLogin($this->adminUser); } /** diff --git a/core/modules/system/src/Tests/System/AccessDeniedTest.php b/core/modules/system/src/Tests/System/AccessDeniedTest.php index 176564886ca01708755c191ddc969ac69ac5ce23..17cb9d50d299fa6b309637485bba910bb9335706 100644 --- a/core/modules/system/src/Tests/System/AccessDeniedTest.php +++ b/core/modules/system/src/Tests/System/AccessDeniedTest.php @@ -22,15 +22,15 @@ class AccessDeniedTest extends WebTestBase { * * @var array */ - public static $modules = array('block'); + public static $modules = ['block']; - protected $admin_user; + protected $adminUser; protected function setUp() { parent::setUp(); // Create an administrative user. - $this->admin_user = $this->drupalCreateUser(array('access administration pages', 'administer site configuration', 'link to any page', 'administer blocks')); + $this->adminUser = $this->drupalCreateUser(['access administration pages', 'administer site configuration', 'link to any page', 'administer blocks']); user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, array('access user profiles')); user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, array('access user profiles')); @@ -42,10 +42,10 @@ function testAccessDenied() { $this->assertResponse(403); // Use a custom 403 page. - $this->drupalLogin($this->admin_user); - $edit = array( - 'site_403' => 'user/' . $this->admin_user->id(), - ); + $this->drupalLogin($this->adminUser); + $edit = [ + 'site_403' => 'user/' . $this->adminUser->id(), + ]; $this->drupalPostForm('admin/config/system/site-information', $edit, t('Save configuration')); // Enable the user login block. @@ -54,14 +54,14 @@ function testAccessDenied() { // Log out and check that the user login block is shown on custom 403 pages. $this->drupalLogout(); $this->drupalGet('admin'); - $this->assertText($this->admin_user->getUsername(), 'Found the custom 403 page'); + $this->assertText($this->adminUser->getUsername(), 'Found the custom 403 page'); $this->assertText(t('Username'), 'Blocks are shown on the custom 403 page'); // Log back in and remove the custom 403 page. - $this->drupalLogin($this->admin_user); - $edit = array( + $this->drupalLogin($this->adminUser); + $edit = [ 'site_403' => '', - ); + ]; $this->drupalPostForm('admin/config/system/site-information', $edit, t('Save configuration')); // Logout and check that the user login block is shown on default 403 pages. @@ -72,18 +72,18 @@ function testAccessDenied() { $this->assertText(t('Username'), 'Blocks are shown on the default 403 page'); // Log back in, set the custom 403 page to /user/login and remove the block - $this->drupalLogin($this->admin_user); + $this->drupalLogin($this->adminUser); $this->config('system.site')->set('page.403', 'user/login')->save(); - $edit = array( + $edit = [ 'region' => -1, - ); + ]; $this->drupalPostForm('admin/structure/block/manage/login', $edit, t('Save block')); // Check that we can log in from the 403 page. $this->drupalLogout(); $edit = array( - 'name' => $this->admin_user->getUsername(), - 'pass' => $this->admin_user->pass_raw, + 'name' => $this->adminUser->getUsername(), + 'pass' => $this->adminUser->pass_raw, ); $this->drupalPostForm('admin/config/system/site-information', $edit, t('Log in')); diff --git a/core/modules/system/src/Tests/System/AdminTest.php b/core/modules/system/src/Tests/System/AdminTest.php index fee3cd9ba669ff65441619eff836a018cf24786d..ab14e8f72644b7f2343f391873d0aa5a0efb2cf5 100644 --- a/core/modules/system/src/Tests/System/AdminTest.php +++ b/core/modules/system/src/Tests/System/AdminTest.php @@ -22,14 +22,14 @@ class AdminTest extends WebTestBase { * * @var \Drupal\Core\Session\AccountInterface */ - protected $admin_user; + protected $adminUser; /** * User account with limited access to administration pages. * * @var \Drupal\Core\Session\AccountInterface */ - protected $web_user; + protected $webUser; /** * Modules to enable. @@ -45,12 +45,12 @@ protected function setUp() { // Create an administrator with all permissions, as well as a regular user // who can only access administration pages and perform some Locale module // administrative tasks, but not all of them. - $this->admin_user = $this->drupalCreateUser(array_keys(\Drupal::service('user.permissions')->getPermissions())); - $this->web_user = $this->drupalCreateUser(array( + $this->adminUser = $this->drupalCreateUser(array_keys(\Drupal::service('user.permissions')->getPermissions())); + $this->webUser = $this->drupalCreateUser(array( 'access administration pages', 'translate interface', )); - $this->drupalLogin($this->admin_user); + $this->drupalLogin($this->adminUser); } /** @@ -84,7 +84,7 @@ function testAdminPages() { // For the administrator, verify that there are links to Locale's primary // configuration pages, but no links to individual sub-configuration // pages. - $this->drupalLogin($this->admin_user); + $this->drupalLogin($this->adminUser); $this->drupalGet($page); $this->assertLinkByHref('admin/config'); $this->assertLinkByHref('admin/config/regional/settings'); @@ -101,7 +101,7 @@ function testAdminPages() { // For a less privileged user, verify that there are no links to Locale's // primary configuration pages, but a link to the translate page exists. - $this->drupalLogin($this->web_user); + $this->drupalLogin($this->webUser); $this->drupalGet($page); $this->assertLinkByHref('admin/config'); $this->assertNoLinkByHref('admin/config/regional/settings'); @@ -152,7 +152,7 @@ function testCompactMode() { // The front page defaults to 'user/login', which redirects to 'user/{user}' // for authenticated users. We cannot use '', since this does not // match the redirected url. - $frontpage_url = 'user/' . $this->admin_user->id(); + $frontpage_url = 'user/' . $this->adminUser->id(); $this->drupalGet('admin/compact/on'); $this->assertResponse(200, 'A valid page is returned after turning on compact mode.'); diff --git a/core/modules/system/src/Tests/System/DateTimeTest.php b/core/modules/system/src/Tests/System/DateTimeTest.php index 9176b1b639133c6cedc1d9788b2b089afcc49346..9f0b0ac750fd0c03274134f2ddbfaceaa7581dda 100644 --- a/core/modules/system/src/Tests/System/DateTimeTest.php +++ b/core/modules/system/src/Tests/System/DateTimeTest.php @@ -28,8 +28,7 @@ protected function setUp() { parent::setUp(); // Create admin user and log in admin user. - $this->admin_user = $this->drupalCreateUser(array('administer site configuration')); - $this->drupalLogin($this->admin_user); + $this->drupalLogin ($this->drupalCreateUser(array('administer site configuration'))); } /** diff --git a/core/modules/system/src/Tests/System/DefaultMobileMetaTagsTest.php b/core/modules/system/src/Tests/System/DefaultMobileMetaTagsTest.php index dd2ec04300a5688c9bea1fce3310f554cc43fa37..4232a88f230ba90305b10a6c2a51b0767b9c2fc7 100644 --- a/core/modules/system/src/Tests/System/DefaultMobileMetaTagsTest.php +++ b/core/modules/system/src/Tests/System/DefaultMobileMetaTagsTest.php @@ -16,9 +16,16 @@ * @group system */ class DefaultMobileMetaTagsTest extends WebTestBase { + /** + * Array of default meta tags to insert into the page. + * + * @var array + */ + protected $defaultMetaTags; + protected function setUp() { parent::setUp(); - $this->default_metatags = array( + $this->defaultMetaTags = array( 'viewport' => '', ); } @@ -28,7 +35,7 @@ protected function setUp() { */ public function testDefaultMetaTagsExist() { $this->drupalGet(''); - foreach ($this->default_metatags as $name => $metatag) { + foreach ($this->defaultMetaTags as $name => $metatag) { $this->assertRaw($metatag, SafeMarkup::format('Default Mobile meta tag "@name" displayed properly.', array('@name' => $name)), 'System'); } } @@ -39,7 +46,7 @@ public function testDefaultMetaTagsExist() { public function testRemovingDefaultMetaTags() { \Drupal::service('module_installer')->install(array('system_module_test')); $this->drupalGet(''); - foreach ($this->default_metatags as $name => $metatag) { + foreach ($this->defaultMetaTags as $name => $metatag) { $this->assertNoRaw($metatag, SafeMarkup::format('Default Mobile meta tag "@name" removed properly.', array('@name' => $name)), 'System'); } } diff --git a/core/modules/system/src/Tests/System/FrontPageTest.php b/core/modules/system/src/Tests/System/FrontPageTest.php index 0b9d75909d8ea111081ef281a39da7e5aad8eac2..bb0b10b17c702197d0be1c395ae7890708ea35cb 100644 --- a/core/modules/system/src/Tests/System/FrontPageTest.php +++ b/core/modules/system/src/Tests/System/FrontPageTest.php @@ -23,14 +23,23 @@ class FrontPageTest extends WebTestBase { */ public static $modules = array('node', 'system_test', 'views'); + /** + * The path to a node that is created for testing. + * + * @var string + */ + protected $nodePath; + protected function setUp() { parent::setUp(); // Create admin user, log in admin user, and create one node. - $this->admin_user = $this->drupalCreateUser(array('access content', 'administer site configuration')); - $this->drupalLogin($this->admin_user); + $this->drupalLogin ($this->drupalCreateUser(array( + 'access content', + 'administer site configuration', + ))); $this->drupalCreateContentType(array('type' => 'page')); - $this->node_path = "node/" . $this->drupalCreateNode(array('promote' => 1))->id(); + $this->nodePath = "node/" . $this->drupalCreateNode(array('promote' => 1))->id(); // Configure 'node' as front page. $this->config('system.site')->set('page.front', 'node')->save(); @@ -54,7 +63,7 @@ public function testDrupalFrontPage() { $this->assertText(t('On front page.'), 'Path is the front page.'); $this->drupalGet('node'); $this->assertText(t('On front page.'), 'Path is the front page.'); - $this->drupalGet($this->node_path); + $this->drupalGet($this->nodePath); $this->assertNoText(t('On front page.'), 'Path is not the front page.'); // Change the front page to an invalid path. @@ -63,7 +72,7 @@ public function testDrupalFrontPage() { $this->assertText(t("The path '@path' is either invalid or you do not have access to it.", array('@path' => $edit['site_frontpage']))); // Change the front page to a valid path. - $edit['site_frontpage'] = $this->node_path; + $edit['site_frontpage'] = $this->nodePath; $this->drupalPostForm('admin/config/system/site-information', $edit, t('Save configuration')); $this->assertText(t('The configuration options have been saved.'), 'The front page path has been saved.'); @@ -71,7 +80,7 @@ public function testDrupalFrontPage() { $this->assertText(t('On front page.'), 'Path is the front page.'); $this->drupalGet('node'); $this->assertNoText(t('On front page.'), 'Path is not the front page.'); - $this->drupalGet($this->node_path); + $this->drupalGet($this->nodePath); $this->assertText(t('On front page.'), 'Path is the front page.'); } } diff --git a/core/modules/system/src/Tests/System/MainContentFallbackTest.php b/core/modules/system/src/Tests/System/MainContentFallbackTest.php index ae10847cd102ef6c2a72d9639d7d355257f2ef10..a6ec81e74fb98c5ca4ff4d71ed3131cfd8cf4f75 100644 --- a/core/modules/system/src/Tests/System/MainContentFallbackTest.php +++ b/core/modules/system/src/Tests/System/MainContentFallbackTest.php @@ -23,22 +23,22 @@ class MainContentFallbackTest extends WebTestBase { */ public static $modules = array('block', 'system_test'); - protected $admin_user; - protected $web_user; + protected $adminUser; + protected $webUser; protected function setUp() { parent::setUp(); // Create and login admin user. - $this->admin_user = $this->drupalCreateUser(array( + $this->adminUser = $this->drupalCreateUser(array( 'access administration pages', 'administer site configuration', 'administer modules', )); - $this->drupalLogin($this->admin_user); + $this->drupalLogin($this->adminUser); // Create a web user. - $this->web_user = $this->drupalCreateUser(array('access user profiles')); + $this->webUser = $this->drupalCreateUser(array('access user profiles')); } /** @@ -62,12 +62,12 @@ function testMainContentFallback() { $this->drupalGet('system-test/main-content-fallback'); $this->assertText(t('Content to test main content fallback'), 'Fallback to SimplePageVariant works for front-end theme.'); // Request a user* page and see if it is displayed. - $this->drupalLogin($this->web_user); - $this->drupalGet('user/' . $this->web_user->id() . '/edit'); + $this->drupalLogin($this->webUser); + $this->drupalGet('user/' . $this->webUser->id() . '/edit'); $this->assertField('mail', 'User interface still available.'); // Enable the block module again. - $this->drupalLogin($this->admin_user); + $this->drupalLogin($this->adminUser); $edit = array(); $edit['modules[Core][block][enable]'] = 'block'; $this->drupalPostForm('admin/modules', $edit, t('Save configuration')); diff --git a/core/modules/system/src/Tests/System/PageNotFoundTest.php b/core/modules/system/src/Tests/System/PageNotFoundTest.php index 8a0a99dfbdcfbbdb2c64f180773daa0bf6644966..41b8ed654cbd4d972d3f977f4054792014481305 100644 --- a/core/modules/system/src/Tests/System/PageNotFoundTest.php +++ b/core/modules/system/src/Tests/System/PageNotFoundTest.php @@ -16,30 +16,30 @@ * @group system */ class PageNotFoundTest extends WebTestBase { - protected $admin_user; + protected $adminUser; protected function setUp() { parent::setUp(); // Create an administrative user. - $this->admin_user = $this->drupalCreateUser(array('administer site configuration', 'link to any page')); + $this->adminUser = $this->drupalCreateUser(array('administer site configuration', 'link to any page')); user_role_grant_permissions(RoleInterface::ANONYMOUS_ID, array('access user profiles')); user_role_grant_permissions(RoleInterface::AUTHENTICATED_ID, array('access user profiles')); } function testPageNotFound() { - $this->drupalLogin($this->admin_user); + $this->drupalLogin($this->adminUser); $this->drupalGet($this->randomMachineName(10)); $this->assertText(t('Page not found'), 'Found the default 404 page'); // Use a custom 404 page. $edit = array( - 'site_404' => 'user/' . $this->admin_user->id(), + 'site_404' => 'user/' . $this->adminUser->id(), ); $this->drupalPostForm('admin/config/system/site-information', $edit, t('Save configuration')); $this->drupalGet($this->randomMachineName(10)); - $this->assertText($this->admin_user->getUsername(), 'Found the custom 404 page'); + $this->assertText($this->adminUser->getUsername(), 'Found the custom 404 page'); } } diff --git a/core/modules/system/src/Tests/System/PageTitleTest.php b/core/modules/system/src/Tests/System/PageTitleTest.php index 2c6f62a50495bac092d3f3c76dc1b1be63a58def..1fef0a48638746a559e07d34051926518e80b4f0 100644 --- a/core/modules/system/src/Tests/System/PageTitleTest.php +++ b/core/modules/system/src/Tests/System/PageTitleTest.php @@ -25,8 +25,8 @@ class PageTitleTest extends WebTestBase { */ public static $modules = array('node', 'test_page_test', 'form_test'); - protected $content_user; - protected $saved_title; + protected $contentUser; + protected $savedTitle; /** * Implement setUp(). @@ -36,8 +36,8 @@ protected function setUp() { $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page')); - $this->content_user = $this->drupalCreateUser(array('create page content', 'access content', 'administer themes', 'administer site configuration', 'link to any page')); - $this->drupalLogin($this->content_user); + $this->contentUser = $this->drupalCreateUser(array('create page content', 'access content', 'administer themes', 'administer site configuration', 'link to any page')); + $this->drupalLogin($this->contentUser); } /** diff --git a/core/modules/system/src/Tests/System/SiteMaintenanceTest.php b/core/modules/system/src/Tests/System/SiteMaintenanceTest.php index 4b42674f2d34e37735bf66623354b821edaaa6e8..4ce0a828a920d007b3dfb98d83c4132ceb193db3 100644 --- a/core/modules/system/src/Tests/System/SiteMaintenanceTest.php +++ b/core/modules/system/src/Tests/System/SiteMaintenanceTest.php @@ -23,7 +23,7 @@ class SiteMaintenanceTest extends WebTestBase { */ public static $modules = array('node'); - protected $admin_user; + protected $adminUser; protected function setUp() { parent::setUp(); @@ -34,8 +34,8 @@ protected function setUp() { // Create a user allowed to access site in maintenance mode. $this->user = $this->drupalCreateUser(array('access site in maintenance mode')); // Create an administrative user. - $this->admin_user = $this->drupalCreateUser(array('administer site configuration', 'access site in maintenance mode')); - $this->drupalLogin($this->admin_user); + $this->adminUser = $this->drupalCreateUser(array('administer site configuration', 'access site in maintenance mode')); + $this->drupalLogin($this->adminUser); } /** @@ -102,7 +102,7 @@ protected function doTestSiteMaintenance() { // Log in administrative user and configure a custom site offline message. $this->drupalLogout(); - $this->drupalLogin($this->admin_user); + $this->drupalLogin($this->adminUser); $this->drupalGet('admin/config/development/maintenance'); $this->assertNoRaw($admin_message, 'Site maintenance mode message not displayed.'); diff --git a/core/modules/system/src/Tests/System/SystemAuthorizeTest.php b/core/modules/system/src/Tests/System/SystemAuthorizeTest.php index cbc359af3eeb437a2d67baf17852d283ca478acf..3632efa611a3c0b3a2dcb15b0bc8044f3d692988 100644 --- a/core/modules/system/src/Tests/System/SystemAuthorizeTest.php +++ b/core/modules/system/src/Tests/System/SystemAuthorizeTest.php @@ -27,8 +27,7 @@ protected function setUp() { parent::setUp(); // Create an administrator user. - $this->admin_user = $this->drupalCreateUser(array('administer software updates')); - $this->drupalLogin($this->admin_user); + $this->drupalLogin ($this->drupalCreateUser(array('administer software updates'))); } /** diff --git a/core/modules/system/src/Tests/System/ThemeTest.php b/core/modules/system/src/Tests/System/ThemeTest.php index ccfc72711ea37ccf1bdd8fa18e275aeb2cba5461..d5bb6f6f222ae94d2fc1686226fa6da8ff21a976 100644 --- a/core/modules/system/src/Tests/System/ThemeTest.php +++ b/core/modules/system/src/Tests/System/ThemeTest.php @@ -18,6 +18,13 @@ */ class ThemeTest extends WebTestBase { + /** + * A user with administrative permissions. + * + * @var \Drupal\user\UserInterface + */ + protected $adminUser; + /** * Modules to enable. * @@ -30,8 +37,8 @@ protected function setUp() { $this->drupalCreateContentType(array('type' => 'page', 'name' => 'Basic page')); - $this->admin_user = $this->drupalCreateUser(array('access administration pages', 'view the administration theme', 'administer themes', 'bypass node access', 'administer blocks')); - $this->drupalLogin($this->admin_user); + $this->adminUser = $this->drupalCreateUser(array('access administration pages', 'view the administration theme', 'administer themes', 'bypass node access', 'administer blocks')); + $this->drupalLogin($this->adminUser); $this->node = $this->drupalCreateNode(); } @@ -215,7 +222,7 @@ function testAdministrationTheme() { $this->drupalGet('admin/config'); $this->assertResponse(403); $this->assertRaw('core/themes/seven', 'Administration theme used on an administration page.'); - $this->drupalLogin($this->admin_user); + $this->drupalLogin($this->adminUser); $this->drupalGet('node/add'); $this->assertRaw('core/themes/classy', 'Site default theme used on the add content page.'); diff --git a/core/modules/system/src/Tests/Theme/EntityFilteringThemeTest.php b/core/modules/system/src/Tests/Theme/EntityFilteringThemeTest.php index 10b52e51032720394393bbff5b2392753342e687..5c90c822356a0d77a42443de7b91f25b300529fb 100644 --- a/core/modules/system/src/Tests/Theme/EntityFilteringThemeTest.php +++ b/core/modules/system/src/Tests/Theme/EntityFilteringThemeTest.php @@ -76,7 +76,7 @@ class EntityFilteringThemeTest extends WebTestBase { * * @string */ - protected $xss_label = "string with HTML and "; + protected $xssLabel = "string with HTML and "; protected function setUp() { parent::setUp(); @@ -88,13 +88,13 @@ protected function setUp() { // Create a test user. $this->user = $this->drupalCreateUser(array('access content', 'access user profiles')); - $this->user->name = $this->xss_label; + $this->user->name = $this->xssLabel; $this->user->save(); $this->drupalLogin($this->user); // Create a test term. $this->term = entity_create('taxonomy_term', array( - 'name' => $this->xss_label, + 'name' => $this->xssLabel, 'vid' => 1, )); $this->term->save(); @@ -103,7 +103,7 @@ protected function setUp() { $this->addDefaultCommentField('node', 'article', 'comment', CommentItemInterface::OPEN); // Create a test node tagged with the test term. $this->node = $this->drupalCreateNode(array( - 'title' => $this->xss_label, + 'title' => $this->xssLabel, 'type' => 'article', 'promote' => NODE_PROMOTED, 'field_tags' => array(array('target_id' => $this->term->id())), @@ -115,7 +115,7 @@ protected function setUp() { 'entity_type' => 'node', 'field_name' => 'comment', 'status' => CommentInterface::PUBLISHED, - 'subject' => $this->xss_label, + 'subject' => $this->xssLabel, 'comment_body' => array($this->randomMachineName()), )); $this->comment->save(); @@ -141,7 +141,7 @@ function testThemedEntity() { foreach ($paths as $path) { $this->drupalGet($path); $this->assertResponse(200); - $this->assertNoRaw($this->xss_label); + $this->assertNoRaw($this->xssLabel); } } } diff --git a/core/modules/system/src/Tests/Theme/TwigTransTest.php b/core/modules/system/src/Tests/Theme/TwigTransTest.php index 85ba19a22fcf6f5fbddd68d0377f97a05963e8cf..08057dc1b2fb5d749ef81140cfc5a556e95e3992 100644 --- a/core/modules/system/src/Tests/Theme/TwigTransTest.php +++ b/core/modules/system/src/Tests/Theme/TwigTransTest.php @@ -35,7 +35,7 @@ class TwigTransTest extends WebTestBase { * * @var \Drupal\user\Entity\User */ - protected $admin_user; + protected $adminUser; /** * Custom languages. @@ -58,13 +58,13 @@ protected function setUp() { $this->config('system.theme')->set('default', 'test_theme')->save(); // Create and log in as admin. - $this->admin_user = $this->drupalCreateUser(array( + $this->adminUser = $this->drupalCreateUser(array( 'administer languages', 'access administration pages', 'administer site configuration', 'translate interface' )); - $this->drupalLogin($this->admin_user); + $this->drupalLogin($this->adminUser); // Install languages. $this->installLanguages(); diff --git a/core/modules/system/src/Tests/Update/InvalidUpdateHookTest.php b/core/modules/system/src/Tests/Update/InvalidUpdateHookTest.php index 228d62c71d0a44be2d89f2128c24d68fbfd35c5c..84c75d800dc293cc4062dd1c4392cbb748a284f4 100644 --- a/core/modules/system/src/Tests/Update/InvalidUpdateHookTest.php +++ b/core/modules/system/src/Tests/Update/InvalidUpdateHookTest.php @@ -30,27 +30,27 @@ class InvalidUpdateHookTest extends WebTestBase { * * @var string */ - private $update_url; + private $updateUrl; /** * A user account with upgrade permission. * * @var \Drupal\user\UserInterface */ - private $update_user; + private $updateUser; protected function setUp() { parent::setUp(); require_once \Drupal::root() . '/core/includes/update.inc'; - $this->update_url = $GLOBALS['base_url'] . '/update.php'; - $this->update_user = $this->drupalCreateUser(array('administer software updates')); + $this->updateUrl = $GLOBALS['base_url'] . '/update.php'; + $this->updateUser = $this->drupalCreateUser(array('administer software updates')); } function testInvalidUpdateHook() { // Confirm that a module with hook_update_8000() cannot be updated. - $this->drupalLogin($this->update_user); - $this->drupalGet($this->update_url); + $this->drupalLogin($this->updateUser); + $this->drupalGet($this->updateUrl); $this->clickLink(t('Continue')); $this->assertText(t('Some of the pending updates cannot be applied because their dependencies were not met.')); } diff --git a/core/modules/system/src/Tests/Update/UpdateScriptTest.php b/core/modules/system/src/Tests/Update/UpdateScriptTest.php index 2da975fb5c3ee19a015aa223526ea8edd17abac9..83db3fb488fa890010253e87a9f8315371d54385 100644 --- a/core/modules/system/src/Tests/Update/UpdateScriptTest.php +++ b/core/modules/system/src/Tests/Update/UpdateScriptTest.php @@ -23,16 +23,29 @@ class UpdateScriptTest extends WebTestBase { */ public static $modules = array('update_script_test', 'dblog'); + /** + * {@inheritdoc} + */ protected $dumpHeaders = TRUE; - private $update_url; - private $update_user; + /** + * URL to the update.php script. + * + * @var string + */ + private $updateUrl; + + /** + * A user with the necessary permissions to administer software updates. + * + * @var \Drupal\user\UserInterface + */ + private $updateUser; protected function setUp() { parent::setUp(); - $this->update_url = $GLOBALS['base_url'] . '/update.php'; - $this->update_user = $this->drupalCreateUser(array('administer software updates', 'access site in maintenance mode')); - // Make sure updates for new entity type definitions are processed. + $this->updateUrl = $GLOBALS['base_url'] . '/update.php'; + $this->updateUser = $this->drupalCreateUser(array('administer software updates', 'access site in maintenance mode')); \Drupal::service('entity.definition_update_manager')->applyUpdates(); } @@ -43,22 +56,22 @@ function testUpdateAccess() { // Try accessing update.php without the proper permission. $regular_user = $this->drupalCreateUser(); $this->drupalLogin($regular_user); - $this->drupalGet($this->update_url, array('external' => TRUE)); + $this->drupalGet($this->updateUrl, array('external' => TRUE)); $this->assertResponse(403); // Try accessing update.php as an anonymous user. $this->drupalLogout(); - $this->drupalGet($this->update_url, array('external' => TRUE)); + $this->drupalGet($this->updateUrl, array('external' => TRUE)); $this->assertResponse(403); // Access the update page with the proper permission. - $this->drupalLogin($this->update_user); - $this->drupalGet($this->update_url, array('external' => TRUE)); + $this->drupalLogin($this->updateUser); + $this->drupalGet($this->updateUrl, array('external' => TRUE)); $this->assertResponse(200); // Access the update page as user 1. $this->drupalLogin($this->rootUser); - $this->drupalGet($this->update_url, array('external' => TRUE)); + $this->drupalGet($this->updateUrl, array('external' => TRUE)); $this->assertResponse(200); } @@ -67,11 +80,11 @@ function testUpdateAccess() { */ function testRequirements() { $update_script_test_config = $this->config('update_script_test.settings'); - $this->drupalLogin($this->update_user); + $this->drupalLogin($this->updateUser); // If there are no requirements warnings or errors, we expect to be able to // go through the update process uninterrupted. - $this->drupalGet($this->update_url, array('external' => TRUE)); + $this->drupalGet($this->updateUrl, array('external' => TRUE)); $this->clickLink(t('Continue')); $this->assertText(t('No pending updates.'), 'End of update process was reached.'); // Confirm that all caches were cleared. @@ -85,7 +98,7 @@ function testRequirements() { // successfully. $update_script_test_config->set('requirement_type', REQUIREMENT_WARNING)->save(); drupal_set_installed_schema_version('update_script_test', drupal_get_installed_schema_version('update_script_test') - 1); - $this->drupalGet($this->update_url, array('external' => TRUE)); + $this->drupalGet($this->updateUrl, array('external' => TRUE)); $this->assertText('This is a requirements warning provided by the update_script_test module.'); $this->clickLink('try again'); $this->assertNoText('This is a requirements warning provided by the update_script_test module.'); @@ -96,7 +109,7 @@ function testRequirements() { $this->assertText(t('hook_cache_flush() invoked for update_script_test.module.'), 'Caches were cleared after resolving a requirements warning and applying updates.'); // Now try again without pending updates to make sure that works too. - $this->drupalGet($this->update_url, array('external' => TRUE)); + $this->drupalGet($this->updateUrl, array('external' => TRUE)); $this->assertText('This is a requirements warning provided by the update_script_test module.'); $this->clickLink('try again'); $this->assertNoText('This is a requirements warning provided by the update_script_test module.'); @@ -109,7 +122,7 @@ function testRequirements() { // clicking the link to proceed (since the problem that triggered the error // has not been fixed). $update_script_test_config->set('requirement_type', REQUIREMENT_ERROR)->save(); - $this->drupalGet($this->update_url, array('external' => TRUE)); + $this->drupalGet($this->updateUrl, array('external' => TRUE)); $this->assertText('This is a requirements error provided by the update_script_test module.'); $this->clickLink('try again'); $this->assertText('This is a requirements error provided by the update_script_test module.'); @@ -123,8 +136,8 @@ function testThemeSystem() { // unusual maintenance mode environment, we check that this rebuild did not // put any incorrect information about the themes into the database. $original_theme_data = $this->config('core.extension')->get('theme'); - $this->drupalLogin($this->update_user); - $this->drupalGet($this->update_url, array('external' => TRUE)); + $this->drupalLogin($this->updateUser); + $this->drupalGet($this->updateUrl, ['external' => TRUE]); $final_theme_data = $this->config('core.extension')->get('theme'); $this->assertEqual($original_theme_data, $final_theme_data, 'Visiting update.php does not alter the information about themes stored in the database.'); } @@ -134,8 +147,8 @@ function testThemeSystem() { */ function testNoUpdateFunctionality() { // Click through update.php with 'administer software updates' permission. - $this->drupalLogin($this->update_user); - $this->drupalGet($this->update_url, array('external' => TRUE)); + $this->drupalLogin($this->updateUser); + $this->drupalGet($this->updateUrl, array('external' => TRUE)); $this->clickLink(t('Continue')); $this->assertText(t('No pending updates.')); $this->assertNoLink('Administration pages'); @@ -146,7 +159,7 @@ function testNoUpdateFunctionality() { // Click through update.php with 'access administration pages' permission. $admin_user = $this->drupalCreateUser(array('administer software updates', 'access administration pages')); $this->drupalLogin($admin_user); - $this->drupalGet($this->update_url, array('external' => TRUE)); + $this->drupalGet($this->updateUrl, array('external' => TRUE)); $this->clickLink(t('Continue')); $this->assertText(t('No pending updates.')); $this->assertLink('Administration pages'); @@ -168,8 +181,8 @@ function testSuccessfulUpdateFunctionality() { $this->assertEqual($schema_version, 8000, 'update_script_test schema version overridden to 8000.'); // Click through update.php with 'administer software updates' permission. - $this->drupalLogin($this->update_user); - $this->drupalGet($this->update_url, array('external' => TRUE)); + $this->drupalLogin($this->updateUser); + $this->drupalGet($this->updateUrl, array('external' => TRUE)); $this->clickLink(t('Continue')); $this->clickLink(t('Apply pending updates')); @@ -204,7 +217,7 @@ function testSuccessfulUpdateFunctionality() { // 'access site reports' permissions. $admin_user = $this->drupalCreateUser(array('administer software updates', 'access administration pages', 'access site reports', 'access site in maintenance mode')); $this->drupalLogin($admin_user); - $this->drupalGet($this->update_url, array('external' => TRUE)); + $this->drupalGet($this->updateUrl, array('external' => TRUE)); $this->clickLink(t('Continue')); $this->clickLink(t('Apply pending updates')); $this->assertText('Updates were attempted.'); diff --git a/core/modules/system/src/Tests/Update/UpdatesWith7xTest.php b/core/modules/system/src/Tests/Update/UpdatesWith7xTest.php index 09daad3b9b6e4d00db100805f1ceb64b986471bb..288533e25bc4ac72b08c6f0a6433776bf7e063aa 100644 --- a/core/modules/system/src/Tests/Update/UpdatesWith7xTest.php +++ b/core/modules/system/src/Tests/Update/UpdatesWith7xTest.php @@ -27,18 +27,18 @@ class UpdatesWith7xTest extends WebTestBase { /** * The URL for the update page. */ - private $update_url; + private $updateUrl; /** * An administrative user. */ - private $update_user; + private $updateUser; protected function setUp() { parent::setUp(); require_once \Drupal::root() . '/core/includes/update.inc'; - $this->update_url = $GLOBALS['base_url'] . '/update.php'; - $this->update_user = $this->drupalCreateUser(array('administer software updates')); + $this->updateUrl = $GLOBALS['base_url'] . '/update.php'; + $this->updateUser = $this->drupalCreateUser(array('administer software updates')); } function testWith7x() { @@ -51,8 +51,8 @@ function testWith7x() { drupal_set_installed_schema_version('update_test_with_7x', 7110); // Click through update.php with 'administer software updates' permission. - $this->drupalLogin($this->update_user); - $this->drupalGet($this->update_url, array('external' => TRUE)); + $this->drupalLogin($this->updateUser); + $this->drupalGet($this->updateUrl, array('external' => TRUE)); $this->clickLink(t('Continue')); $this->assertText(t('Some of the pending updates cannot be applied because their dependencies were not met.')); }