You are here

public function TeamViewBuilderTest::testViewCacheExpiration in Apigee Edge 8

Tests the cache max-age for the view builder.

File

modules/apigee_edge_teams/tests/src/Kernel/Entity/TeamViewBuilderTest.php, line 96

Class

TeamViewBuilderTest
Tests the Team view builder.

Namespace

Drupal\Tests\apigee_edge_teams\Kernel\Entity

Code

public function testViewCacheExpiration() {

  /** @var \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager */
  $entity_type_manager = $this->container
    ->get('entity_type.manager');
  $build = $entity_type_manager
    ->getViewBuilder(static::ENTITY_TYPE)
    ->view($this->entity);
  static::assertEqual(900, $build['#cache']['max-age']);

  // Update the cache setting.
  $this
    ->config('apigee_edge_teams.team_settings')
    ->set('cache_expiration', 0)
    ->save();
  $build = $entity_type_manager
    ->getViewBuilder(static::ENTITY_TYPE)
    ->view($this->entity);
  static::assertEqual(0, $build['#cache']['max-age']);
}