diff --git a/core/modules/field/src/Tests/FieldDataCountTest.php b/core/modules/field/src/Tests/FieldDataCountTest.php index aef5e7e..9906a7d 100644 --- a/core/modules/field/src/Tests/FieldDataCountTest.php +++ b/core/modules/field/src/Tests/FieldDataCountTest.php @@ -146,6 +146,20 @@ public function testEntityCountAndHasData() { * Verify that we can count a table that contains an entry with index 0. */ public function testCountWithIndex0() { + // Create a field that will require dedicated storage. + /** @var \Drupal\field\Entity\FieldStorageConfig $field_storage */ + $field_storage = entity_create('field_storage_config', array( + 'field_name' => 'field_int', + 'entity_type' => 'user', + 'type' => 'integer', + 'cardinality' => 2, + )); + $field_storage->save(); + entity_create('field_config', array( + 'field_storage' => $field_storage, + 'bundle' => 'user', + ))->save(); + // Create an entry for the anonymous user, who has user ID 0. $user = $this->storageUser ->create(array( @@ -153,11 +167,17 @@ public function testCountWithIndex0() { 'name' => 'anonymous', 'mail' => NULL, 'status' => FALSE, + 'field_int' => 42, )); $user->save(); + // Test shared table storage. $storage = $user->getFieldDefinition('name')->getFieldStorageDefinition(); $this->assertIdentical(TRUE, $this->storageUser->countFieldData($storage, TRUE)); + + // Test dedicated table storage. + $storage = $user->getFieldDefinition('field_int')->getFieldStorageDefinition(); + $this->assertIdentical(TRUE, $this->storageUser->countFieldData($storage, TRUE)); } }