You are here

public function BlocacheMetadataUnitTest::setUp in Blocache (Block Cache Control) 8

Overrides UnitTestCase::setUp

File

tests/src/Unit/BlocacheMetadataUnitTest.php, line 43

Class

BlocacheMetadataUnitTest
Tests for BlocacheMetadata class.

Namespace

Drupal\Tests\blocache\Unit

Code

public function setUp() {
  parent::setUp();
  $this->blocacheMetadata = new BlocacheMetadata();
  $plugin = $this
    ->getMockBuilder('Drupal\\Core\\Block\\BlockBase')
    ->disableOriginalConstructor()
    ->getMock();
  $plugin
    ->expects($this
    ->any())
    ->method('getMachineNameSuggestion')
    ->will($this
    ->returnValue($this
    ->randomMachineName(8)));
  $block = $this
    ->getMockBuilder('Drupal\\block\\Entity\\Block')
    ->disableOriginalConstructor()
    ->getMock();
  $block
    ->expects($this
    ->any())
    ->method('getPlugin')
    ->will($this
    ->returnValue($plugin));
  $this->block = $block;
  $this->blocacheMetadata
    ->setBlock($this->block);
  $this->metadata = [
    BlocacheMetadata::METADATA_MAX_AGE => 600,
    BlocacheMetadata::METADATA_CONTEXTS => [
      'user',
      'language',
    ],
    BlocacheMetadata::METADATA_TAGS => [
      'user:1',
      'language:en',
    ],
  ];
}