/** * Verify that we can count a table that contains an entry with index 0. */ public function testCountWithIndex0() { // Create an entry for the anonymous user, who has user ID 0. $user = $this->storageUser->create(array('uid' => 0, 'name' => 'anonymous', 'mail' => NULL, 'status' => FALSE)); $user->save(); $storage = $user->getFieldDefinition('name')->getFieldStorageDefinition(); $this->assertIdentical(TRUE, $this->storageUser->countFieldData($storage, TRUE)); }
/** * 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 = FieldStorageConfig::create(array('field_name' => 'field_int', 'entity_type' => 'user', 'type' => 'integer', 'cardinality' => 2)); $field_storage->save(); FieldConfig::create(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('uid' => 0, '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)); }