mirror of
https://github.com/kevinpapst/kimai2.git
synced 2025-05-13 13:11:54 +00:00
53 lines
1.5 KiB
PHP
53 lines
1.5 KiB
PHP
<?php
|
|
|
|
/*
|
|
* This file is part of the Kimai time-tracking app.
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
namespace App\Tests\DependencyInjection\Compiler;
|
|
|
|
use App\DependencyInjection\Compiler\WidgetCompilerPass;
|
|
use App\Widget\Type\ActiveUsers;
|
|
use App\Widget\Type\Duration;
|
|
use App\Widget\WidgetInterface;
|
|
use App\Widget\WidgetService;
|
|
use PHPUnit\Framework\TestCase;
|
|
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
|
use Symfony\Component\DependencyInjection\Definition;
|
|
|
|
/**
|
|
* @covers \App\DependencyInjection\Compiler\WidgetCompilerPass
|
|
*/
|
|
class WidgetCompilerPassTest extends TestCase
|
|
{
|
|
private function getContainer(): ContainerBuilder
|
|
{
|
|
$container = new ContainerBuilder();
|
|
|
|
$definition = new Definition(WidgetService::class);
|
|
$container->setDefinition(WidgetService::class, $definition);
|
|
|
|
$widgets = [Duration::class, ActiveUsers::class];
|
|
foreach ($widgets as $widget) {
|
|
$container->register($widget)->addTag(WidgetInterface::class);
|
|
}
|
|
|
|
return $container;
|
|
}
|
|
|
|
public function testCallsAreAdded(): void
|
|
{
|
|
$container = $this->getContainer();
|
|
$sut = new WidgetCompilerPass();
|
|
$sut->process($container);
|
|
|
|
$definition = $container->findDefinition(WidgetService::class);
|
|
$methods = $definition->getMethodCalls();
|
|
|
|
self::assertCount(2, $methods);
|
|
self::assertTrue($definition->hasMethodCall('registerWidget'));
|
|
}
|
|
}
|