コード例 #1
0
 /**
  * {@inheritdoc}
  */
 public function setUp()
 {
     parent::setUp();
     $this->installEntitySchema('entity_test_rev');
     $this->installEntitySchema('user');
     $field_name = 'test';
     $this->fieldStorage = FieldStorageConfig::create(['field_name' => $field_name, 'entity_type' => 'entity_test_rev', 'type' => 'string', 'cardinality' => 1]);
     $this->fieldStorage->save();
     $this->field = FieldConfig::create(['field_name' => $field_name, 'entity_type' => 'entity_test_rev', 'bundle' => 'entity_test_rev', 'required' => TRUE]);
     $this->field->save();
     // Create an entity with field data.
     $this->entity = EntityTestRev::create(['user_id' => mt_rand(1, 10), 'name' => $this->randomMachineName(), $field_name => $this->randomString()]);
     $this->entity->save();
 }
コード例 #2
0
 function setUp()
 {
     parent::setUp();
     $this->field_name = 'test_options';
     entity_create('field_storage_config', array('name' => $this->field_name, 'entity_type' => 'entity_test_rev', 'type' => 'list_text', 'cardinality' => 1, 'settings' => array('allowed_values_function' => 'options_test_dynamic_values_callback')))->save();
     $this->instance = entity_create('field_instance_config', array('field_name' => $this->field_name, 'entity_type' => 'entity_test_rev', 'bundle' => 'entity_test_rev', 'required' => TRUE))->save();
     entity_get_form_display('entity_test_rev', 'entity_test_rev', 'default')->setComponent($this->field_name, array('type' => 'options_select'))->save();
     // Create an entity and prepare test data that will be used by
     // options_test_dynamic_values_callback().
     $values = array('user_id' => mt_rand(1, 10), 'name' => $this->randomMachineName());
     $this->entity = entity_create('entity_test_rev', $values);
     $this->entity->save();
     $this->test = array('label' => $this->entity->label(), 'uuid' => $this->entity->uuid(), 'bundle' => $this->entity->bundle(), 'uri' => $this->entity->url());
 }
コード例 #3
0
 protected function setUp()
 {
     parent::setUp();
     $field_name = 'test_options';
     $this->fieldStorage = FieldStorageConfig::create(['field_name' => $field_name, 'entity_type' => 'entity_test_rev', 'type' => 'list_string', 'cardinality' => 1, 'settings' => ['allowed_values_function' => 'options_test_dynamic_values_callback']]);
     $this->fieldStorage->save();
     $this->field = FieldConfig::create(['field_name' => $field_name, 'entity_type' => 'entity_test_rev', 'bundle' => 'entity_test_rev', 'required' => TRUE])->save();
     entity_get_form_display('entity_test_rev', 'entity_test_rev', 'default')->setComponent($field_name, ['type' => 'options_select'])->save();
     // Create an entity and prepare test data that will be used by
     // options_test_dynamic_values_callback().
     $values = ['user_id' => mt_rand(1, 10), 'name' => $this->randomMachineName()];
     $this->entity = EntityTestRev::create($values);
     $this->entity->save();
     $this->test = ['label' => $this->entity->label(), 'uuid' => $this->entity->uuid(), 'bundle' => $this->entity->bundle(), 'uri' => $this->entity->url()];
 }
コード例 #4
0
ファイル: EntityUnitTest.php プロジェクト: ddrozdik/dmaps
 /**
  * @covers ::save
  */
 public function testSave()
 {
     $storage = $this->getMock('\\Drupal\\Core\\Entity\\EntityStorageInterface');
     $storage->expects($this->once())->method('save')->with($this->entity);
     $this->entityManager->expects($this->once())->method('getStorage')->with($this->entityTypeId)->will($this->returnValue($storage));
     $this->entity->save();
 }
コード例 #5
0
ファイル: ConfigEntityBase.php プロジェクト: ddrozdik/dmaps
 /**
  * {@inheritdoc}
  */
 public function save()
 {
     $return = parent::save();
     $this->trustedData = FALSE;
     return $return;
 }