protected function EntityFieldTest::assertComputedProperties

Executes the computed properties tests for the given entity type.

Parameters

string $entity_type: The entity type to run the tests with.

1 call to EntityFieldTest::assertComputedProperties()
EntityFieldTest::testComputedProperties in drupal/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php
Tests getting processed property values via a computed property.

File

drupal/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldTest.php, line 598
Definition of Drupal\system\Tests\Entity\EntityFieldTest.

Class

EntityFieldTest
Tests Entity API base functionality.

Namespace

Drupal\system\Tests\Entity

Code

protected function assertComputedProperties($entity_type) {

  // Make the test text field processed.
  $instance = field_info_instance($entity_type, 'field_test_text', $entity_type);
  $instance['settings']['text_processing'] = 1;
  field_update_instance($instance);
  $entity = $this
    ->createTestEntity($entity_type);
  $entity->field_test_text->value = "The <strong>text</strong> text to filter.";
  $entity->field_test_text->format = filter_default_format();
  $target = "<p>The &lt;strong&gt;text&lt;/strong&gt; text to filter.</p>\n";
  $this
    ->assertEqual($entity->field_test_text->processed, $target, format_string('%entity_type: Text is processed with the default filter.', array(
    '%entity_type' => $entity_type,
  )));

  // Save and load entity and make sure it still works.
  $entity
    ->save();
  $entity = entity_load($entity_type, $entity
    ->id());
  $this
    ->assertEqual($entity->field_test_text->processed, $target, format_string('%entity_type: Text is processed with the default filter.', array(
    '%entity_type' => $entity_type,
  )));
}