Namespace
Drupal\Tests\content_entity_example\Kernel
File
-
modules/content_entity_example/tests/src/Kernel/ContactTest.php
View source
<?php
namespace Drupal\Tests\content_entity_example\Kernel;
use Drupal\content_entity_example\Entity\Contact;
use Drupal\KernelTests\KernelTestBase;
class ContactTest extends KernelTestBase {
protected $defaultTheme = 'stark';
protected static $modules = [
'content_entity_example',
'options',
'user',
];
public function testEntity() {
$this->installEntitySchema('content_entity_example_contact');
$entity = Contact::create([
'name' => 'Name',
'first_name' => 'Firstname',
'user_id' => 0,
'role' => 'user',
]);
$this->assertNotNull($entity);
$this->assertEquals(SAVED_NEW, $entity->save());
$this->assertEquals(SAVED_UPDATED, $entity->set('role', 'administrator')
->save());
$entity_id = $entity->id();
$this->assertNotEmpty($entity_id);
$entity->delete();
$this->assertNull(Contact::load($entity_id));
}
}
Classes
| Title |
Deprecated |
Summary |
| ContactTest |
|
Test basic CRUD operations for our Contact entity type. |