function CacheableMetadataTest::testSetCacheMaxAge

Same name in other branches
  1. 8.9.x core/tests/Drupal/Tests/Core/Cache/CacheableMetadataTest.php \Drupal\Tests\Core\Cache\CacheableMetadataTest::testSetCacheMaxAge()
  2. 10 core/tests/Drupal/Tests/Core/Cache/CacheableMetadataTest.php \Drupal\Tests\Core\Cache\CacheableMetadataTest::testSetCacheMaxAge()
  3. 11.x core/tests/Drupal/Tests/Core/Cache/CacheableMetadataTest.php \Drupal\Tests\Core\Cache\CacheableMetadataTest::testSetCacheMaxAge()

Tests valid and invalid values as max age.

@covers ::setCacheMaxAge @dataProvider providerSetCacheMaxAge

File

core/tests/Drupal/Tests/Core/Cache/CacheableMetadataTest.php, line 111

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->expectException('\\InvalidArgumentException');
    }
    $metadata->setCacheMaxAge($data);
    $this->assertEquals($data, $metadata->getCacheMaxAge());
}

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