You are here

public function CacheableMetadataTest::testSetCacheMaxAge in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/tests/Drupal/Tests/Core/Cache/CacheableMetadataTest.php \Drupal\Tests\Core\Cache\CacheableMetadataTest::testSetCacheMaxAge()

Test valid and invalid values as max age.

@covers ::setCacheMaxAge @dataProvider providerSetCacheMaxAge

File

core/tests/Drupal/Tests/Core/Cache/CacheableMetadataTest.php, line 117
Contains \Drupal\Tests\Core\Cache\CacheableMetadataTest.

Class

CacheableMetadataTest
@coversDefaultClass \Drupal\Core\Cache\CacheableMetadata @group Cache

Namespace

Drupal\Tests\Core\Cache

Code

public function testSetCacheMaxAge($data, $expect_exception) {
  $metadata = new CacheableMetadata();
  if ($expect_exception) {
    $this
      ->setExpectedException('\\InvalidArgumentException');
  }
  $metadata
    ->setCacheMaxAge($data);
  $this
    ->assertEquals($data, $metadata
    ->getCacheMaxAge());
}