summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Pott2015-04-01 13:12:27 (GMT)
committerAlex Pott2015-04-01 13:12:27 (GMT)
commit1f37397d4dd922134b77622ec127f85d49407c0a (patch)
tree82a696909cb627f17f16aa35e7ebe6b40abdc60b
parent95dc3178b5c109268cfb6d28b9cf645d2f9732e3 (diff)
Issue #2392669 by hussainweb, Mile23, rteijeiro, subhojit777, AjitS: Clean-up field module test members - ensure property definition and use of camelCase naming convention
-rw-r--r--core/modules/field/src/Tests/Boolean/BooleanFieldTest.php11
-rw-r--r--core/modules/field/src/Tests/BulkDeleteTest.php34
-rw-r--r--core/modules/field/src/Tests/DisplayApiTest.php44
-rw-r--r--core/modules/field/src/Tests/Email/EmailFieldTest.php5
-rw-r--r--core/modules/field/src/Tests/FieldAccessTest.php10
-rw-r--r--core/modules/field/src/Tests/FieldDataCountTest.php8
-rw-r--r--core/modules/field/src/Tests/FieldImportDeleteUninstallUiTest.php3
-rw-r--r--core/modules/field/src/Tests/Number/NumberFieldTest.php19
-rw-r--r--core/modules/field/src/Tests/ShapeItemTest.php34
-rw-r--r--core/modules/field/src/Tests/TestItemTest.php18
-rw-r--r--core/modules/field/src/Tests/TestItemWithDependenciesTest.php6
-rw-r--r--core/modules/field/src/Tests/TranslationTest.php42
-rw-r--r--core/modules/field/src/Tests/TranslationWebTest.php28
-rw-r--r--core/modules/field/src/Tests/reEnableModuleFieldTest.php6
14 files changed, 133 insertions, 135 deletions
diff --git a/core/modules/field/src/Tests/Boolean/BooleanFieldTest.php b/core/modules/field/src/Tests/Boolean/BooleanFieldTest.php
index 5f027a4..28f6334 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 @@ class BooleanFieldTest extends WebTestBase {
// 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 fdffb7e..de49be1 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 @@ class BulkDeleteTest extends FieldUnitTestBase {
$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 @@ class BulkDeleteTest extends FieldUnitTestBase {
// 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 @@ class BulkDeleteTest extends FieldUnitTestBase {
$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 @@ class BulkDeleteTest extends FieldUnitTestBase {
))->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 @@ class BulkDeleteTest extends FieldUnitTestBase {
$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 @@ class BulkDeleteTest extends FieldUnitTestBase {
$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 @@ class BulkDeleteTest extends FieldUnitTestBase {
$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 @@ class BulkDeleteTest extends FieldUnitTestBase {
$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 @@ class BulkDeleteTest extends FieldUnitTestBase {
// 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 @@ class BulkDeleteTest extends FieldUnitTestBase {
// 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 @@ class BulkDeleteTest extends FieldUnitTestBase {
// 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 @@ class BulkDeleteTest extends FieldUnitTestBase {
// 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 @@ class BulkDeleteTest extends FieldUnitTestBase {
// 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 4123ab3..a8ff4c0 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 @@ class DisplayApiTest extends FieldUnitTestBase {
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 @@ class DisplayApiTest extends FieldUnitTestBase {
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 @@ class DisplayApiTest extends FieldUnitTestBase {
* 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 @@ class DisplayApiTest extends FieldUnitTestBase {
// 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 @@ class DisplayApiTest extends FieldUnitTestBase {
// 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 @@ class DisplayApiTest extends FieldUnitTestBase {
$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 @@ class DisplayApiTest extends FieldUnitTestBase {
);
$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 @@ class DisplayApiTest extends FieldUnitTestBase {
);
$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 @@ class DisplayApiTest extends FieldUnitTestBase {
// 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 @@ class DisplayApiTest extends FieldUnitTestBase {
);
// $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 55adf48..169d067 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 4b067a8..a633fac 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 @@ class FieldAccessTest extends FieldTestBase {
}
// 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 @@ class FieldAccessTest extends FieldTestBase {
// 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 2a14652..ebf0591 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 @@ class FieldDataCountTest extends FieldUnitTestBase {
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 @@ class FieldDataCountTest extends FieldUnitTestBase {
$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 @@ class FieldDataCountTest extends FieldUnitTestBase {
$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 d2dcd6c..53998e7 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 d6a8bab..0a22b74 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 548d63e..9f7df3b 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 @@ class ShapeItemTest extends FieldUnitTestBase {
$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 b282fd1..7aa4679 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 @@ class TestItemTest extends FieldUnitTestBase {
// 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 b5ad7e1..b3398ad 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 4119b88..870c664 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 @@ class TranslationTest extends FieldUnitTestBase {
$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 @@ class TranslationTest extends FieldUnitTestBase {
$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 @@ class TranslationTest extends FieldUnitTestBase {
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 @@ class TranslationTest extends FieldUnitTestBase {
$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 @@ class TranslationTest extends FieldUnitTestBase {
$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 @@ class TranslationTest extends FieldUnitTestBase {
* @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 34e4be3..6fd241a 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 @@ class TranslationWebTest extends FieldTestBase {
$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 @@ class TranslationWebTest extends FieldTestBase {
"{$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 @@ class TranslationWebTest extends FieldTestBase {
*/
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 52ce2a3..cbbf386 100644
--- a/core/modules/field/src/Tests/reEnableModuleFieldTest.php
+++ b/core/modules/field/src/Tests/reEnableModuleFieldTest.php
@@ -33,8 +33,10 @@ class reEnableModuleFieldTest extends WebTestBase {
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',
+ )));
}
/**