diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..df4e6fc --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,45 @@ +name: Tests + +on: + pull_request: + push: + branches: + - master + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} + +jobs: + + tests: + runs-on: ubuntu-24.04 + strategy: + matrix: + php-versions: [ '8.2', '8.3', '8.4' ] + symfony-version: ['5.4.*', '6.4.*', '7.2.*'] + fail-fast: false + steps: + - uses: actions/checkout@v4 + + - name: Setup PHP, with composer and extensions + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + coverage: none + tools: phpstan + + - name: Configure Symfony + run: composer config extra.symfony.require "${{ matrix.symfony-version }}" + + - name: Update project dependencies + run: composer update --no-progress --ansi --prefer-stable + + - name: Composer install + run: composer install --no-scripts --no-interaction --prefer-dist -oa + + - name: Run Phpunit + run: ./vendor/bin/phpunit + + - name: Run Phpstan + run: phpstan analyze DependencyInjection Services diff --git a/.gitignore b/.gitignore index 2942141..02efec0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,7 @@ .idea/ composer.lock vendor/ +.phpunit.cache +.phpunit.result.cache +.devenv +.devenv.flake.nix diff --git a/DependencyInjection/Configuration.php b/DependencyInjection/Configuration.php index 5cfd34b..e41407c 100644 --- a/DependencyInjection/Configuration.php +++ b/DependencyInjection/Configuration.php @@ -15,7 +15,7 @@ class Configuration implements ConfigurationInterface * * @return \Symfony\Component\Config\Definition\Builder\TreeBuilder The tree builder */ - public function getConfigTreeBuilder() + public function getConfigTreeBuilder(): TreeBuilder { $treeBuilder = new TreeBuilder('openclassrooms_use_case'); $rootNode = $treeBuilder->getRootNode(); @@ -24,6 +24,7 @@ public function getConfigTreeBuilder() ->scalarNode('transaction')->defaultValue('doctrine.orm.entity_manager')->end() ->scalarNode('event_sender')->defaultValue('event_dispatcher')->end() ->scalarNode('event_factory')->defaultValue('openclassrooms.use_case.event_factory')->end() + ->variableNode('cache')->end() ->end(); return $treeBuilder; diff --git a/DependencyInjection/OpenClassroomsUseCaseExtension.php b/DependencyInjection/OpenClassroomsUseCaseExtension.php index 5af5b4d..e91b0a8 100644 --- a/DependencyInjection/OpenClassroomsUseCaseExtension.php +++ b/DependencyInjection/OpenClassroomsUseCaseExtension.php @@ -33,12 +33,17 @@ public function load(array $config, ContainerBuilder $container) $container->setParameter('openclassrooms.use_case.default_entity_manager', $config['transaction']); $container->setParameter('openclassrooms.use_case.default_event_sender', $config['event_sender']); $container->setParameter('openclassrooms.use_case.default_event_factory', $config['event_factory']); + + if (isset($config['cache'])) { + $cache = $container->setAlias('openclassrooms.use_case.cache', $config['cache']); + $cache->setPublic(true); + } } /** * @return string */ - public function getAlias() + public function getAlias(): string { return 'open_classrooms_use_case'; } diff --git a/Resources/config/services.xml b/Resources/config/services.xml index 144f9fa..e7cec74 100644 --- a/Resources/config/services.xml +++ b/Resources/config/services.xml @@ -1,15 +1,6 @@ - - OpenClassrooms\Bundle\UseCaseBundle\Services\Security\Impl\SecurityFactoryImpl - OpenClassrooms\Bundle\UseCaseBundle\Services\Transaction\Impl\TransactionFactoryImpl - OpenClassrooms\Bundle\UseCaseBundle\Services\Event\Impl\EventAdapterFactoryImpl - OpenClassrooms\Bundle\UseCaseBundle\Services\Event\Impl\UseCaseEventBuilderImpl - OpenClassrooms\Bundle\UseCaseBundle\Services\Event\Impl\EventFactoryImpl - OpenClassrooms\Bundle\UseCaseBundle\Services\Proxy\Impl\UseCaseProxyFactoryImpl - - - + @@ -17,22 +8,22 @@ - - - - - + + + + + - - + + - + diff --git a/Services/Proxy/Impl/UseCaseProxyFactoryImpl.php b/Services/Proxy/Impl/UseCaseProxyFactoryImpl.php index 16b86a4..bff305f 100644 --- a/Services/Proxy/Impl/UseCaseProxyFactoryImpl.php +++ b/Services/Proxy/Impl/UseCaseProxyFactoryImpl.php @@ -141,10 +141,10 @@ private function buildCache(array $tagParameters) if (isset($tagParameters['cache'])) { /** @var Cache $cache */ $cache = $this->container->get($tagParameters['cache']); - } elseif ($this->container->has('openclassrooms.cache.cache')) { - $cache = $this->container->get('openclassrooms.cache.cache'); + } elseif ($this->container->has('openclassrooms.use_case.cache')) { + $cache = $this->container->get('openclassrooms.use_case.cache'); } else { - throw new CacheIsNotDefinedException('Default cache is not defined. Have you configured open_classrooms_cache ?'); + throw new CacheIsNotDefinedException('Default cache is not defined. Have you configured it ?'); } return $cache; diff --git a/Tests/DependencyInjection/AbstractDependencyInjectionTest.php b/Tests/DependencyInjection/AbstractDependencyInjectionTestCase.php similarity index 82% rename from Tests/DependencyInjection/AbstractDependencyInjectionTest.php rename to Tests/DependencyInjection/AbstractDependencyInjectionTestCase.php index 42a3e8f..4e54b41 100644 --- a/Tests/DependencyInjection/AbstractDependencyInjectionTest.php +++ b/Tests/DependencyInjection/AbstractDependencyInjectionTestCase.php @@ -2,8 +2,6 @@ namespace OpenClassrooms\Bundle\UseCaseBundle\Tests\DependencyInjection; -use OpenClassrooms\Bundle\CacheBundle\DependencyInjection\OpenClassroomsCacheExtension; -use OpenClassrooms\Bundle\CacheBundle\OpenClassroomsCacheBundle; use OpenClassrooms\Bundle\UseCaseBundle\DependencyInjection\OpenClassroomsUseCaseExtension; use OpenClassrooms\Bundle\UseCaseBundle\OpenClassroomsUseCaseBundle; use OpenClassrooms\Bundle\UseCaseBundle\Tests\DependencyInjection\Fixtures\BusinessRules\UseCases\CacheUseCaseStub; @@ -20,13 +18,13 @@ use PHPUnit\Framework\TestCase; use Symfony\Component\Config\FileLocator; use Symfony\Component\DependencyInjection\ContainerBuilder; +use Symfony\Component\DependencyInjection\Loader\PhpFileLoader; use Symfony\Component\DependencyInjection\Loader\XmlFileLoader; -use Symfony\Component\DependencyInjection\Loader\YamlFileLoader; /** * @author Romain Kuzniak */ -abstract class AbstractDependencyInjectionTest extends TestCase +abstract class AbstractDependencyInjectionTestCase extends TestCase { const USE_CASE_PROXY_CLASS = 'OpenClassrooms\UseCase\Application\Services\Proxy\UseCases\Impl\UseCaseProxyImpl'; @@ -36,7 +34,7 @@ abstract class AbstractDependencyInjectionTest extends TestCase protected $container; /** - * @var YamlFileLoader + * @var PhpFileLoader */ protected $configLoader; @@ -71,8 +69,8 @@ protected function initServiceLoader() protected function initConfigLoader() { - $this->configLoader = new YamlFileLoader($this->container, new FileLocator(__DIR__.'/Fixtures/Resources/config/')); - $this->configLoader->load('DefaultConfiguration.yml'); + $this->configLoader = new PhpFileLoader($this->container, new FileLocator(__DIR__.'/Fixtures/Resources/config/')); + $this->configLoader->load('DefaultConfiguration.php'); } protected function assertSecurityUseCaseProxy(UseCaseProxy $useCaseProxy) @@ -93,7 +91,7 @@ protected function assertCacheUseCaseProxy(UseCaseProxy $useCaseProxy) { $this->assertUseCaseProxy($useCaseProxy); $this->assertEquals(new CacheUseCaseStub(), $useCaseProxy->getUseCase()); - $this->assertTrue(CacheSpy::$saved); + $this->assertNotEmpty(CacheSpy::$saved); } protected function assertTransactionUseCaseProxy(UseCaseProxy $useCaseProxy) @@ -110,14 +108,4 @@ protected function assertEventUseCaseProxy(UseCaseProxy $useCaseProxy) $this->assertTrue(EventDispatcherSpy::$sent); $this->assertEquals(EventUseCaseStub::EVENT_NAME, EventDispatcherSpy::$eventName); } - - protected function initCacheBundle() - { - $cacheExtension = new OpenClassroomsCacheExtension(); - $this->container->registerExtension($cacheExtension); - $this->container->loadFromExtension('open_classrooms_cache'); - - $cacheBundle = new OpenClassroomsCacheBundle(); - $cacheBundle->build($this->container); - } } diff --git a/Tests/DependencyInjection/CacheOpenClassroomsUseCaseExtensionTest.php b/Tests/DependencyInjection/CacheOpenClassroomsUseCaseExtensionTest.php index f074985..6ca1461 100644 --- a/Tests/DependencyInjection/CacheOpenClassroomsUseCaseExtensionTest.php +++ b/Tests/DependencyInjection/CacheOpenClassroomsUseCaseExtensionTest.php @@ -2,22 +2,24 @@ namespace OpenClassrooms\Bundle\UseCaseBundle\Tests\DependencyInjection\Yaml; -use OpenClassrooms\Bundle\UseCaseBundle\Tests\DependencyInjection\AbstractDependencyInjectionTest; +use OpenClassrooms\Bundle\UseCaseBundle\Tests\DependencyInjection\AbstractDependencyInjectionTestCase; +use OpenClassrooms\UseCase\Application\Services\Proxy\UseCases\Exceptions\CacheIsNotDefinedException; use OpenClassrooms\UseCase\Application\Services\Proxy\UseCases\UseCaseProxy; use Symfony\Component\DependencyInjection\ContainerBuilder; /** * @author Romain Kuzniak */ -class CacheOpenClassroomsUseCaseExtensionTest extends AbstractDependencyInjectionTest +class CacheOpenClassroomsUseCaseExtensionTest extends AbstractDependencyInjectionTestCase { /** * @test - * @expectedException \OpenClassrooms\UseCase\Application\Services\Proxy\UseCases\Exceptions\CacheIsNotDefinedException */ public function WithCacheConfigurationWithoutCacheContext_CacheUseCase_ThrowException() { - $this->configLoader->load('DefaultConfiguration.yml'); + $this->expectException(CacheIsNotDefinedException::class); + + $this->configLoader->load('DefaultConfiguration.php'); $this->container->compile(); $this->container->get('openclassrooms.tests.use_cases.configuration_cache_use_case_stub'); @@ -30,12 +32,11 @@ public function WithCacheConfiguration_CacheUseCase_ReturnUseCaseProxy() { $this->container = new ContainerBuilder(); - $this->initCacheBundle(); $this->initUseCaseBundle(); $this->initServiceLoader(); $this->initConfigLoader(); $this->serviceLoader->load('cache_configuration_services.xml'); - $this->configLoader->load('CacheConfiguration.yml'); + $this->configLoader->load('CacheConfiguration.php'); $this->container->compile(); /** @var UseCaseProxy $useCaseProxy */ @@ -44,7 +45,7 @@ public function WithCacheConfiguration_CacheUseCase_ReturnUseCaseProxy() $this->assertUseCaseProxy($useCaseProxy); } - protected function setUp() + protected function setUp(): void { $this->initContainer(); $this->serviceLoader->load('cache_configuration_services.xml'); diff --git a/Tests/DependencyInjection/Compiler/UseCaseProxyPassTest.php b/Tests/DependencyInjection/Compiler/UseCaseProxyPassTest.php index a631022..102da36 100644 --- a/Tests/DependencyInjection/Compiler/UseCaseProxyPassTest.php +++ b/Tests/DependencyInjection/Compiler/UseCaseProxyPassTest.php @@ -2,7 +2,7 @@ namespace OpenClassrooms\Bundle\UseCaseBundle\Tests\DependencyInjection\Compiler; -use OpenClassrooms\Bundle\UseCaseBundle\Tests\DependencyInjection\AbstractDependencyInjectionTest; +use OpenClassrooms\Bundle\UseCaseBundle\Tests\DependencyInjection\AbstractDependencyInjectionTestCase; use OpenClassrooms\Bundle\UseCaseBundle\Tests\DependencyInjection\Fixtures\BusinessRules\UseCases\EventUseCaseStub; use OpenClassrooms\Bundle\UseCaseBundle\Tests\DependencyInjection\Fixtures\BusinessRules\UseCases\SecurityUseCaseStub; use OpenClassrooms\Bundle\UseCaseBundle\Tests\DependencyInjection\Fixtures\BusinessRules\UseCases\TransactionUseCaseStub; @@ -16,7 +16,7 @@ /** * @author Romain Kuzniak */ -class UseCaseProxyPassTest extends AbstractDependencyInjectionTest +class UseCaseProxyPassTest extends AbstractDependencyInjectionTestCase { /** * @test @@ -145,7 +145,7 @@ public function WithEventDispatcherEventUseCase_ReturnProxy() $this->assertEventUseCaseProxy($useCaseProxy); } - protected function setUp() + protected function setUp(): void { $this->initContainer(); $this->container->compile(); diff --git a/Tests/DependencyInjection/EventOpenClassroomsUseCaseExtensionTest.php b/Tests/DependencyInjection/EventOpenClassroomsUseCaseExtensionTest.php index b27e85c..4754642 100644 --- a/Tests/DependencyInjection/EventOpenClassroomsUseCaseExtensionTest.php +++ b/Tests/DependencyInjection/EventOpenClassroomsUseCaseExtensionTest.php @@ -2,21 +2,24 @@ namespace OpenClassrooms\Bundle\UseCaseBundle\Tests\DependencyInjection\Yaml; -use OpenClassrooms\Bundle\UseCaseBundle\Tests\DependencyInjection\AbstractDependencyInjectionTest; +use OpenClassrooms\Bundle\UseCaseBundle\Tests\DependencyInjection\AbstractDependencyInjectionTestCase; +use OpenClassrooms\UseCase\Application\Services\Proxy\UseCases\Exceptions\EventFactoryIsNotDefinedException; +use OpenClassrooms\UseCase\Application\Services\Proxy\UseCases\Exceptions\EventIsNotDefinedException; use OpenClassrooms\UseCase\Application\Services\Proxy\UseCases\UseCaseProxy; /** * @author Romain Kuzniak */ -class EventOpenClassroomsUseCaseExtensionTest extends AbstractDependencyInjectionTest +class EventOpenClassroomsUseCaseExtensionTest extends AbstractDependencyInjectionTestCase { /** * @test - * @expectedException \OpenClassrooms\UseCase\Application\Services\Proxy\UseCases\Exceptions\EventIsNotDefinedException */ public function WithEventConfigurationWithoutEvent_EventUseCase_ThrowException() { - $this->configLoader->load('EventConfiguration.yml'); + $this->expectException(EventIsNotDefinedException::class); + + $this->configLoader->load('EventConfiguration.php'); $this->container->compile(); $this->container->get('openclassrooms.tests.use_cases.configuration_event_use_case_stub'); @@ -24,12 +27,13 @@ public function WithEventConfigurationWithoutEvent_EventUseCase_ThrowException() /** * @test - * @expectedException \OpenClassrooms\UseCase\Application\Services\Proxy\UseCases\Exceptions\EventIsNotDefinedException - * @expectedExceptionMessage EventSender should be defined for use case: OpenClassrooms\Bundle\UseCaseBundle\Tests\DependencyInjection\Fixtures\BusinessRules\UseCases\EventUseCaseStub. Default EventSender: 'event_dispatcher' is not defined. */ public function WithDefaultConfigurationWithoutEvent_EventUseCase_ThrowException() { - $this->configLoader->load('DefaultConfiguration.yml'); + $this->expectException(EventIsNotDefinedException::class); + $this->expectExceptionMessage("EventSender should be defined for use case: OpenClassrooms\Bundle\UseCaseBundle\Tests\DependencyInjection\Fixtures\BusinessRules\UseCases\EventUseCaseStub. Default EventSender: 'event_dispatcher' is not defined."); + + $this->configLoader->load('DefaultConfiguration.php'); $this->container->compile(); $this->container->get('openclassrooms.tests.use_cases.configuration_event_use_case_stub'); @@ -37,11 +41,12 @@ public function WithDefaultConfigurationWithoutEvent_EventUseCase_ThrowException /** * @test - * @expectedException \OpenClassrooms\UseCase\Application\Services\Proxy\UseCases\Exceptions\EventFactoryIsNotDefinedException */ public function WithEventFactoryConfigurationWithoutEventFactory_EventUseCase_ThrowException() { - $this->configLoader->load('EventConfiguration.yml'); + $this->expectException(EventFactoryIsNotDefinedException::class); + + $this->configLoader->load('EventConfiguration.php'); $this->serviceLoader->load('event_only_services.xml'); $this->container->compile(); @@ -53,7 +58,7 @@ public function WithEventFactoryConfigurationWithoutEventFactory_EventUseCase_Th */ public function WithEventConfiguration_EventUseCase_ReturnUseCaseProxy() { - $this->configLoader->load('EventConfiguration.yml'); + $this->configLoader->load('EventConfiguration.php'); $this->serviceLoader->load('default_services.xml'); $this->container->compile(); @@ -68,7 +73,7 @@ public function WithEventConfiguration_EventUseCase_ReturnUseCaseProxy() */ public function WithDefaultConfiguration_ReturnUseCaseProxy() { - $this->configLoader->load('DefaultConfiguration.yml'); + $this->configLoader->load('DefaultConfiguration.php'); $this->serviceLoader->load('default_services.xml'); $this->container->compile(); @@ -78,7 +83,7 @@ public function WithDefaultConfiguration_ReturnUseCaseProxy() $this->assertEventUseCaseProxy($useCaseProxy); } - protected function setUp() + protected function setUp(): void { $this->initContainer(); $this->serviceLoader->load('event_configuration_services.xml'); diff --git a/Tests/DependencyInjection/Fixtures/Resources/config/CacheConfiguration.php b/Tests/DependencyInjection/Fixtures/Resources/config/CacheConfiguration.php new file mode 100644 index 0000000..5486121 --- /dev/null +++ b/Tests/DependencyInjection/Fixtures/Resources/config/CacheConfiguration.php @@ -0,0 +1,15 @@ +extension('open_classrooms_use_case', [ + 'cache' => service('default.cache') + ]); + + $container->services() + ->set('default.cache') + ->class(ArrayAdapter::class); +}; diff --git a/Tests/DependencyInjection/Fixtures/Resources/config/CacheConfiguration.yml b/Tests/DependencyInjection/Fixtures/Resources/config/CacheConfiguration.yml deleted file mode 100644 index 70e9c4d..0000000 --- a/Tests/DependencyInjection/Fixtures/Resources/config/CacheConfiguration.yml +++ /dev/null @@ -1,3 +0,0 @@ -open_classrooms_cache: - provider: array -open_classrooms_use_case: ~ diff --git a/Tests/DependencyInjection/Fixtures/Resources/config/DefaultConfiguration.php b/Tests/DependencyInjection/Fixtures/Resources/config/DefaultConfiguration.php new file mode 100644 index 0000000..4315bbe --- /dev/null +++ b/Tests/DependencyInjection/Fixtures/Resources/config/DefaultConfiguration.php @@ -0,0 +1,11 @@ +extension('open_classrooms_use_case', [ + + ]); +}; diff --git a/Tests/DependencyInjection/Fixtures/Resources/config/DefaultConfiguration.yml b/Tests/DependencyInjection/Fixtures/Resources/config/DefaultConfiguration.yml deleted file mode 100644 index aef651f..0000000 --- a/Tests/DependencyInjection/Fixtures/Resources/config/DefaultConfiguration.yml +++ /dev/null @@ -1 +0,0 @@ -open_classrooms_use_case: ~ diff --git a/Tests/DependencyInjection/Fixtures/Resources/config/EventConfiguration.php b/Tests/DependencyInjection/Fixtures/Resources/config/EventConfiguration.php new file mode 100644 index 0000000..44e1c99 --- /dev/null +++ b/Tests/DependencyInjection/Fixtures/Resources/config/EventConfiguration.php @@ -0,0 +1,10 @@ +extension('open_classrooms_use_case', [ + 'event_sender' => 'openclassrooms.tests.util.configuration_event_dispatcher_stub', + 'event_factory' => 'openclassrooms.tests.util.configuration_event_factory_stub', + ]); +}; diff --git a/Tests/DependencyInjection/Fixtures/Resources/config/EventConfiguration.yml b/Tests/DependencyInjection/Fixtures/Resources/config/EventConfiguration.yml deleted file mode 100644 index 786f77b..0000000 --- a/Tests/DependencyInjection/Fixtures/Resources/config/EventConfiguration.yml +++ /dev/null @@ -1,3 +0,0 @@ -open_classrooms_use_case: - event_sender: openclassrooms.tests.util.configuration_event_dispatcher_stub - event_factory: openclassrooms.tests.util.configuration_event_factory_stub diff --git a/Tests/DependencyInjection/Fixtures/Resources/config/SecurityConfiguration.php b/Tests/DependencyInjection/Fixtures/Resources/config/SecurityConfiguration.php new file mode 100644 index 0000000..2614065 --- /dev/null +++ b/Tests/DependencyInjection/Fixtures/Resources/config/SecurityConfiguration.php @@ -0,0 +1,9 @@ +extension('open_classrooms_use_case', [ + 'security' => 'openclassrooms.tests.util.configuration_authorization_checker_stub', + ]); +}; diff --git a/Tests/DependencyInjection/Fixtures/Resources/config/SecurityConfiguration.yml b/Tests/DependencyInjection/Fixtures/Resources/config/SecurityConfiguration.yml deleted file mode 100644 index fc9f04c..0000000 --- a/Tests/DependencyInjection/Fixtures/Resources/config/SecurityConfiguration.yml +++ /dev/null @@ -1,2 +0,0 @@ -open_classrooms_use_case: - security: openclassrooms.tests.util.configuration_authorization_checker_stub diff --git a/Tests/DependencyInjection/Fixtures/Resources/config/TransactionConfiguration.php b/Tests/DependencyInjection/Fixtures/Resources/config/TransactionConfiguration.php new file mode 100644 index 0000000..13d82f2 --- /dev/null +++ b/Tests/DependencyInjection/Fixtures/Resources/config/TransactionConfiguration.php @@ -0,0 +1,9 @@ +extension('open_classrooms_use_case', [ + 'transaction' => 'openclassrooms.tests.util.configuration_entity_manager_stub', + ]); +}; diff --git a/Tests/DependencyInjection/Fixtures/Resources/config/TransactionConfiguration.yml b/Tests/DependencyInjection/Fixtures/Resources/config/TransactionConfiguration.yml deleted file mode 100644 index aaf19c4..0000000 --- a/Tests/DependencyInjection/Fixtures/Resources/config/TransactionConfiguration.yml +++ /dev/null @@ -1,2 +0,0 @@ -open_classrooms_use_case: - transaction: openclassrooms.tests.util.configuration_entity_manager_stub diff --git a/Tests/DependencyInjection/Fixtures/Util/AuthorizationCheckerSpy.php b/Tests/DependencyInjection/Fixtures/Util/AuthorizationCheckerSpy.php index 9e5ebe4..6f178b3 100644 --- a/Tests/DependencyInjection/Fixtures/Util/AuthorizationCheckerSpy.php +++ b/Tests/DependencyInjection/Fixtures/Util/AuthorizationCheckerSpy.php @@ -43,7 +43,7 @@ public function setToken(TokenInterface $token = null) * * @return bool */ - public function isGranted($attributes, $object = null) + public function isGranted(mixed $attributes, mixed $object = null): bool { self::$isGranted = true; diff --git a/Tests/DependencyInjection/Fixtures/Util/CacheSpy.php b/Tests/DependencyInjection/Fixtures/Util/CacheSpy.php index a88c8c2..98a845e 100644 --- a/Tests/DependencyInjection/Fixtures/Util/CacheSpy.php +++ b/Tests/DependencyInjection/Fixtures/Util/CacheSpy.php @@ -2,25 +2,38 @@ namespace OpenClassrooms\Bundle\UseCaseBundle\Tests\DependencyInjection\Fixtures\Util; -use Doctrine\Common\Cache\ArrayCache; -use OpenClassrooms\Cache\Cache\CacheImpl; +use Psr\Cache\CacheItemInterface; +use Symfony\Component\Cache\Adapter\ArrayAdapter; +use Symfony\Component\Cache\CacheItem; /** * @author Romain Kuzniak */ -class CacheSpy extends CacheImpl +class CacheSpy extends ArrayAdapter { - public static $saved = false; + /** + * @var array + */ + public static array $saved = []; - public function __construct() + /** + * @var array + */ + public static array $getted = []; + + public function save(CacheItemInterface $item): bool { - $this->cache = new ArrayCache(); + self::$saved[$item->getKey()] = (new \ReflectionProperty($item, 'expiry'))->getValue($item); + + return parent::save($item); } - public function save($id, $data, $lifeTime = null) + public function getItem(mixed $key): CacheItem { - self::$saved = true; + $item = parent::getItem($key); + + self::$getted[$item->getKey()] = $item->isHit(); - return parent::save($id, $data, $lifeTime); + return $item; } } diff --git a/Tests/DependencyInjection/Fixtures/Util/ConnectionMock.php b/Tests/DependencyInjection/Fixtures/Util/ConnectionMock.php index 7d301cd..e9ab1f5 100644 --- a/Tests/DependencyInjection/Fixtures/Util/ConnectionMock.php +++ b/Tests/DependencyInjection/Fixtures/Util/ConnectionMock.php @@ -2,15 +2,13 @@ namespace OpenClassrooms\Bundle\UseCaseBundle\Tests\DependencyInjection\Fixtures\Util; -use Doctrine\DBAL\Driver\Connection as DriverConnection; -use Doctrine\DBAL\Driver\Result; -use Doctrine\DBAL\Driver\Statement; +use Doctrine\DBAL\Connection as DriverConnection; use Doctrine\DBAL\ParameterType; /** * @author Romain Kuzniak */ -class ConnectionMock implements DriverConnection +class ConnectionMock extends DriverConnection { /** * @var bool @@ -44,19 +42,19 @@ public function getConnection(): self return new ConnectionMock(); } - public function beginTransaction() + public function beginTransaction(): void { self::$transactionNumber++; self::$transactionBegin = true; } - public function commit() + public function commit(): void { self::$committed = true; ConnectionMock::$transactionNumber--; } - public function rollback() + public function rollback(): void { self::$rollBacked = true; ConnectionMock::$transactionNumber--; @@ -65,7 +63,7 @@ public function rollback() /** * @return bool */ - public function isTransactionActive() + public function isTransactionActive(): bool { return self::$transactionNumber > 0; } @@ -73,7 +71,7 @@ public function isTransactionActive() /** * {@inheritDoc} */ - public function prepare($sql): StatementSpy + public function prepare(string $sql): StatementSpy { return new StatementSpy(); } @@ -89,7 +87,7 @@ public function query(string $sql): ResultSpy /** * {@inheritDoc} */ - public function quote($value, $type = ParameterType::STRING) + public function quote($value, $type = ParameterType::STRING): string { return null; } @@ -97,7 +95,7 @@ public function quote($value, $type = ParameterType::STRING) /** * {@inheritDoc} */ - public function exec($sql): int + public function exec(string $sql): int { return 1; } @@ -105,9 +103,9 @@ public function exec($sql): int /** * {@inheritDoc} */ - public function lastInsertId($name = null) + public function lastInsertId($name = null): int|string { - return null; + return 1; } /** @@ -125,4 +123,14 @@ public function errorInfo() { return null; } + + public function getNativeConnection() + { + // TODO: Implement getNativeConnection() method. + } + + public function getServerVersion(): string + { + // TODO: Implement getServerVersion() method. + } } diff --git a/Tests/DependencyInjection/Fixtures/Util/EntityManagerSpy.php b/Tests/DependencyInjection/Fixtures/Util/EntityManagerSpy.php index a1c8db5..6f15e3b 100644 --- a/Tests/DependencyInjection/Fixtures/Util/EntityManagerSpy.php +++ b/Tests/DependencyInjection/Fixtures/Util/EntityManagerSpy.php @@ -26,27 +26,27 @@ public function __construct() self::$flushed = false; } - public function getConnection() + public function getConnection(): Connection { return $this->conn; } - public function beginTransaction() + public function beginTransaction(): void { $this->conn->beginTransaction(); } - public function flush($entity = null) + public function flush($entity = null): void { self::$flushed = true; } - public function commit() + public function commit(): void { $this->conn->commit(); } - public function rollback() + public function rollback(): void { $this->conn->rollback(); } diff --git a/Tests/DependencyInjection/Fixtures/Util/EventDispatcherSpy.php b/Tests/DependencyInjection/Fixtures/Util/EventDispatcherSpy.php index d36a70b..bfd0aa0 100644 --- a/Tests/DependencyInjection/Fixtures/Util/EventDispatcherSpy.php +++ b/Tests/DependencyInjection/Fixtures/Util/EventDispatcherSpy.php @@ -30,6 +30,6 @@ public function dispatch(object $event, string $eventName = null): object self::$eventName = $eventName; self::$sent = true; - parent::dispatch($event, $eventName); + return parent::dispatch($event, $eventName); } } diff --git a/Tests/DependencyInjection/Fixtures/Util/EventFactorySpy.php b/Tests/DependencyInjection/Fixtures/Util/EventFactorySpy.php index 3d5a0c3..cc2666d 100644 --- a/Tests/DependencyInjection/Fixtures/Util/EventFactorySpy.php +++ b/Tests/DependencyInjection/Fixtures/Util/EventFactorySpy.php @@ -7,7 +7,7 @@ use OpenClassrooms\UseCase\Application\Services\Event\Exceptions\InvalidEventNameException; use OpenClassrooms\UseCase\BusinessRules\Requestors\UseCaseRequest; use OpenClassrooms\UseCase\BusinessRules\Responders\UseCaseResponse; -use Symfony\Component\EventDispatcher\Event; +use Symfony\Contracts\EventDispatcher\Event; /** * @author Romain Kuzniak diff --git a/Tests/DependencyInjection/Fixtures/Util/NotGrantedAuthorizationCheckerStub.php b/Tests/DependencyInjection/Fixtures/Util/NotGrantedAuthorizationCheckerStub.php index 8411412..11b9505 100644 --- a/Tests/DependencyInjection/Fixtures/Util/NotGrantedAuthorizationCheckerStub.php +++ b/Tests/DependencyInjection/Fixtures/Util/NotGrantedAuthorizationCheckerStub.php @@ -38,7 +38,7 @@ public function setToken(TokenInterface $token = null) * * @return bool */ - public function isGranted($attributes, $object = null) + public function isGranted($attributes, $object = null): bool { return false; } diff --git a/Tests/DependencyInjection/Fixtures/Util/ResultSpy.php b/Tests/DependencyInjection/Fixtures/Util/ResultSpy.php index f4cdab0..6e491b5 100644 --- a/Tests/DependencyInjection/Fixtures/Util/ResultSpy.php +++ b/Tests/DependencyInjection/Fixtures/Util/ResultSpy.php @@ -2,19 +2,24 @@ namespace OpenClassrooms\Bundle\UseCaseBundle\Tests\DependencyInjection\Fixtures\Util; -use Doctrine\DBAL\Driver\Result; +use Doctrine\DBAL\Result; -class ResultSpy implements Result +class ResultSpy extends Result { - public function fetchNumeric() + public function __construct() + { + + } + + public function fetchNumeric(): false|array { } - public function fetchAssociative() + public function fetchAssociative(): false|array { } - public function fetchOne() + public function fetchOne(): mixed { } @@ -41,4 +46,6 @@ public function columnCount(): int public function free(): void { } + + } diff --git a/Tests/DependencyInjection/Fixtures/Util/StatementSpy.php b/Tests/DependencyInjection/Fixtures/Util/StatementSpy.php index f6dc2b9..320eaa1 100644 --- a/Tests/DependencyInjection/Fixtures/Util/StatementSpy.php +++ b/Tests/DependencyInjection/Fixtures/Util/StatementSpy.php @@ -2,13 +2,18 @@ namespace OpenClassrooms\Bundle\UseCaseBundle\Tests\DependencyInjection\Fixtures\Util; -use Doctrine\DBAL\Driver\Result; -use Doctrine\DBAL\Driver\Statement; +use Doctrine\DBAL\Result; +use Doctrine\DBAL\Statement; use Doctrine\DBAL\ParameterType; -class StatementSpy implements Statement +class StatementSpy extends Statement { - public function bindValue($param, $value, $type = ParameterType::STRING) + public function __construct() + { + + } + + public function bindValue($param, $value, $type = ParameterType::STRING): void { } diff --git a/Tests/DependencyInjection/SecurityOpenClassroomsUseCaseExtensionTest.php b/Tests/DependencyInjection/SecurityOpenClassroomsUseCaseExtensionTest.php index 6c26c24..fd159a6 100644 --- a/Tests/DependencyInjection/SecurityOpenClassroomsUseCaseExtensionTest.php +++ b/Tests/DependencyInjection/SecurityOpenClassroomsUseCaseExtensionTest.php @@ -2,21 +2,23 @@ namespace OpenClassrooms\Bundle\UseCaseBundle\Tests\DependencyInjection\Yaml; -use OpenClassrooms\Bundle\UseCaseBundle\Tests\DependencyInjection\AbstractDependencyInjectionTest; +use OpenClassrooms\Bundle\UseCaseBundle\Tests\DependencyInjection\AbstractDependencyInjectionTestCase; +use OpenClassrooms\UseCase\Application\Services\Proxy\UseCases\Exceptions\SecurityIsNotDefinedException; use OpenClassrooms\UseCase\Application\Services\Proxy\UseCases\UseCaseProxy; /** * @author Romain Kuzniak */ -class SecurityOpenClassroomsUseCaseExtensionTest extends AbstractDependencyInjectionTest +class SecurityOpenClassroomsUseCaseExtensionTest extends AbstractDependencyInjectionTestCase { /** * @test - * @expectedException \OpenClassrooms\UseCase\Application\Services\Proxy\UseCases\Exceptions\SecurityIsNotDefinedException */ public function WithSecurityConfigurationWithoutSecurityContext_SecurityUseCase_ThrowException() { - $this->configLoader->load('SecurityConfiguration.yml'); + $this->expectException(SecurityIsNotDefinedException::class); + + $this->configLoader->load('SecurityConfiguration.php'); $this->container->compile(); $this->container->get('openclassrooms.tests.use_cases.configuration_security_use_case_stub'); @@ -24,11 +26,12 @@ public function WithSecurityConfigurationWithoutSecurityContext_SecurityUseCase_ /** * @test - * @expectedException \OpenClassrooms\UseCase\Application\Services\Proxy\UseCases\Exceptions\SecurityIsNotDefinedException */ public function WithDefaultConfigurationWithoutSecurityContext_SecurityUseCase_ThrowException() { - $this->configLoader->load('DefaultConfiguration.yml'); + $this->expectException(SecurityIsNotDefinedException::class); + + $this->configLoader->load('DefaultConfiguration.php'); $this->container->compile(); $this->container->get('openclassrooms.tests.use_cases.configuration_security_use_case_stub'); @@ -39,7 +42,7 @@ public function WithDefaultConfigurationWithoutSecurityContext_SecurityUseCase_T */ public function WithSecurityConfiguration_SecurityUseCase_ReturnUseCaseProxy() { - $this->configLoader->load('SecurityConfiguration.yml'); + $this->configLoader->load('SecurityConfiguration.php'); $this->serviceLoader->load('default_services.xml'); $this->container->compile(); @@ -54,7 +57,7 @@ public function WithSecurityConfiguration_SecurityUseCase_ReturnUseCaseProxy() */ public function WithDefaultConfiguration_ReturnUseCaseProxy() { - $this->configLoader->load('DefaultConfiguration.yml'); + $this->configLoader->load('DefaultConfiguration.php'); $this->serviceLoader->load('default_services.xml'); $this->container->compile(); @@ -64,7 +67,7 @@ public function WithDefaultConfiguration_ReturnUseCaseProxy() $this->assertSecurityUseCaseProxy($useCaseProxy); } - protected function setUp() + protected function setUp(): void { $this->initContainer(); $this->serviceLoader->load('security_configuration_services.xml'); diff --git a/Tests/DependencyInjection/TransactionOpenClassroomsUseCaseExtensionTest.php b/Tests/DependencyInjection/TransactionOpenClassroomsUseCaseExtensionTest.php index 6479e5f..662dbd2 100644 --- a/Tests/DependencyInjection/TransactionOpenClassroomsUseCaseExtensionTest.php +++ b/Tests/DependencyInjection/TransactionOpenClassroomsUseCaseExtensionTest.php @@ -2,21 +2,23 @@ namespace OpenClassrooms\Bundle\UseCaseBundle\Tests\DependencyInjection\Yaml; -use OpenClassrooms\Bundle\UseCaseBundle\Tests\DependencyInjection\AbstractDependencyInjectionTest; +use OpenClassrooms\Bundle\UseCaseBundle\Tests\DependencyInjection\AbstractDependencyInjectionTestCase; +use OpenClassrooms\UseCase\Application\Services\Proxy\UseCases\Exceptions\TransactionIsNotDefinedException; use OpenClassrooms\UseCase\Application\Services\Proxy\UseCases\UseCaseProxy; /** * @author Romain Kuzniak */ -class TransactionOpenClassroomsUseCaseExtensionTest extends AbstractDependencyInjectionTest +class TransactionOpenClassroomsUseCaseExtensionTest extends AbstractDependencyInjectionTestCase { /** * @test - * @expectedException \OpenClassrooms\UseCase\Application\Services\Proxy\UseCases\Exceptions\TransactionIsNotDefinedException */ public function WithTransactionConfigurationWithoutTransaction_TransactionUseCase_ThrowException() { - $this->configLoader->load('TransactionConfiguration.yml'); + $this->expectException(TransactionIsNotDefinedException::class); + + $this->configLoader->load('TransactionConfiguration.php'); $this->container->compile(); $this->container->get('openclassrooms.tests.use_cases.configuration_transaction_use_case_stub'); @@ -24,12 +26,13 @@ public function WithTransactionConfigurationWithoutTransaction_TransactionUseCas /** * @test - * @expectedException \OpenClassrooms\UseCase\Application\Services\Proxy\UseCases\Exceptions\TransactionIsNotDefinedException - * @expectedExceptionMessage Transaction should be defined for use case: OpenClassrooms\Bundle\UseCaseBundle\Tests\DependencyInjection\Fixtures\BusinessRules\UseCases\TransactionUseCaseStub. Default entity manager: 'doctrine.orm.entity_manager' is not defined. */ public function WithDefaultConfigurationWithoutTransaction_TransactionUseCase_ThrowException() { - $this->configLoader->load('DefaultConfiguration.yml'); + $this->expectException(TransactionIsNotDefinedException::class); + $this->expectExceptionMessage("Transaction should be defined for use case: OpenClassrooms\Bundle\UseCaseBundle\Tests\DependencyInjection\Fixtures\BusinessRules\UseCases\TransactionUseCaseStub. Default entity manager: 'doctrine.orm.entity_manager' is not defined."); + + $this->configLoader->load('DefaultConfiguration.php'); $this->container->compile(); $this->container->get('openclassrooms.tests.use_cases.configuration_transaction_use_case_stub'); @@ -40,7 +43,7 @@ public function WithDefaultConfigurationWithoutTransaction_TransactionUseCase_Th */ public function WithTransactionConfiguration_TransactionUseCase_ReturnUseCaseProxy() { - $this->configLoader->load('TransactionConfiguration.yml'); + $this->configLoader->load('TransactionConfiguration.php'); $this->serviceLoader->load('default_services.xml'); $this->container->compile(); @@ -55,7 +58,7 @@ public function WithTransactionConfiguration_TransactionUseCase_ReturnUseCasePro */ public function WithDefaultConfiguration_ReturnUseCaseProxy() { - $this->configLoader->load('DefaultConfiguration.yml'); + $this->configLoader->load('DefaultConfiguration.php'); $this->serviceLoader->load('default_services.xml'); $this->container->compile(); @@ -65,7 +68,7 @@ public function WithDefaultConfiguration_ReturnUseCaseProxy() $this->assertTransactionUseCaseProxy($useCaseProxy); } - protected function setUp() + protected function setUp(): void { $this->initContainer(); $this->serviceLoader->load('transaction_configuration_services.xml'); diff --git a/Tests/Services/Security/Impl/AuthorizationCheckerSecurityAdapterTest.php b/Tests/Services/Security/Impl/AuthorizationCheckerSecurityAdapterTest.php index 35e16d5..8808c51 100644 --- a/Tests/Services/Security/Impl/AuthorizationCheckerSecurityAdapterTest.php +++ b/Tests/Services/Security/Impl/AuthorizationCheckerSecurityAdapterTest.php @@ -6,6 +6,7 @@ use OpenClassrooms\Bundle\UseCaseBundle\Tests\DependencyInjection\Fixtures\Util\AuthorizationCheckerSpy; use OpenClassrooms\Bundle\UseCaseBundle\Tests\DependencyInjection\Fixtures\Util\NotGrantedAuthorizationCheckerStub; use PHPUnit\Framework\TestCase; +use Symfony\Component\Security\Core\Exception\AccessDeniedException; /** * @author Romain Kuzniak @@ -19,16 +20,17 @@ class AuthorizationCheckerSecurityAdapterTest extends TestCase public function IsGranted_DonTThrowException() { $security = new AuthorizationCheckerSecurityAdapter(new AuthorizationCheckerSpy()); - $security->checkAccess(array()); + $security->checkAccess(['ROLE_USER']); } /** * @test - * @expectedException \Symfony\Component\Security\Core\Exception\AccessDeniedException */ public function IsNotGranted_ThrowAccessDeniedException() { + $this->expectException(AccessDeniedException::class); + $security = new AuthorizationCheckerSecurityAdapter(new NotGrantedAuthorizationCheckerStub()); - $security->checkAccess(array()); + $security->checkAccess(['ROLE_USER']); } } diff --git a/Tests/Services/Transaction/Impl/DoctrineDBALConnectionTransactionAdapterTest.php b/Tests/Services/Transaction/Impl/DoctrineDBALConnectionTransactionAdapterTest.php index dcf27a7..c7fe671 100644 --- a/Tests/Services/Transaction/Impl/DoctrineDBALConnectionTransactionAdapterTest.php +++ b/Tests/Services/Transaction/Impl/DoctrineDBALConnectionTransactionAdapterTest.php @@ -70,7 +70,7 @@ public function RollBack() $this->assertFalse($this->transaction->isTransactionActive()); } - protected function setUp() + protected function setUp(): void { ConnectionMock::$transactionNumber = 0; $this->entityManager = new EntityManagerSpy(); diff --git a/Tests/Services/Transaction/Impl/EntityManagerTransactionAdapterTest.php b/Tests/Services/Transaction/Impl/EntityManagerTransactionAdapterTest.php index 339a2aa..b2daf27 100644 --- a/Tests/Services/Transaction/Impl/EntityManagerTransactionAdapterTest.php +++ b/Tests/Services/Transaction/Impl/EntityManagerTransactionAdapterTest.php @@ -71,7 +71,7 @@ public function RollBack() $this->assertFalse($this->transaction->isTransactionActive()); } - protected function setUp() + protected function setUp():void { ConnectionMock::$transactionNumber = 0; $this->entityManager = new EntityManagerSpy(); diff --git a/Tests/bootstrap.php b/Tests/bootstrap.php index 5e378ec..72913f7 100644 --- a/Tests/bootstrap.php +++ b/Tests/bootstrap.php @@ -3,12 +3,7 @@ namespace OpenClassrooms\Bundle\UseCaseBundle\Tests; use Composer\Autoload\ClassLoader; -use Doctrine\Common\Annotations\AnnotationRegistry; error_reporting(E_ALL | E_STRICT); /** @var ClassLoader $loader */ require __DIR__.'/../vendor/autoload.php'; -AnnotationRegistry::registerAutoloadNamespace( - 'OpenClassrooms\UseCase\Application\Annotations', - dirname(__DIR__).'/vendor/openclassrooms/use-case/src' -); diff --git a/composer.json b/composer.json index 05c3922..6b63d06 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,6 @@ { "name": "openclassrooms/use-case-bundle", - "description": "Symfony2 Bundle for OpenClassrooms UseCase", + "description": "Symfony Bundle for OpenClassrooms UseCase", "type": "symfony-bundle", "keywords": ["design"], "license": "MIT", @@ -20,19 +20,19 @@ } }, "require": { - "php": ">=7.1", - "openclassrooms/use-case": "^v1.1.1", - "openclassrooms/cache-bundle": "^v2.2.1", - "openclassrooms/cache": "v1.1.0", - "symfony/dependency-injection": "~5.0 || ~6.4 || ~7.1", + "php": ">=8.2", + "openclassrooms/use-case": "^2.0", + "symfony/cache": "~5.4 || ~6.4 || ~7.1", + "symfony/dependency-injection": "~5.4 || ~6.4 || ~7.1", "symfony/config": "~5.0 || ~6.4 || ~7.1", "symfony/http-kernel": "~5.0 || ~6.4 || ~7.1 || ~7.1", "symfony/security-core": "~5.0 || ~6.4 || ~7.1", "doctrine/orm": "~2.3 || ~3.2", + "doctrine/dbal": "~3.2", "symfony/event-dispatcher": "~5.0 || ~6.4 || ~7.1" }, "require-dev": { - "phpunit/phpunit": "~9.6" + "phpunit/phpunit": "^10" }, "extra": { "branch-alias": { diff --git a/devenv.lock b/devenv.lock new file mode 100644 index 0000000..065914a --- /dev/null +++ b/devenv.lock @@ -0,0 +1,103 @@ +{ + "nodes": { + "devenv": { + "locked": { + "dir": "src/modules", + "lastModified": 1738414267, + "owner": "cachix", + "repo": "devenv", + "rev": "3f49b4afbb9a80b1e81fb6071f59dac152177efa", + "type": "github" + }, + "original": { + "dir": "src/modules", + "owner": "cachix", + "repo": "devenv", + "type": "github" + } + }, + "flake-compat": { + "flake": false, + "locked": { + "lastModified": 1733328505, + "owner": "edolstra", + "repo": "flake-compat", + "rev": "ff81ac966bb2cae68946d5ed5fc4994f96d0ffec", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "git-hooks": { + "inputs": { + "flake-compat": "flake-compat", + "gitignore": "gitignore", + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1737465171, + "owner": "cachix", + "repo": "git-hooks.nix", + "rev": "9364dc02281ce2d37a1f55b6e51f7c0f65a75f17", + "type": "github" + }, + "original": { + "owner": "cachix", + "repo": "git-hooks.nix", + "type": "github" + } + }, + "gitignore": { + "inputs": { + "nixpkgs": [ + "git-hooks", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1709087332, + "owner": "hercules-ci", + "repo": "gitignore.nix", + "rev": "637db329424fd7e46cf4185293b9cc8c88c95394", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "repo": "gitignore.nix", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1738484997, + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "d1a8431d9fb2262e4b43e8f013093c226415a657", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixpkgs-24.11-darwin", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "devenv": "devenv", + "git-hooks": "git-hooks", + "nixpkgs": "nixpkgs", + "pre-commit-hooks": [ + "git-hooks" + ] + } + } + }, + "root": "root", + "version": 7 +} diff --git a/devenv.nix b/devenv.nix new file mode 100644 index 0000000..aaf9a65 --- /dev/null +++ b/devenv.nix @@ -0,0 +1,22 @@ +{ pkgs, lib, config, ... }: + +let + profile = ".devenv/profile"; + composerJson = builtins.fromJSON (builtins.readFile ./composer.json); + requiredPackages = builtins.attrNames composerJson.require; + phpExtensionsDirty = builtins.filter + (name: + builtins.match "ext-.*" name != null && + !builtins.elem (builtins.substring 4 100 name) [ "json" "libxml" "xml" ] + ) + requiredPackages; + phpExtensions = builtins.map (name: builtins.replaceStrings [ "ext-" ] [ "" ] name) phpExtensionsDirty; +in +{ + languages.php = { + enable = true; + version = lib.mkDefault "8.2"; + extensions = phpExtensions ++ [ "xdebug" ]; + }; + +} diff --git a/devenv.yaml b/devenv.yaml new file mode 100644 index 0000000..705d148 --- /dev/null +++ b/devenv.yaml @@ -0,0 +1,3 @@ +inputs: + nixpkgs: + url: github:NixOS/nixpkgs/nixpkgs-24.11-darwin diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 90dc45a..2f9c6d5 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,30 +1,17 @@ - - - + - + ./Tests/ - - - . - - ./Resources - ./Tests - ./vendor - - - + + + ./DependencyInjection + ./Services + + -