public function EntityPagerAnalyzerTest::testAnalyze in Entity Pager 8
Same name and namespace in other branches
- 2.0.x tests/src/Unit/EntityPagerAnalyzerTest.php \Drupal\Tests\entity_pager\Unit\EntityPagerAnalyzerTest::testAnalyze()
@covers ::__construct @covers ::analyze
File
- tests/
src/ Unit/ EntityPagerAnalyzerTest.php, line 50
Class
- EntityPagerAnalyzerTest
- @coversDefaultClass \Drupal\entity_pager\EntityPagerAnalyzer @group entity_pager
Namespace
Drupal\Tests\entity_pager\UnitCode
public function testAnalyze() {
$event_dispatcher = $this
->createMock(EventDispatcherInterface::class);
$event_dispatcher
->expects($this
->once())
->method('dispatch')
->with(EntityPagerEvents::ENTITY_PAGER_ANALYZE, $this
->callback([
$this,
'mockSubscriberLog',
]));
// @todo Refactor \Drupal\entity_pager\EntityPagerAnalyzer to use dependency
// injection for its logging.
$logger = $this
->createMock(LoggerChannelInterface::class);
$logger
->expects($this
->exactly(count($this->logs)))
->method('notice')
->withConsecutive(...array_map(function ($a) {
return [
$a,
];
}, $this->logs));
$logger_factory = $this
->createMock(LoggerChannelFactoryInterface::class);
$logger_factory
->method('get')
->willReturn($logger);
$container = new ContainerBuilder();
$container
->set('logger.factory', $logger_factory);
\Drupal::setContainer($container);
$analyzer = new EntityPagerAnalyzer($event_dispatcher);
$analyzer
->analyze($this->entityPager);
}