You are here

public function ApidocEntityTest::testEntity in Apigee API Catalog 8

Same name and namespace in other branches
  1. 8.2 tests/src/Kernel/ApidocEntityTest.php \Drupal\Tests\apigee_api_catalog\Kernel\ApidocEntityTest::testEntity()

Basic CRUD operations on a ApiDoc entity.

File

tests/src/Kernel/ApidocEntityTest.php, line 67

Class

ApidocEntityTest
Test basic CRUD operations for our ApiDoc entity type.

Namespace

Drupal\Tests\apigee_api_catalog\Kernel

Code

public function testEntity() {
  $entity = ApiDoc::create([
    'name' => 'API 1',
    'description' => 'Test API 1',
    'spec' => NULL,
    'api_product' => NULL,
  ]);
  $this
    ->assertNotNull($entity);
  $this
    ->assertEquals(SAVED_NEW, $entity
    ->save());
  $this
    ->assertEquals(SAVED_UPDATED, $entity
    ->set('name', 'API 1a')
    ->save());
  $entity_id = $entity
    ->id();
  $this
    ->assertNotEmpty($entity_id);
  $entity
    ->delete();
  $this
    ->assertNull(ApiDoc::load($entity_id));
}