protected function setUp() { parent::setUp(); $this->entityStorage = $this->entityManager->getStorage('entity_test'); $this->factory = $this->container->get('entity.query'); // Add some fieldapi fields to be used in the test. for ($i = 1; $i <= 2; $i++) { $field_name = 'field_test_' . $i; entity_create('field_storage_config', array('field_name' => $field_name, 'entity_type' => 'entity_test', 'type' => 'integer', 'cardinality' => 2))->save(); entity_create('field_config', array('field_name' => $field_name, 'entity_type' => 'entity_test', 'bundle' => 'entity_test'))->save(); } $entity = $this->entityStorage->create(array('id' => 1, 'user_id' => 1, 'field_test_1' => 1, 'field_test_2' => 2)); $entity->enforceIsNew(); $entity->save(); $entity = $this->entityStorage->create(array('id' => 2, 'user_id' => 2, 'field_test_1' => 1, 'field_test_2' => 7)); $entity->enforceIsNew(); $entity->save(); $entity = $this->entityStorage->create(array('id' => 3, 'user_id' => 2, 'field_test_1' => 2, 'field_test_2' => 1)); $entity->enforceIsNew(); $entity->save(); $entity = $this->entityStorage->create(array('id' => 4, 'user_id' => 2, 'field_test_1' => 2, 'field_test_2' => 8)); $entity->enforceIsNew(); $entity->save(); $entity = $this->entityStorage->create(array('id' => 5, 'user_id' => 3, 'field_test_1' => 2, 'field_test_2' => 2)); $entity->enforceIsNew(); $entity->save(); $entity = $this->entityStorage->create(array('id' => 6, 'user_id' => 3, 'field_test_1' => 3, 'field_test_2' => 8)); $entity->enforceIsNew(); $entity->save(); }
public function setUp() { parent::setUp(); $this->installEntitySchema('entity_test_rev'); $this->installEntitySchema('entity_test_mul'); $this->installEntitySchema('entity_test_mulrev'); }
protected function setUp() { parent::setUp(); $this->installEntitySchema('taxonomy_term'); // We want a taxonomy term reference field. It needs a vocabulary, terms, // a field storage and a field. First, create the vocabulary. $vocabulary = entity_create('taxonomy_vocabulary', array('vid' => drupal_strtolower($this->randomMachineName()))); $vocabulary->save(); // Second, create the field. $this->fieldName = strtolower($this->randomMachineName()); entity_create('field_storage_config', array('field_name' => $this->fieldName, 'entity_type' => 'entity_test', 'type' => 'taxonomy_term_reference', 'settings' => array('allowed_values' => array('vocabulary' => $vocabulary->id()))))->save(); entity_test_create_bundle('test_bundle'); // Third, create the instance. entity_create('field_config', array('entity_type' => 'entity_test', 'field_name' => $this->fieldName, 'bundle' => 'test_bundle'))->save(); // Create two terms and also two accounts. for ($i = 0; $i <= 1; $i++) { $term = entity_create('taxonomy_term', array('name' => $this->randomMachineName(), 'vid' => $vocabulary->id())); $term->save(); $this->terms[] = $term; $this->accounts[] = $this->createUser(); } // Create three entity_test entities, the 0th entity will point to the // 0th account and 0th term, the 1st and 2nd entity will point to the // 1st account and 1st term. for ($i = 0; $i <= 2; $i++) { $entity = entity_create('entity_test', array('type' => 'test_bundle')); $entity->name->value = $this->randomMachineName(); $index = $i ? 1 : 0; $entity->user_id->target_id = $this->accounts[$index]->id(); $entity->{$this->fieldName}->target_id = $this->terms[$index]->id(); $entity->save(); $this->entities[] = $entity; } $this->factory = \Drupal::service('entity.query'); }
/** * {@inheritdoc} */ protected function setUp() { parent::setUp(); // Create the test field. entity_test_install(); // Install required default configuration for filter module. $this->installConfig(array('system', 'filter')); }
/** * {@inheritdoc} */ public function setUp() { parent::setUp(); $this->installSchema('user', array('users_data')); $this->installSchema('system', array('router')); $this->moduleHandler = $this->container->get('module_handler'); $this->database = $this->container->get('database'); }
protected function setUp() { parent::setUp(); foreach (entity_test_entity_types() as $entity_type_id) { // The entity_test schema is installed by the parent. if ($entity_type_id != 'entity_test') { $this->installEntitySchema($entity_type_id); } } }
/** * {@inheritdoc} */ public function setUp() { parent::setUp(); $this->installEntitySchema('entity_test_rev'); $this->installEntitySchema('entity_test_mul'); $this->installEntitySchema('entity_test_mulrev'); // Create the test field. entity_test_install(); // Install required default configuration for filter module. $this->installConfig(array('system', 'filter')); }
/** * {@inheritdoc} */ public function setUp() { parent::setUp(); $this->installConfig(array('entity_test')); }