createMock(EventDispatcherInterface::class); $security = $this->createMock(AuthorizationCheckerInterface::class); $security->method('isGranted')->willReturn($isGranted); return new ReportingExtension($dispatcher, $security); } public function testGetFunctions() { $sut = $this->getSut(); $functions = ['available_reports']; $twigFunctions = $sut->getFunctions(); $this->assertCount(\count($functions), $twigFunctions); $i = 0; /** @var TwigFunction $function */ foreach ($twigFunctions as $function) { $this->assertInstanceOf(TwigFunction::class, $function); $this->assertEquals($functions[$i++], $function->getName()); } } public function testGetAvailableReports() { $sut = $this->getSut(); $reports = $sut->getAvailableReports(new User()); self::assertIsArray($reports); self::assertEmpty($reports); } public function testGetAvailableReportsWithPermission() { $sut = $this->getSut(true); $reports = $sut->getAvailableReports(new User()); self::assertIsArray($reports); self::assertCount(3, $reports); } }