diff --git a/core/modules/field/src/Tests/Boolean/BooleanFieldTest.php b/core/modules/field/src/Tests/Boolean/BooleanFieldTest.php index 5f027a436ed80e5588956ef5495c283db04c0316..28f6334dd2dd2f7e3fc09c5bc5ee73e51f323758 100644 --- a/core/modules/field/src/Tests/Boolean/BooleanFieldTest.php +++ b/core/modules/field/src/Tests/Boolean/BooleanFieldTest.php @@ -31,7 +31,7 @@ class BooleanFieldTest extends WebTestBase { * * @var \Drupal\field\Entity\FieldStorageConfig */ - protected $field_storage; + protected $fieldStorage; /** * The field used in this test class. @@ -46,13 +46,12 @@ class BooleanFieldTest extends WebTestBase { protected function setUp() { parent::setUp(); - $this->web_user = $this->drupalCreateUser(array( + $this->drupalLogin($this->drupalCreateUser(array( 'view test entity', 'administer entity_test content', 'administer entity_test form display', 'administer entity_test fields', - )); - $this->drupalLogin($this->web_user); + ))); } /** @@ -65,12 +64,12 @@ function testBooleanField() { // Create a field with settings to validate. $field_name = Unicode::strtolower($this->randomMachineName()); - $this->field_storage = FieldStorageConfig::create(array( + $this->fieldStorage = FieldStorageConfig::create(array( 'field_name' => $field_name, 'entity_type' => 'entity_test', 'type' => 'boolean', )); - $this->field_storage->save(); + $this->fieldStorage->save(); $this->field = FieldConfig::create(array( 'field_name' => $field_name, 'entity_type' => 'entity_test', diff --git a/core/modules/field/src/Tests/BulkDeleteTest.php b/core/modules/field/src/Tests/BulkDeleteTest.php index fdffb7edc3decc279872a7f19e032136b416fb73..de49be1d5e874de9d534977b8a6f8a6f011e4306 100644 --- a/core/modules/field/src/Tests/BulkDeleteTest.php +++ b/core/modules/field/src/Tests/BulkDeleteTest.php @@ -36,7 +36,7 @@ class BulkDeleteTest extends FieldUnitTestBase { * * @var array */ - protected $entities_by_bundles; + protected $entitiesByBundles; /** * The bundles for the entities used in this test. @@ -48,9 +48,9 @@ class BulkDeleteTest extends FieldUnitTestBase { /** * The entity type to be used in the test classes. * - * @var array + * @var string */ - protected $entity_type = 'entity_test'; + protected $entityTypeId = 'entity_test'; /** * Tests that the expected hooks have been invoked on the expected entities. @@ -96,7 +96,7 @@ protected function setUp() { $this->fieldStorages = array(); $this->entities = array(); - $this->entities_by_bundles = array(); + $this->entitiesByBundles = array(); // Create two bundles. $this->bundles = array('bb_1' => 'bb_1', 'bb_2' => 'bb_2'); @@ -107,7 +107,7 @@ protected function setUp() { // Create two field storages. $field_storage = entity_create('field_storage_config', array( 'field_name' => 'bf_1', - 'entity_type' => $this->entity_type, + 'entity_type' => $this->entityTypeId, 'type' => 'test_field', 'cardinality' => 1 )); @@ -115,7 +115,7 @@ protected function setUp() { $this->fieldStorages[] = $field_storage; $field_storage = entity_create('field_storage_config', array( 'field_name' => 'bf_2', - 'entity_type' => $this->entity_type, + 'entity_type' => $this->entityTypeId, 'type' => 'test_field', 'cardinality' => 4 )); @@ -132,14 +132,14 @@ protected function setUp() { ))->save(); } for ($i = 0; $i < 10; $i++) { - $entity = entity_create($this->entity_type, array('type' => $bundle)); + $entity = entity_create($this->entityTypeId, array('type' => $bundle)); foreach ($this->fieldStorages as $field_storage) { $entity->{$field_storage->getName()}->setValue($this->_generateTestFieldValues($field_storage->getCardinality())); } $entity->save(); } } - $this->entities = entity_load_multiple($this->entity_type); + $this->entities = entity_load_multiple($this->entityTypeId); foreach ($this->entities as $entity) { // This test relies on the entities having stale field definitions // so that the deleted field can be accessed on them. Access the field @@ -147,7 +147,7 @@ protected function setUp() { $entity->bf_1->value; // Also keep track of the entities per bundle. - $this->entities_by_bundles[$entity->bundle()][$entity->id()] = $entity; + $this->entitiesByBundles[$entity->bundle()][$entity->id()] = $entity; } } @@ -172,7 +172,7 @@ function testDeleteField() { $this->assertEqual(count($found), 10, 'Correct number of entities found before deleting'); // Delete the field. - $field = FieldConfig::loadByName($this->entity_type, $bundle, $field_name); + $field = FieldConfig::loadByName($this->entityTypeId, $bundle, $field_name); $field->delete(); // The field still exists, deleted. @@ -182,7 +182,7 @@ function testDeleteField() { $this->assertEqual($field->bundle, $bundle, 'The deleted field is for the correct bundle'); // Check that the actual stored content did not change during delete. - $storage = \Drupal::entityManager()->getStorage($this->entity_type); + $storage = \Drupal::entityManager()->getStorage($this->entityTypeId); /** @var \Drupal\Core\Entity\Sql\DefaultTableMapping $table_mapping */ $table_mapping = $storage->getTableMapping(); $table = $table_mapping->getDedicatedDataTableName($field_storage); @@ -225,7 +225,7 @@ function testPurgeField() { $field_name = $field_storage->getName(); // Delete the field. - $field = FieldConfig::loadByName($this->entity_type, $bundle, $field_name); + $field = FieldConfig::loadByName($this->entityTypeId, $bundle, $field_name); $field->delete(); // No field hooks were called. @@ -250,7 +250,7 @@ function testPurgeField() { // bundle. $actual_hooks = field_test_memorize(); $hooks = array(); - $entities = $this->entities_by_bundles[$bundle]; + $entities = $this->entitiesByBundles[$bundle]; foreach ($entities as $id => $entity) { $hooks['field_test_field_delete'][] = $entity; } @@ -286,7 +286,7 @@ function testPurgeFieldStorage() { // Delete the first field. $bundle = reset($this->bundles); - $field = FieldConfig::loadByName($this->entity_type, $bundle, $field_name); + $field = FieldConfig::loadByName($this->entityTypeId, $bundle, $field_name); $field->delete(); // Assert that FieldItemInterface::delete() was not called yet. @@ -301,7 +301,7 @@ function testPurgeFieldStorage() { // bundle. $actual_hooks = field_test_memorize(); $hooks = array(); - $entities = $this->entities_by_bundles[$bundle]; + $entities = $this->entitiesByBundles[$bundle]; foreach ($entities as $id => $entity) { $hooks['field_test_field_delete'][] = $entity; } @@ -323,7 +323,7 @@ function testPurgeFieldStorage() { // Delete the second field. $bundle = next($this->bundles); - $field = FieldConfig::loadByName($this->entity_type, $bundle, $field_name); + $field = FieldConfig::loadByName($this->entityTypeId, $bundle, $field_name); $field->delete(); // Assert that FieldItemInterface::delete() was not called yet. @@ -336,7 +336,7 @@ function testPurgeFieldStorage() { // Check hooks invocations (same as above, for the 2nd bundle). $actual_hooks = field_test_memorize(); $hooks = array(); - $entities = $this->entities_by_bundles[$bundle]; + $entities = $this->entitiesByBundles[$bundle]; foreach ($entities as $id => $entity) { $hooks['field_test_field_delete'][] = $entity; } diff --git a/core/modules/field/src/Tests/DisplayApiTest.php b/core/modules/field/src/Tests/DisplayApiTest.php index 4123ab31ee3112c83f7f473c97a88980b4d14c97..a8ff4c0ecdd749b8d042b21a3c2735a0d2f79eee 100644 --- a/core/modules/field/src/Tests/DisplayApiTest.php +++ b/core/modules/field/src/Tests/DisplayApiTest.php @@ -21,7 +21,7 @@ class DisplayApiTest extends FieldUnitTestBase { * * @var string */ - protected $field_name; + protected $fieldName; /** * The field label to use in this test. @@ -42,7 +42,7 @@ class DisplayApiTest extends FieldUnitTestBase { * * @var array */ - protected $display_options; + protected $displayOptions; /** * The test entity. @@ -62,24 +62,24 @@ protected function setUp() { parent::setUp(); // Create a field and its storage. - $this->field_name = 'test_field'; + $this->fieldName = 'test_field'; $this->label = $this->randomMachineName(); $this->cardinality = 4; $field_storage = array( - 'field_name' => $this->field_name, + 'field_name' => $this->fieldName, 'entity_type' => 'entity_test', 'type' => 'test_field', 'cardinality' => $this->cardinality, ); $field = array( - 'field_name' => $this->field_name, + 'field_name' => $this->fieldName, 'entity_type' => 'entity_test', 'bundle' => 'entity_test', 'label' => $this->label, ); - $this->display_options = array( + $this->displayOptions = array( 'default' => array( 'type' => 'field_test_default', 'settings' => array( @@ -98,18 +98,18 @@ protected function setUp() { entity_create('field_config', $field)->save(); // Create a display for the default view mode. entity_get_display($field['entity_type'], $field['bundle'], 'default') - ->setComponent($this->field_name, $this->display_options['default']) + ->setComponent($this->fieldName, $this->displayOptions['default']) ->save(); // Create a display for the teaser view mode. EntityViewMode::create(array('id' => 'entity_test.teaser', 'targetEntityType' => 'entity_test'))->save(); entity_get_display($field['entity_type'], $field['bundle'], 'teaser') - ->setComponent($this->field_name, $this->display_options['teaser']) + ->setComponent($this->fieldName, $this->displayOptions['teaser']) ->save(); // Create an entity with values. $this->values = $this->_generateTestFieldValues($this->cardinality); $this->entity = entity_create('entity_test'); - $this->entity->{$this->field_name}->setValue($this->values); + $this->entity->{$this->fieldName}->setValue($this->values); $this->entity->save(); } @@ -117,7 +117,7 @@ protected function setUp() { * Tests the FieldItemListInterface::view() method. */ function testFieldItemListView() { - $items = $this->entity->get($this->field_name); + $items = $this->entity->get($this->fieldName); // No display settings: check that default display settings are used. $build = $items->view(); @@ -192,7 +192,7 @@ function testFieldItemListView() { // are used. $build = $items->view('teaser'); $this->render($build); - $setting = $this->display_options['teaser']['settings']['test_formatter_setting']; + $setting = $this->displayOptions['teaser']['settings']['test_formatter_setting']; $this->assertText($this->label, 'Label was displayed.'); foreach ($this->values as $delta => $value) { $this->assertText($setting . '|' . $value['value'], format_string('Value @delta was displayed with expected setting.', array('@delta' => $delta))); @@ -202,7 +202,7 @@ function testFieldItemListView() { // are used. $build = $items->view('unknown_view_mode'); $this->render($build); - $setting = $this->display_options['default']['settings']['test_formatter_setting']; + $setting = $this->displayOptions['default']['settings']['test_formatter_setting']; $this->assertText($this->label, 'Label was displayed.'); foreach ($this->values as $delta => $value) { $this->assertText($setting . '|' . $value['value'], format_string('Value @delta was displayed with expected setting.', array('@delta' => $delta))); @@ -217,7 +217,7 @@ function testFieldItemView() { $settings = \Drupal::service('plugin.manager.field.formatter')->getDefaultSettings('field_test_default'); $setting = $settings['test_formatter_setting']; foreach ($this->values as $delta => $value) { - $item = $this->entity->{$this->field_name}[$delta]; + $item = $this->entity->{$this->fieldName}[$delta]; $build = $item->view(); $this->render($build); $this->assertText($setting . '|' . $value['value'], format_string('Value @delta was displayed with expected setting.', array('@delta' => $delta))); @@ -232,7 +232,7 @@ function testFieldItemView() { ); $setting = $display['settings']['test_formatter_setting_multiple']; foreach ($this->values as $delta => $value) { - $item = $this->entity->{$this->field_name}[$delta]; + $item = $this->entity->{$this->fieldName}[$delta]; $build = $item->view($display); $this->render($build); $this->assertText($setting . '|0:' . $value['value'], format_string('Value @delta was displayed with expected setting.', array('@delta' => $delta))); @@ -247,16 +247,16 @@ function testFieldItemView() { ); $setting = $display['settings']['test_formatter_setting_additional']; foreach ($this->values as $delta => $value) { - $item = $this->entity->{$this->field_name}[$delta]; + $item = $this->entity->{$this->fieldName}[$delta]; $build = $item->view($display); $this->render($build); $this->assertText($setting . '|' . $value['value'] . '|' . ($value['value'] + 1), format_string('Value @delta was displayed with expected setting.', array('@delta' => $delta))); } // View mode: check that display settings specified in the field are used. - $setting = $this->display_options['teaser']['settings']['test_formatter_setting']; + $setting = $this->displayOptions['teaser']['settings']['test_formatter_setting']; foreach ($this->values as $delta => $value) { - $item = $this->entity->{$this->field_name}[$delta]; + $item = $this->entity->{$this->fieldName}[$delta]; $build = $item->view('teaser'); $this->render($build); $this->assertText($setting . '|' . $value['value'], format_string('Value @delta was displayed with expected setting.', array('@delta' => $delta))); @@ -264,9 +264,9 @@ function testFieldItemView() { // Unknown view mode: check that display settings for 'default' view mode // are used. - $setting = $this->display_options['default']['settings']['test_formatter_setting']; + $setting = $this->displayOptions['default']['settings']['test_formatter_setting']; foreach ($this->values as $delta => $value) { - $item = $this->entity->{$this->field_name}[$delta]; + $item = $this->entity->{$this->fieldName}[$delta]; $build = $item->view('unknown_view_mode'); $this->render($build); $this->assertText($setting . '|' . $value['value'], format_string('Value @delta was displayed with expected setting.', array('@delta' => $delta))); @@ -287,16 +287,16 @@ function testFieldEmpty() { ); // $this->entity is set by the setUp() method and by default contains 4 // numeric values. We only want to test the display of this one field. - $build = $this->entity->get($this->field_name)->view($display); + $build = $this->entity->get($this->fieldName)->view($display); $this->render($build); // The test field by default contains values, so should not display the // default "empty" text. $this->assertNoText($display['settings']['test_empty_string']); // Now remove the values from the test field and retest. - $this->entity->{$this->field_name} = array(); + $this->entity->{$this->fieldName} = array(); $this->entity->save(); - $build = $this->entity->get($this->field_name)->view($display); + $build = $this->entity->get($this->fieldName)->view($display); $this->render($build); // This time, as the field values have been removed, we *should* show the // default "empty" text. diff --git a/core/modules/field/src/Tests/Email/EmailFieldTest.php b/core/modules/field/src/Tests/Email/EmailFieldTest.php index 55adf48875c80010353fb044ac13947e4d35ba25..169d067e63884a7b713e1719b4f7a0ad66406f14 100644 --- a/core/modules/field/src/Tests/Email/EmailFieldTest.php +++ b/core/modules/field/src/Tests/Email/EmailFieldTest.php @@ -41,12 +41,11 @@ class EmailFieldTest extends WebTestBase { protected function setUp() { parent::setUp(); - $this->web_user = $this->drupalCreateUser(array( + $this->drupalLogin($this->drupalCreateUser(array( 'view test entity', 'administer entity_test content', 'administer content types', - )); - $this->drupalLogin($this->web_user); + ))); } /** diff --git a/core/modules/field/src/Tests/FieldAccessTest.php b/core/modules/field/src/Tests/FieldAccessTest.php index 4b067a8caa41e15646721b0d77d98a964d1ff590..a633fac0bf6b660c646e7835290da84345e1f1bf 100644 --- a/core/modules/field/src/Tests/FieldAccessTest.php +++ b/core/modules/field/src/Tests/FieldAccessTest.php @@ -33,7 +33,7 @@ class FieldAccessTest extends FieldTestBase { * * @var string */ - protected $test_view_field_value; + protected $testViewFieldValue; protected function setUp() { parent::setUp(); @@ -66,11 +66,11 @@ protected function setUp() { } // Create test node. - $this->test_view_field_value = 'This is some text'; + $this->testViewFieldValue = 'This is some text'; $settings = array(); $settings['type'] = $content_type; $settings['title'] = 'Field view access test'; - $settings['test_view_field'] = array(array('value' => $this->test_view_field_value)); + $settings['test_view_field'] = array(array('value' => $this->testViewFieldValue)); $this->node = $this->drupalCreateNode($settings); } @@ -81,13 +81,13 @@ function testFieldAccess() { // Assert the text is visible. $this->drupalGet('node/' . $this->node->id()); - $this->assertText($this->test_view_field_value); + $this->assertText($this->testViewFieldValue); // Assert the text is not visible for anonymous users. // The field_test module implements hook_entity_field_access() which will // specifically target the 'test_view_field' field. $this->drupalLogout(); $this->drupalGet('node/' . $this->node->id()); - $this->assertNoText($this->test_view_field_value); + $this->assertNoText($this->testViewFieldValue); } } diff --git a/core/modules/field/src/Tests/FieldDataCountTest.php b/core/modules/field/src/Tests/FieldDataCountTest.php index 2a14652ebe97807cbfc8a945f647d211ac3a742f..ebf0591defc8eed1611743bd143260ecc6a3b1d4 100644 --- a/core/modules/field/src/Tests/FieldDataCountTest.php +++ b/core/modules/field/src/Tests/FieldDataCountTest.php @@ -27,7 +27,7 @@ class FieldDataCountTest extends FieldUnitTestBase { /** * @var \Drupal\Core\Entity\DynamicallyFieldableEntityStorageInterface */ - protected $storage_rev; + protected $storageRev; /** * {@inheritdoc} @@ -36,7 +36,7 @@ protected function setUp() { parent::setUp(); $this->installEntitySchema('entity_test_rev'); $this->storage = \Drupal::entityManager()->getStorage('entity_test'); - $this->storage_rev = \Drupal::entityManager()->getStorage('entity_test_rev'); + $this->storageRev = \Drupal::entityManager()->getStorage('entity_test_rev'); } /** @@ -112,7 +112,7 @@ public function testEntityCountAndHasData() { $cardinality = $this->fieldTestData->field_storage_2->getCardinality(); $this->assertIdentical($this->fieldTestData->field_storage_2->hasData(), FALSE, 'There are no entities with field data.'); - $this->assertIdentical($this->storage_rev->countFieldData($this->fieldTestData->field_storage_2), 0, 'There are 0 entities with field data.'); + $this->assertIdentical($this->storageRev->countFieldData($this->fieldTestData->field_storage_2), 0, 'There are 0 entities with field data.'); // Create 1 entity with the field. $entity = clone($entity_init); @@ -123,7 +123,7 @@ public function testEntityCountAndHasData() { $first_revision = $entity->getRevisionId(); $this->assertIdentical($this->fieldTestData->field_storage_2->hasData(), TRUE, 'There are entities with field data.'); - $this->assertIdentical($this->storage_rev->countFieldData($this->fieldTestData->field_storage_2), 1, 'There is 1 entity with field data.'); + $this->assertIdentical($this->storageRev->countFieldData($this->fieldTestData->field_storage_2), 1, 'There is 1 entity with field data.'); $entity->{$this->fieldTestData->field_name_2} = array(); $entity->setNewRevision(); diff --git a/core/modules/field/src/Tests/FieldImportDeleteUninstallUiTest.php b/core/modules/field/src/Tests/FieldImportDeleteUninstallUiTest.php index d2dcd6cad38a3015227fa9c28eb0b2eb62a2a94c..53998e7d5ed8dc228e749bd9abb7fd8f193d9afe 100644 --- a/core/modules/field/src/Tests/FieldImportDeleteUninstallUiTest.php +++ b/core/modules/field/src/Tests/FieldImportDeleteUninstallUiTest.php @@ -28,8 +28,7 @@ class FieldImportDeleteUninstallUiTest extends FieldTestBase { protected function setUp() { parent::setUp(); - $this->web_user = $this->drupalCreateUser(array('synchronize configuration')); - $this->drupalLogin($this->web_user); + $this->drupalLogin($this->drupalCreateUser(array('synchronize configuration'))); } /** diff --git a/core/modules/field/src/Tests/Number/NumberFieldTest.php b/core/modules/field/src/Tests/Number/NumberFieldTest.php index d6a8bab81f8121211d5a32ba1b8d0785d4edb564..0a22b7469a544ee1f015568a687f3fd199a645e9 100644 --- a/core/modules/field/src/Tests/Number/NumberFieldTest.php +++ b/core/modules/field/src/Tests/Number/NumberFieldTest.php @@ -24,18 +24,17 @@ class NumberFieldTest extends WebTestBase { */ public static $modules = array('node', 'entity_test', 'field_ui'); - /** - * A user with permission to view and manage entities and content types. - * - * @var \Drupal\user\UserInterface - */ - protected $web_user; - protected function setUp() { parent::setUp(); - - $this->web_user = $this->drupalCreateUser(array('view test entity', 'administer entity_test content', 'administer content types', 'administer node fields', 'administer node display', 'bypass node access', 'administer entity_test fields')); - $this->drupalLogin($this->web_user); + $this->drupalLogin($this->drupalCreateUser(array( + 'view test entity', + 'administer entity_test content', + 'administer content types', + 'administer node fields', + 'administer node display', + 'bypass node access', + 'administer entity_test fields', + ))); } /** diff --git a/core/modules/field/src/Tests/ShapeItemTest.php b/core/modules/field/src/Tests/ShapeItemTest.php index 548d63e1c73e8f8125877b84faaacd727333a8b8..9f7df3b43406ce9742d642844ee49e8e0ceb0411 100644 --- a/core/modules/field/src/Tests/ShapeItemTest.php +++ b/core/modules/field/src/Tests/ShapeItemTest.php @@ -29,20 +29,20 @@ class ShapeItemTest extends FieldUnitTestBase { * * @var string */ - protected $field_name = 'field_shape'; + protected $fieldName = 'field_shape'; protected function setUp() { parent::setUp(); // Create a 'shape' field and storage for validation. entity_create('field_storage_config', array( - 'field_name' => $this->field_name, + 'field_name' => $this->fieldName, 'entity_type' => 'entity_test', 'type' => 'shape', ))->save(); entity_create('field_config', array( 'entity_type' => 'entity_test', - 'field_name' => $this->field_name, + 'field_name' => $this->fieldName, 'bundle' => 'entity_test', ))->save(); } @@ -55,34 +55,34 @@ public function testShapeItem() { $entity = entity_create('entity_test'); $shape = 'cube'; $color = 'blue'; - $entity->{$this->field_name}->shape = $shape; - $entity->{$this->field_name}->color = $color; + $entity->{$this->fieldName}->shape = $shape; + $entity->{$this->fieldName}->color = $color; $entity->name->value = $this->randomMachineName(); $entity->save(); // Verify entity has been created properly. $id = $entity->id(); $entity = entity_load('entity_test', $id); - $this->assertTrue($entity->{$this->field_name} instanceof FieldItemListInterface, 'Field implements interface.'); - $this->assertTrue($entity->{$this->field_name}[0] instanceof FieldItemInterface, 'Field item implements interface.'); - $this->assertEqual($entity->{$this->field_name}->shape, $shape); - $this->assertEqual($entity->{$this->field_name}->color, $color); - $this->assertEqual($entity->{$this->field_name}[0]->shape, $shape); - $this->assertEqual($entity->{$this->field_name}[0]->color, $color); + $this->assertTrue($entity->{$this->fieldName} instanceof FieldItemListInterface, 'Field implements interface.'); + $this->assertTrue($entity->{$this->fieldName}[0] instanceof FieldItemInterface, 'Field item implements interface.'); + $this->assertEqual($entity->{$this->fieldName}->shape, $shape); + $this->assertEqual($entity->{$this->fieldName}->color, $color); + $this->assertEqual($entity->{$this->fieldName}[0]->shape, $shape); + $this->assertEqual($entity->{$this->fieldName}[0]->color, $color); // Verify changing the field value. $new_shape = 'circle'; $new_color = 'red'; - $entity->{$this->field_name}->shape = $new_shape; - $entity->{$this->field_name}->color = $new_color; - $this->assertEqual($entity->{$this->field_name}->shape, $new_shape); - $this->assertEqual($entity->{$this->field_name}->color, $new_color); + $entity->{$this->fieldName}->shape = $new_shape; + $entity->{$this->fieldName}->color = $new_color; + $this->assertEqual($entity->{$this->fieldName}->shape, $new_shape); + $this->assertEqual($entity->{$this->fieldName}->color, $new_color); // Read changed entity and assert changed values. $entity->save(); $entity = entity_load('entity_test', $id); - $this->assertEqual($entity->{$this->field_name}->shape, $new_shape); - $this->assertEqual($entity->{$this->field_name}->color, $new_color); + $this->assertEqual($entity->{$this->fieldName}->shape, $new_shape); + $this->assertEqual($entity->{$this->fieldName}->color, $new_color); } } diff --git a/core/modules/field/src/Tests/TestItemTest.php b/core/modules/field/src/Tests/TestItemTest.php index b282fd1480a8cc01b871473cf7f527a22989ba05..7aa46791a820ddfa260f0f8fd7293f5d7ae9db9c 100644 --- a/core/modules/field/src/Tests/TestItemTest.php +++ b/core/modules/field/src/Tests/TestItemTest.php @@ -30,20 +30,20 @@ class TestItemTest extends FieldUnitTestBase { * * @var string */ - protected $field_name = 'field_test'; + protected $fieldName = 'field_test'; protected function setUp() { parent::setUp(); // Create a 'test_field' field and storage for validation. entity_create('field_storage_config', array( - 'field_name' => $this->field_name, + 'field_name' => $this->fieldName, 'entity_type' => 'entity_test', 'type' => 'test_field', ))->save(); entity_create('field_config', array( 'entity_type' => 'entity_test', - 'field_name' => $this->field_name, + 'field_name' => $this->fieldName, 'bundle' => 'entity_test', ))->save(); } @@ -62,20 +62,20 @@ public function testTestItem() { // Verify entity has been created properly. $id = $entity->id(); $entity = entity_load('entity_test', $id); - $this->assertTrue($entity->{$this->field_name} instanceof FieldItemListInterface, 'Field implements interface.'); - $this->assertTrue($entity->{$this->field_name}[0] instanceof FieldItemInterface, 'Field item implements interface.'); - $this->assertEqual($entity->{$this->field_name}->value, $value); - $this->assertEqual($entity->{$this->field_name}[0]->value, $value); + $this->assertTrue($entity->{$this->fieldName} instanceof FieldItemListInterface, 'Field implements interface.'); + $this->assertTrue($entity->{$this->fieldName}[0] instanceof FieldItemInterface, 'Field item implements interface.'); + $this->assertEqual($entity->{$this->fieldName}->value, $value); + $this->assertEqual($entity->{$this->fieldName}[0]->value, $value); // Verify changing the field value. $new_value = rand(1, 10); $entity->field_test->value = $new_value; - $this->assertEqual($entity->{$this->field_name}->value, $new_value); + $this->assertEqual($entity->{$this->fieldName}->value, $new_value); // Read changed entity and assert changed values. $entity->save(); $entity = entity_load('entity_test', $id); - $this->assertEqual($entity->{$this->field_name}->value, $new_value); + $this->assertEqual($entity->{$this->fieldName}->value, $new_value); // Test the schema for this field type. $expected_schema = array( diff --git a/core/modules/field/src/Tests/TestItemWithDependenciesTest.php b/core/modules/field/src/Tests/TestItemWithDependenciesTest.php index b5ad7e123477d394a7f1afdb9cbd65b40e6c7a33..b3398ade56f172639b9372d3788f1f4b5cf00cd5 100644 --- a/core/modules/field/src/Tests/TestItemWithDependenciesTest.php +++ b/core/modules/field/src/Tests/TestItemWithDependenciesTest.php @@ -26,7 +26,7 @@ class TestItemWithDependenciesTest extends FieldUnitTestBase { * * @var string */ - protected $field_name = 'field_test'; + protected $fieldName = 'field_test'; /** * Tests that field types can add dependencies to field config entities. @@ -34,13 +34,13 @@ class TestItemWithDependenciesTest extends FieldUnitTestBase { public function testTestItemWithDepenencies() { // Create a 'test_field_with_dependencies' field and storage for validation. entity_create('field_storage_config', array( - 'field_name' => $this->field_name, + 'field_name' => $this->fieldName, 'entity_type' => 'entity_test', 'type' => 'test_field_with_dependencies', ))->save(); $field = entity_create('field_config', array( 'entity_type' => 'entity_test', - 'field_name' => $this->field_name, + 'field_name' => $this->fieldName, 'bundle' => 'entity_test', )); $field->save(); diff --git a/core/modules/field/src/Tests/TranslationTest.php b/core/modules/field/src/Tests/TranslationTest.php index 4119b888debfea842aba2015eae06636c047b152..870c664e1313bfc22f55cdcb1fdd88892fb45a19 100644 --- a/core/modules/field/src/Tests/TranslationTest.php +++ b/core/modules/field/src/Tests/TranslationTest.php @@ -33,28 +33,28 @@ class TranslationTest extends FieldUnitTestBase { * * @var string */ - protected $field_name; + protected $fieldName; /** * The name of the entity type to use in this test. * * @var string */ - protected $entity_type = 'test_entity'; + protected $entityType = 'test_entity'; /** * An array defining the field storage to use in this test. * * @var array */ - protected $field_storage_definition; + protected $fieldStorageDefinition; /** * An array defining the field to use in this test. * * @var array */ - protected $field_definition; + protected $fieldDefinition; /** * The field storage to use in this test. @@ -78,24 +78,24 @@ protected function setUp() { $this->installConfig(array('language')); - $this->field_name = Unicode::strtolower($this->randomMachineName()); + $this->fieldName = Unicode::strtolower($this->randomMachineName()); - $this->entity_type = 'entity_test'; + $this->entityType = 'entity_test'; - $this->field_storage_definition = array( - 'field_name' => $this->field_name, - 'entity_type' => $this->entity_type, + $this->fieldStorageDefinition = array( + 'field_name' => $this->fieldName, + 'entity_type' => $this->entityType, 'type' => 'test_field', 'cardinality' => 4, ); - $this->fieldStorage = entity_create('field_storage_config', $this->field_storage_definition); + $this->fieldStorage = entity_create('field_storage_config', $this->fieldStorageDefinition); $this->fieldStorage->save(); - $this->field_definition = array( + $this->fieldDefinition = array( 'field_storage' => $this->fieldStorage, 'bundle' => 'entity_test', ); - $this->field = entity_create('field_config', $this->field_definition); + $this->field = entity_create('field_config', $this->fieldDefinition); $this->field->save(); for ($i = 0; $i < 3; ++$i) { @@ -124,7 +124,7 @@ function testTranslatableFieldSaveLoad() { $entity->langcode->value = reset($available_langcodes); foreach ($available_langcodes as $langcode) { $field_translations[$langcode] = $this->_generateTestFieldValues($this->fieldStorage->getCardinality()); - $entity->getTranslation($langcode)->{$this->field_name}->setValue($field_translations[$langcode]); + $entity->getTranslation($langcode)->{$this->fieldName}->setValue($field_translations[$langcode]); } // Save and reload the field translations. @@ -134,19 +134,19 @@ function testTranslatableFieldSaveLoad() { foreach ($field_translations as $langcode => $items) { $result = TRUE; foreach ($items as $delta => $item) { - $result = $result && $item['value'] == $entity->getTranslation($langcode)->{$this->field_name}[$delta]->value; + $result = $result && $item['value'] == $entity->getTranslation($langcode)->{$this->fieldName}[$delta]->value; } $this->assertTrue($result, format_string('%language translation correctly handled.', array('%language' => $langcode))); } // Test default values. $field_name_default = Unicode::strtolower($this->randomMachineName() . '_field_name'); - $field_storage_definition = $this->field_storage_definition; + $field_storage_definition = $this->fieldStorageDefinition; $field_storage_definition['field_name'] = $field_name_default; $field_storage = entity_create('field_storage_config', $field_storage_definition); $field_storage->save(); - $field_definition = $this->field_definition; + $field_definition = $this->fieldDefinition; $field_definition['field_storage'] = $field_storage; $field_definition['default_value'] = array(array('value' => rand(1, 127))); $field = entity_create('field_config', $field_definition); @@ -159,8 +159,8 @@ function testTranslatableFieldSaveLoad() { $values = array('type' => $field->bundle, 'langcode' => $translation_langcodes[0]); $entity = entity_create($entity_type_id, $values); foreach ($translation_langcodes as $langcode) { - $values[$this->field_name][$langcode] = $this->_generateTestFieldValues($this->fieldStorage->getCardinality()); - $entity->getTranslation($langcode, FALSE)->{$this->field_name}->setValue($values[$this->field_name][$langcode]); + $values[$this->fieldName][$langcode] = $this->_generateTestFieldValues($this->fieldStorage->getCardinality()); + $entity->getTranslation($langcode, FALSE)->{$this->fieldName}->setValue($values[$this->fieldName][$langcode]); } $field_langcodes = array_keys($entity->getTranslationLanguages()); @@ -177,8 +177,8 @@ function testTranslatableFieldSaveLoad() { $values = array('type' => $field->bundle, 'langcode' => $translation_langcodes[0]); $entity = entity_create($entity_type_id, $values); foreach ($translation_langcodes as $langcode) { - $values[$this->field_name][$langcode] = $this->_generateTestFieldValues($this->fieldStorage->getCardinality()); - $entity->getTranslation($langcode)->{$this->field_name}->setValue($values[$this->field_name][$langcode]); + $values[$this->fieldName][$langcode] = $this->_generateTestFieldValues($this->fieldStorage->getCardinality()); + $entity->getTranslation($langcode)->{$this->fieldName}->setValue($values[$this->fieldName][$langcode]); $entity->getTranslation($langcode)->{$field_name_default}->setValue($empty_items); $values[$field_name_default][$langcode] = $empty_items; } @@ -198,7 +198,7 @@ function testTranslatableFieldSaveLoad() { * @see https://www.drupal.org/node/2404739 */ public function testFieldAccess() { - $access_control_handler = \Drupal::entityManager()->getAccessControlHandler($this->entity_type); + $access_control_handler = \Drupal::entityManager()->getAccessControlHandler($this->entityType); $this->assertTrue($access_control_handler->fieldAccess('view', $this->field)); } diff --git a/core/modules/field/src/Tests/TranslationWebTest.php b/core/modules/field/src/Tests/TranslationWebTest.php index 34e4be3eddbd4a284870c1a317d567fdd5f472f4..6fd241abd0a1bbaceffb110cd737c8857ed2c7e8 100644 --- a/core/modules/field/src/Tests/TranslationWebTest.php +++ b/core/modules/field/src/Tests/TranslationWebTest.php @@ -31,14 +31,14 @@ class TranslationWebTest extends FieldTestBase { * * @var string */ - protected $field_name; + protected $fieldName; /** * The name of the entity type to use in this test. * * @var string */ - protected $entity_type = 'entity_test_mulrev'; + protected $entityTypeId = 'entity_test_mulrev'; /** * The field storage to use in this test. @@ -57,26 +57,26 @@ class TranslationWebTest extends FieldTestBase { protected function setUp() { parent::setUp(); - $this->field_name = Unicode::strtolower($this->randomMachineName() . '_field_name'); + $this->fieldName = Unicode::strtolower($this->randomMachineName() . '_field_name'); $field_storage = array( - 'field_name' => $this->field_name, - 'entity_type' => $this->entity_type, + 'field_name' => $this->fieldName, + 'entity_type' => $this->entityTypeId, 'type' => 'test_field', 'cardinality' => 4, ); entity_create('field_storage_config', $field_storage)->save(); - $this->fieldStorage = FieldStorageConfig::load($this->entity_type . '.' . $this->field_name); + $this->fieldStorage = FieldStorageConfig::load($this->entityTypeId . '.' . $this->fieldName); $field = array( 'field_storage' => $this->fieldStorage, - 'bundle' => $this->entity_type, + 'bundle' => $this->entityTypeId, ); entity_create('field_config', $field)->save(); - $this->field = FieldConfig::load($this->entity_type . '.' . $field['bundle'] . '.' . $this->field_name); + $this->field = FieldConfig::load($this->entityTypeId . '.' . $field['bundle'] . '.' . $this->fieldName); - entity_get_form_display($this->entity_type, $this->entity_type, 'default') - ->setComponent($this->field_name) + entity_get_form_display($this->entityTypeId, $this->entityTypeId, 'default') + ->setComponent($this->fieldName) ->save(); for ($i = 0; $i < 3; ++$i) { @@ -95,8 +95,8 @@ function testFieldFormTranslationRevisions() { $this->drupalLogin($web_user); // Prepare the field translations. - field_test_entity_info_translatable($this->entity_type, TRUE); - $entity = entity_create($this->entity_type); + field_test_entity_info_translatable($this->entityTypeId, TRUE); + $entity = entity_create($this->entityTypeId); $available_langcodes = array_flip(array_keys($this->container->get('language_manager')->getLanguages())); $field_name = $this->fieldStorage->getName(); @@ -113,7 +113,7 @@ function testFieldFormTranslationRevisions() { "{$field_name}[0][value]" => $entity->{$field_name}->value, 'revision' => TRUE, ); - $this->drupalPostForm($this->entity_type . '/manage/' . $entity->id(), $edit, t('Save')); + $this->drupalPostForm($this->entityTypeId . '/manage/' . $entity->id(), $edit, t('Save')); // Check translation revisions. $this->checkTranslationRevisions($entity->id(), $entity->getRevisionId(), $available_langcodes); @@ -126,7 +126,7 @@ function testFieldFormTranslationRevisions() { */ private function checkTranslationRevisions($id, $revision_id, $available_langcodes) { $field_name = $this->fieldStorage->getName(); - $entity = entity_revision_load($this->entity_type, $revision_id); + $entity = entity_revision_load($this->entityTypeId, $revision_id); foreach ($available_langcodes as $langcode => $value) { $passed = $entity->getTranslation($langcode)->{$field_name}->value == $value + 1; $this->assertTrue($passed, format_string('The @language translation for revision @revision was correctly stored', array('@language' => $langcode, '@revision' => $entity->getRevisionId()))); diff --git a/core/modules/field/src/Tests/reEnableModuleFieldTest.php b/core/modules/field/src/Tests/reEnableModuleFieldTest.php index 52ce2a36ce31e82acb5bbcaa16673242402f17e3..cbbf386d87ca369e7eb45e9664c8e60e8524651b 100644 --- a/core/modules/field/src/Tests/reEnableModuleFieldTest.php +++ b/core/modules/field/src/Tests/reEnableModuleFieldTest.php @@ -33,8 +33,10 @@ protected function setUp() { parent::setUp(); $this->drupalCreateContentType(array('type' => 'article')); - $this->article_creator = $this->drupalCreateUser(array('create article content', 'edit own article content')); - $this->drupalLogin($this->article_creator); + $this->drupalLogin($this->drupalCreateUser(array( + 'create article content', + 'edit own article content', + ))); } /**