311a312,390 > diff --git a/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldDefaultValueTest.php b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldDefaultValueTest.php > new file mode 100644 > index 0000000..730e659 > --- /dev/null > +++ b/core/modules/system/lib/Drupal/system/Tests/Entity/EntityFieldDefaultValueTest.php > @@ -0,0 +1,73 @@ > + + > +/** > + * @file > + * Definition of Drupal\system\Tests\Entity\EntityFieldDefaultValueTest. > + */ > + > +namespace Drupal\system\Tests\Entity; > + > +use Drupal\Core\Entity\EntityInterface; > +use Drupal\Core\Entity\Field\FieldInterface; > +use Drupal\Core\Entity\Field\FieldItemInterface; > +use Drupal\Core\TypedData\TypedDataInterface; > +use Drupal\Component\Uuid\Uuid; > + > + > +/** > + * Tests Entity API default field value functionality. > + */ > +class EntityFieldDefaultValueTest extends EntityUnitTestBase { > + > + /** > + * The UUID object to be used for generating UUIDs. > + * > + * @var Drupal\Component\Uuid\UuidInterface > + */ > + protected $uuid; > + > + public static function getInfo() { > + return array( > + 'name' => 'Entity Field Default Value', > + 'description' => 'Tests default values for entity fields.', > + 'group' => 'Entity API', > + ); > + } > + > + public function setUp() { > + parent::setUp(); > + $this->installSchema('entity_test', array( > + 'entity_test_mul', > + 'entity_test_mul_property_data', > + 'entity_test_rev', > + 'entity_test_rev_revision', > + 'entity_test_mulrev', > + 'entity_test_mulrev_property_data', > + 'entity_test_mulrev_property_revision' > + )); > + // Initiate the generator. This will lazy-load uuid.inc. > + $this->uuid = new Uuid(); > + } > + > + /** > + * Tests. > + */ > + public function testDefaultValues() { > + // All entity variations have to have the same results. > + foreach (entity_test_entity_types() as $entity_type) { > + $this->assertDefaultValues($entity_type); > + } > + } > + > + /** > + * Executes a test set for a defined entity type. > + * > + * @param string $entity_type > + * The entity type to run the tests with. > + */ > + protected function assertDefaultValues($entity_type) { > + $entity = entity_create($entity_type, array()); > + $this->assertEqual($entity->langcode->value, LANGUAGE_NOT_SPECIFIED, format_string('%entity_type: Default language', array('%entity_type' => $entity_type))); > + $this->assertTrue($this->uuid->isValid($entity->uuid->value), format_string('%entity_type: Default UUID', array('%entity_type' => $entity_type))); > + } > +}