EntityAnalyzerSubscriberTest.php in Entity Pager 2.0.x
Same filename and directory in other branches
Namespace
Drupal\Tests\entity_pager\UnitFile
tests/src/Unit/EntityAnalyzerSubscriberTest.phpView source
<?php
namespace Drupal\Tests\entity_pager\Unit;
use Drupal\entity_pager\EntityPagerInterface;
use Drupal\entity_pager\Event\EntityPagerAnalyzeEvent;
use Drupal\entity_pager\EventSubscriber\EntityAnalyzerSubscriber;
use Drupal\entity_test\Entity\EntityTest;
use Drupal\Tests\UnitTestCase;
/**
* @coversDefaultClass \Drupal\entity_pager\EventSubscriber\EntityAnalyzerSubscriber
* @group entity_pager
*/
class EntityAnalyzerSubscriberTest extends UnitTestCase {
/**
* @covers ::onEntityPagerAnalyze
* @dataProvider onEntityPagerAnalyzeTestCases
*/
public function testEntityPagerAnalyze($entity, $logs) {
$entity_pager = $this
->createMock(EntityPagerInterface::class);
$entity_pager
->method('getEntity')
->willReturn($entity);
$event = new EntityPagerAnalyzeEvent($entity_pager);
(new EntityAnalyzerSubscriber())
->onEntityPagerAnalyze($event);
$this
->assertEquals($logs, $event
->getLogs());
}
/**
* Test cases for testOnEntityPagerAnalyze().
*/
public function onEntityPagerAnalyzeTestCases() {
return [
'No entity' => [
NULL,
[
'No Entity on page.',
],
],
'Has entity' => [
$this
->createMock(EntityTest::class),
[],
],
];
}
}
Classes
Name | Description |
---|---|
EntityAnalyzerSubscriberTest | @coversDefaultClass \Drupal\entity_pager\EventSubscriber\EntityAnalyzerSubscriber @group entity_pager |