function ResourceTypeRepositoryTest::testCaching

Same name in other branches
  1. 9 core/modules/jsonapi/tests/src/Kernel/ResourceType/ResourceTypeRepositoryTest.php \Drupal\Tests\jsonapi\Kernel\ResourceType\ResourceTypeRepositoryTest::testCaching()
  2. 10 core/modules/jsonapi/tests/src/Kernel/ResourceType/ResourceTypeRepositoryTest.php \Drupal\Tests\jsonapi\Kernel\ResourceType\ResourceTypeRepositoryTest::testCaching()
  3. 11.x core/modules/jsonapi/tests/src/Kernel/ResourceType/ResourceTypeRepositoryTest.php \Drupal\Tests\jsonapi\Kernel\ResourceType\ResourceTypeRepositoryTest::testCaching()

Ensures that the ResourceTypeRepository's cache does not become stale.

File

core/modules/jsonapi/tests/src/Kernel/ResourceType/ResourceTypeRepositoryTest.php, line 108

Class

ResourceTypeRepositoryTest
@coversDefaultClass \Drupal\jsonapi\ResourceType\ResourceTypeRepository @group jsonapi

Namespace

Drupal\Tests\jsonapi\Kernel\ResourceType

Code

public function testCaching() {
    $this->assertEmpty($this->resourceTypeRepository
        ->get('node', 'article')
        ->getRelatableResourceTypesByField('field_relationship'));
    $this->createEntityReferenceField('node', 'article', 'field_relationship', 'Related entity', 'node');
    $this->assertCount(3, $this->resourceTypeRepository
        ->get('node', 'article')
        ->getRelatableResourceTypesByField('field_relationship'));
    NodeType::create([
        'type' => 'camelids',
    ])->save();
    $this->assertCount(4, $this->resourceTypeRepository
        ->get('node', 'article')
        ->getRelatableResourceTypesByField('field_relationship'));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.