diff --git a/core/modules/field/src/Tests/DisplayApiTest.php b/core/modules/field/src/Tests/DisplayApiTest.php index 60f1fdf..2fe67a3 100644 --- a/core/modules/field/src/Tests/DisplayApiTest.php +++ b/core/modules/field/src/Tests/DisplayApiTest.php @@ -17,6 +17,13 @@ class DisplayApiTest extends FieldUnitTestBase { /** + * The field name to use in this test. + * + * @var string + */ + protected $fieldName; + + /** * The field label to use in this test. * * @var string @@ -55,18 +62,18 @@ 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, @@ -91,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->displayOptions['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->displayOptions['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(); } @@ -110,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(); @@ -280,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/ShapeItemTest.php b/core/modules/field/src/Tests/ShapeItemTest.php index 9f7df3b..6f6c9fa 100644 --- a/core/modules/field/src/Tests/ShapeItemTest.php +++ b/core/modules/field/src/Tests/ShapeItemTest.php @@ -64,11 +64,11 @@ public function testShapeItem() { $id = $entity->id(); $entity = entity_load('entity_test', $id); $this->assertTrue($entity->{$this->fieldName} instanceof FieldItemListInterface, 'Field implements interface.'); - $this->assertTrue($entity->{$this->fieldName}[0] instanceof FieldItemInterface, 'Field item implements interface.'); + $this->assertTrue($entity->{$this->field_name}[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); + $this->assertEqual($entity->{$this->field_name}[0]->shape, $shape); + $this->assertEqual($entity->{$this->field_name}[0]->color, $color); // Verify changing the field value. $new_shape = 'circle'; diff --git a/core/modules/field/src/Tests/TestItemTest.php b/core/modules/field/src/Tests/TestItemTest.php index 7aa4679..681561c 100644 --- a/core/modules/field/src/Tests/TestItemTest.php +++ b/core/modules/field/src/Tests/TestItemTest.php @@ -63,9 +63,9 @@ public function testTestItem() { $id = $entity->id(); $entity = entity_load('entity_test', $id); $this->assertTrue($entity->{$this->fieldName} instanceof FieldItemListInterface, 'Field implements interface.'); - $this->assertTrue($entity->{$this->fieldName}[0] instanceof FieldItemInterface, 'Field item implements interface.'); + $this->assertTrue($entity->{$this->field_name}[0] instanceof FieldItemInterface, 'Field item implements interface.'); $this->assertEqual($entity->{$this->fieldName}->value, $value); - $this->assertEqual($entity->{$this->fieldName}[0]->value, $value); + $this->assertEqual($entity->{$this->field_name}[0]->value, $value); // Verify changing the field value. $new_value = rand(1, 10); diff --git a/core/modules/field/src/Tests/TranslationTest.php b/core/modules/field/src/Tests/TranslationTest.php index 6e1d3fc..5cd6504 100644 --- a/core/modules/field/src/Tests/TranslationTest.php +++ b/core/modules/field/src/Tests/TranslationTest.php @@ -133,7 +133,7 @@ function testTranslatableFieldSaveLoad() { foreach ($field_translations as $langcode => $items) { $result = TRUE; foreach ($items as $delta => $item) { - $result = $result && $item['value'] == $entity->getTranslation($langcode)->{$this->fieldName}[$delta]->value; + $result = $result && $item['value'] == $entity->getTranslation($langcode)->{fieldName}[$delta]->value; } $this->assertTrue($result, format_string('%language translation correctly handled.', array('%language' => $langcode))); }