public function EntityQueryTest::testCount in Zircon Profile 8
Same name and namespace in other branches
- 8.0 core/modules/system/src/Tests/Entity/EntityQueryTest.php \Drupal\system\Tests\Entity\EntityQueryTest::testCount()
Test that count queries are separated across entity types.
File
- core/
modules/ system/ src/ Tests/ Entity/ EntityQueryTest.php, line 458 - Contains \Drupal\system\Tests\Entity\EntityQueryTest.
Class
- EntityQueryTest
- Tests Entity Query functionality.
Namespace
Drupal\system\Tests\EntityCode
public function testCount() {
// Create a field with the same name in a different entity type.
$field_name = $this->figures;
$field_storage = entity_create('field_storage_config', array(
'field_name' => $field_name,
'entity_type' => 'entity_test',
'type' => 'shape',
'cardinality' => 2,
'translatable' => TRUE,
));
$field_storage
->save();
$bundle = $this
->randomMachineName();
entity_create('field_config', array(
'field_storage' => $field_storage,
'bundle' => $bundle,
))
->save();
$entity = entity_create('entity_test', array(
'id' => 1,
'type' => $bundle,
));
$entity
->enforceIsNew();
$entity
->save();
// As the single entity of this type we just saved does not have a value
// in the color field, the result should be 0.
$count = $this->factory
->get('entity_test')
->exists("{$field_name}.color")
->count()
->execute();
$this
->assertFalse($count);
}