You are here

public function EntityPagerAnalyzeEventTest::testGetSetLogs in Entity Pager 8

Same name and namespace in other branches
  1. 2.0.x tests/src/Unit/EntityPagerAnalyzeEventTest.php \Drupal\Tests\entity_pager\Unit\EntityPagerAnalyzeEventTest::testGetSetLogs()

@covers ::__construct @covers ::getLogs @covers ::setLogs @covers ::log

File

tests/src/Unit/EntityPagerAnalyzeEventTest.php, line 44

Class

EntityPagerAnalyzeEventTest
@coversDefaultClass \Drupal\entity_pager\Event\EntityPagerAnalyzeEvent @group entity_pager

Namespace

Drupal\Tests\entity_pager\Unit

Code

public function testGetSetLogs() {
  $event = new EntityPagerAnalyzeEvent($this
    ->createMock(EntityPagerInterface::class));
  $logs1 = [
    $this
      ->randomMachineName(),
    $this
      ->randomMachineName(),
  ];
  $event
    ->setLogs($logs1);
  $this
    ->assertSame($logs1, $event
    ->getLogs());
  $log2 = $this
    ->randomMachineName();
  $event
    ->log($log2);
  $this
    ->assertEquals(array_merge($logs1, [
    $log2,
  ]), $event
    ->getLogs(), 'log() accepts string argument.');
  $log3 = [
    $this
      ->randomMachineName(),
    $this
      ->randomMachineName(),
  ];
  $event
    ->log($log3);
  $this
    ->assertEquals(array_merge($logs1, [
    $log2,
  ], $log3), $event
    ->getLogs(), 'log() accepts array argument.');
}