Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Doctrine requirement is now optional #942

Merged
merged 3 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
"babdev/pagerfanta-bundle": "^3.7 || ^4.0",
"doctrine/annotations": "^2.0",
"doctrine/collections": "^1.8 || ^2.0",
"doctrine/doctrine-bundle": "^2.0",
"doctrine/event-manager": "^1.1 || ^2.0",
"doctrine/inflector": "^1.4 || ^2.0",
"doctrine/persistence": "^2.0 || ^3.0",
Expand Down Expand Up @@ -57,6 +56,7 @@
"sylius/resource": "self.version"
},
"require-dev": {
"doctrine/doctrine-bundle": "^2.0",
"doctrine/orm": "^2.5",
"friendsofsymfony/rest-bundle": "^3.0",
"jms/serializer-bundle": "^3.5 || ^4.0 || ^5.0",
Expand Down Expand Up @@ -89,6 +89,7 @@
"willdurand/hateoas-bundle": "^2.0"
},
"conflict": {
"doctrine/doctrine-bundle": "<2.0 || ^3.0",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cause it has been moved on dev requirement, we have to ensure the right version is installed.

"friendsofsymfony/rest-bundle": "<3.0",
"jms/serializer-bundle": "<3.5",
"willdurand/hateoas-bundle": "<2.0 || ^2.6",
Expand All @@ -102,7 +103,8 @@
"allow-plugins": {
"symfony/flex": true,
"dealerdirect/phpcodesniffer-composer-installer": false
}
},
"sort-packages": true
},
"extra": {
"symfony": {
Expand Down
2 changes: 1 addition & 1 deletion src/Bundle/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ private function addDriversSection(ArrayNodeDefinition $node): void
$node
->children()
->arrayNode('drivers')
->defaultValue([SyliusResourceBundle::DRIVER_DOCTRINE_ORM])
->defaultValue([])
->enumPrototype()->values(SyliusResourceBundle::getAvailableDrivers())->end()
->end()
->end()
Expand Down
111 changes: 94 additions & 17 deletions src/Bundle/DependencyInjection/SyliusResourceExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@

$loader->load('services.xml');

/** @var array $bundles */
/** @var array<string, string> $bundles */
$bundles = $container->getParameter('kernel.bundles');
if (array_key_exists('SyliusGridBundle', $bundles)) {
$loader->load('services/integrations/grid.xml');
Expand All @@ -68,7 +68,7 @@

$this->autoRegisterResources($config, $container);

$this->loadPersistence($config['drivers'], $config['resources'], $loader);
$this->loadPersistence($config['drivers'], $config['resources'], $loader, $container);
$this->loadResources($config['resources'], $container);

$container->registerForAutoconfiguration(ProviderInterface::class)
Expand Down Expand Up @@ -175,8 +175,20 @@
return 'app.' . u($shortName)->snake()->toString();
}

private function loadPersistence(array $drivers, array $resources, LoaderInterface $loader): void
/**
* @param array<string, array{driver: string|false}> $resources
*/
private function loadPersistence(array $drivers, array $resources, LoaderInterface $loader, ContainerBuilder $container): void
{
$availableDrivers = $this->getAvailableDrivers($container);

// Enable all available drivers if there is no configured drivers
$drivers = [] !== $drivers ? $drivers : $availableDrivers;

$resourceDrivers = $this->getResourceDrivers($resources);

$this->checkConfiguredDrivers($drivers, $availableDrivers, $resourceDrivers);

$integrateDoctrine = array_reduce($drivers, function (bool $result, string $driver): bool {
return $result || in_array($driver, [SyliusResourceBundle::DRIVER_DOCTRINE_ORM, SyliusResourceBundle::DRIVER_DOCTRINE_PHPCR_ODM, SyliusResourceBundle::DRIVER_DOCTRINE_MONGODB_ODM], true);
}, false);
Expand All @@ -185,20 +197,6 @@
$loader->load('services/integrations/doctrine.xml');
}

foreach ($resources as $alias => $resource) {
if (false === $resource['driver']) {
break;
}

if (!in_array($resource['driver'], $drivers, true)) {
throw new InvalidArgumentException(sprintf(
'Resource "%s" uses driver "%s", but this driver has not been enabled.',
$alias,
$resource['driver'],
));
}
}

foreach ($drivers as $driver) {
if (in_array($driver, [SyliusResourceBundle::DRIVER_DOCTRINE_PHPCR_ODM, SyliusResourceBundle::DRIVER_DOCTRINE_MONGODB_ODM], true)) {
trigger_deprecation(
Expand All @@ -209,10 +207,89 @@
);
}

// Only Doctrine drivers need service integration file
if (!str_starts_with($driver, 'doctrine')) {
continue;
}

$loader->load(sprintf('services/integrations/%s.xml', $driver));
}
}

/**
* @param array<string, array{driver: string|false}> $resources
*
* @return array<string, string>
*/
private function getResourceDrivers(array $resources): array
{
$resourceDrivers = array_map(function (array $resource): string|false {
return $resource['driver'] ?? false;
}, $resources);

// Remove resources with disabled driver
return array_filter($resourceDrivers, function (string|false $driver): bool {
return false !== $driver;
});
}

private function getAvailableDrivers(ContainerBuilder $container): array
{
$availableDrivers = [];

if ($container::willBeAvailable(SyliusResourceBundle::DRIVER_DOCTRINE_ORM, \Doctrine\ORM\EntityManagerInterface::class, ['doctrine/doctrine-bundle'])) {
$availableDrivers[] = SyliusResourceBundle::DRIVER_DOCTRINE_ORM;
}

if ($container::willBeAvailable(SyliusResourceBundle::DRIVER_DOCTRINE_PHPCR_ODM, \Doctrine\ODM\PHPCR\Document\Resource::class, ['doctrine/doctrine-bundle'])) {

Check failure on line 244 in src/Bundle/DependencyInjection/SyliusResourceExtension.php

View workflow job for this annotation

GitHub Actions / PHP 8.3, Symfony ^7.0, Persistence: , Collections:

UndefinedClass

src/Bundle/DependencyInjection/SyliusResourceExtension.php:244:90: UndefinedClass: Class, interface or enum named Doctrine\ODM\PHPCR\Document\Resource does not exist (see https://psalm.dev/019)

Check failure on line 244 in src/Bundle/DependencyInjection/SyliusResourceExtension.php

View workflow job for this annotation

GitHub Actions / PHP 8.1, Symfony ^5.4, Persistence: , Collections:

UndefinedClass

src/Bundle/DependencyInjection/SyliusResourceExtension.php:244:90: UndefinedClass: Class, interface or enum named Doctrine\ODM\PHPCR\Document\Resource does not exist (see https://psalm.dev/019)

Check failure on line 244 in src/Bundle/DependencyInjection/SyliusResourceExtension.php

View workflow job for this annotation

GitHub Actions / PHP 8.2, Symfony ^5.4, Persistence: ^3.0, Collections: ^1.8

UndefinedClass

src/Bundle/DependencyInjection/SyliusResourceExtension.php:244:90: UndefinedClass: Class, interface or enum named Doctrine\ODM\PHPCR\Document\Resource does not exist (see https://psalm.dev/019)

Check failure on line 244 in src/Bundle/DependencyInjection/SyliusResourceExtension.php

View workflow job for this annotation

GitHub Actions / PHP 8.2, Symfony ^5.4, Persistence: ^3.0, Collections: ^2.0

UndefinedClass

src/Bundle/DependencyInjection/SyliusResourceExtension.php:244:90: UndefinedClass: Class, interface or enum named Doctrine\ODM\PHPCR\Document\Resource does not exist (see https://psalm.dev/019)

Check failure on line 244 in src/Bundle/DependencyInjection/SyliusResourceExtension.php

View workflow job for this annotation

GitHub Actions / PHP 8.1, Symfony ^6.4, Persistence: ^3.0, Collections: ^2.0

UndefinedClass

src/Bundle/DependencyInjection/SyliusResourceExtension.php:244:90: UndefinedClass: Class, interface or enum named Doctrine\ODM\PHPCR\Document\Resource does not exist (see https://psalm.dev/019)

Check failure on line 244 in src/Bundle/DependencyInjection/SyliusResourceExtension.php

View workflow job for this annotation

GitHub Actions / PHP 8.3, Symfony ^6.4, Persistence: ^3.0, Collections: ^2.0

UndefinedClass

src/Bundle/DependencyInjection/SyliusResourceExtension.php:244:90: UndefinedClass: Class, interface or enum named Doctrine\ODM\PHPCR\Document\Resource does not exist (see https://psalm.dev/019)

Check failure on line 244 in src/Bundle/DependencyInjection/SyliusResourceExtension.php

View workflow job for this annotation

GitHub Actions / PHP 8.3, Symfony ^5.4, Persistence: ^3.0, Collections: ^1.8

UndefinedClass

src/Bundle/DependencyInjection/SyliusResourceExtension.php:244:90: UndefinedClass: Class, interface or enum named Doctrine\ODM\PHPCR\Document\Resource does not exist (see https://psalm.dev/019)

Check failure on line 244 in src/Bundle/DependencyInjection/SyliusResourceExtension.php

View workflow job for this annotation

GitHub Actions / PHP 8.2, Symfony ^6.4, Persistence: ^3.0, Collections: ^1.8

UndefinedClass

src/Bundle/DependencyInjection/SyliusResourceExtension.php:244:90: UndefinedClass: Class, interface or enum named Doctrine\ODM\PHPCR\Document\Resource does not exist (see https://psalm.dev/019)

Check failure on line 244 in src/Bundle/DependencyInjection/SyliusResourceExtension.php

View workflow job for this annotation

GitHub Actions / PHP 8.1, Symfony ^5.4, Persistence: ^2.0, Collections: ^1.8

UndefinedClass

src/Bundle/DependencyInjection/SyliusResourceExtension.php:244:90: UndefinedClass: Class, interface or enum named Doctrine\ODM\PHPCR\Document\Resource does not exist (see https://psalm.dev/019)

Check failure on line 244 in src/Bundle/DependencyInjection/SyliusResourceExtension.php

View workflow job for this annotation

GitHub Actions / PHP 8.1, Symfony ^5.4, Persistence: ^3.0, Collections: ^1.8

UndefinedClass

src/Bundle/DependencyInjection/SyliusResourceExtension.php:244:90: UndefinedClass: Class, interface or enum named Doctrine\ODM\PHPCR\Document\Resource does not exist (see https://psalm.dev/019)

Check failure on line 244 in src/Bundle/DependencyInjection/SyliusResourceExtension.php

View workflow job for this annotation

GitHub Actions / PHP 8.3, Symfony ^6.4, Persistence: ^3.0, Collections: ^1.8

UndefinedClass

src/Bundle/DependencyInjection/SyliusResourceExtension.php:244:90: UndefinedClass: Class, interface or enum named Doctrine\ODM\PHPCR\Document\Resource does not exist (see https://psalm.dev/019)

Check failure on line 244 in src/Bundle/DependencyInjection/SyliusResourceExtension.php

View workflow job for this annotation

GitHub Actions / PHP 8.1, Symfony ^5.4, Persistence: ^3.0, Collections: ^2.0

UndefinedClass

src/Bundle/DependencyInjection/SyliusResourceExtension.php:244:90: UndefinedClass: Class, interface or enum named Doctrine\ODM\PHPCR\Document\Resource does not exist (see https://psalm.dev/019)

Check failure on line 244 in src/Bundle/DependencyInjection/SyliusResourceExtension.php

View workflow job for this annotation

GitHub Actions / PHP 8.1, Symfony ^6.4, Persistence: ^3.0, Collections: ^1.8

UndefinedClass

src/Bundle/DependencyInjection/SyliusResourceExtension.php:244:90: UndefinedClass: Class, interface or enum named Doctrine\ODM\PHPCR\Document\Resource does not exist (see https://psalm.dev/019)

Check failure on line 244 in src/Bundle/DependencyInjection/SyliusResourceExtension.php

View workflow job for this annotation

GitHub Actions / PHP 8.3, Symfony ^5.4, Persistence: ^3.0, Collections: ^2.0

UndefinedClass

src/Bundle/DependencyInjection/SyliusResourceExtension.php:244:90: UndefinedClass: Class, interface or enum named Doctrine\ODM\PHPCR\Document\Resource does not exist (see https://psalm.dev/019)

Check failure on line 244 in src/Bundle/DependencyInjection/SyliusResourceExtension.php

View workflow job for this annotation

GitHub Actions / PHP 8.3, Symfony ^5.4, Persistence: ^2.0, Collections: ^1.8

UndefinedClass

src/Bundle/DependencyInjection/SyliusResourceExtension.php:244:90: UndefinedClass: Class, interface or enum named Doctrine\ODM\PHPCR\Document\Resource does not exist (see https://psalm.dev/019)

Check failure on line 244 in src/Bundle/DependencyInjection/SyliusResourceExtension.php

View workflow job for this annotation

GitHub Actions / PHP 8.2, Symfony ^6.4, Persistence: ^3.0, Collections: ^2.0

UndefinedClass

src/Bundle/DependencyInjection/SyliusResourceExtension.php:244:90: UndefinedClass: Class, interface or enum named Doctrine\ODM\PHPCR\Document\Resource does not exist (see https://psalm.dev/019)

Check failure on line 244 in src/Bundle/DependencyInjection/SyliusResourceExtension.php

View workflow job for this annotation

GitHub Actions / PHP 8.2, Symfony ^5.4, Persistence: ^2.0, Collections: ^1.8

UndefinedClass

src/Bundle/DependencyInjection/SyliusResourceExtension.php:244:90: UndefinedClass: Class, interface or enum named Doctrine\ODM\PHPCR\Document\Resource does not exist (see https://psalm.dev/019)
$availableDrivers[] = SyliusResourceBundle::DRIVER_DOCTRINE_PHPCR_ODM;
}

if ($container::willBeAvailable(SyliusResourceBundle::DRIVER_DOCTRINE_MONGODB_ODM, \Doctrine\ODM\MongoDB\DocumentManager::class, ['doctrine/doctrine-bundle'])) {

Check failure on line 248 in src/Bundle/DependencyInjection/SyliusResourceExtension.php

View workflow job for this annotation

GitHub Actions / PHP 8.3, Symfony ^7.0, Persistence: , Collections:

UndefinedClass

src/Bundle/DependencyInjection/SyliusResourceExtension.php:248:92: UndefinedClass: Class, interface or enum named Doctrine\ODM\MongoDB\DocumentManager does not exist (see https://psalm.dev/019)

Check failure on line 248 in src/Bundle/DependencyInjection/SyliusResourceExtension.php

View workflow job for this annotation

GitHub Actions / PHP 8.1, Symfony ^5.4, Persistence: , Collections:

UndefinedClass

src/Bundle/DependencyInjection/SyliusResourceExtension.php:248:92: UndefinedClass: Class, interface or enum named Doctrine\ODM\MongoDB\DocumentManager does not exist (see https://psalm.dev/019)

Check failure on line 248 in src/Bundle/DependencyInjection/SyliusResourceExtension.php

View workflow job for this annotation

GitHub Actions / PHP 8.2, Symfony ^5.4, Persistence: ^3.0, Collections: ^1.8

UndefinedClass

src/Bundle/DependencyInjection/SyliusResourceExtension.php:248:92: UndefinedClass: Class, interface or enum named Doctrine\ODM\MongoDB\DocumentManager does not exist (see https://psalm.dev/019)

Check failure on line 248 in src/Bundle/DependencyInjection/SyliusResourceExtension.php

View workflow job for this annotation

GitHub Actions / PHP 8.2, Symfony ^5.4, Persistence: ^3.0, Collections: ^2.0

UndefinedClass

src/Bundle/DependencyInjection/SyliusResourceExtension.php:248:92: UndefinedClass: Class, interface or enum named Doctrine\ODM\MongoDB\DocumentManager does not exist (see https://psalm.dev/019)

Check failure on line 248 in src/Bundle/DependencyInjection/SyliusResourceExtension.php

View workflow job for this annotation

GitHub Actions / PHP 8.1, Symfony ^6.4, Persistence: ^3.0, Collections: ^2.0

UndefinedClass

src/Bundle/DependencyInjection/SyliusResourceExtension.php:248:92: UndefinedClass: Class, interface or enum named Doctrine\ODM\MongoDB\DocumentManager does not exist (see https://psalm.dev/019)

Check failure on line 248 in src/Bundle/DependencyInjection/SyliusResourceExtension.php

View workflow job for this annotation

GitHub Actions / PHP 8.3, Symfony ^6.4, Persistence: ^3.0, Collections: ^2.0

UndefinedClass

src/Bundle/DependencyInjection/SyliusResourceExtension.php:248:92: UndefinedClass: Class, interface or enum named Doctrine\ODM\MongoDB\DocumentManager does not exist (see https://psalm.dev/019)

Check failure on line 248 in src/Bundle/DependencyInjection/SyliusResourceExtension.php

View workflow job for this annotation

GitHub Actions / PHP 8.3, Symfony ^5.4, Persistence: ^3.0, Collections: ^1.8

UndefinedClass

src/Bundle/DependencyInjection/SyliusResourceExtension.php:248:92: UndefinedClass: Class, interface or enum named Doctrine\ODM\MongoDB\DocumentManager does not exist (see https://psalm.dev/019)

Check failure on line 248 in src/Bundle/DependencyInjection/SyliusResourceExtension.php

View workflow job for this annotation

GitHub Actions / PHP 8.2, Symfony ^6.4, Persistence: ^3.0, Collections: ^1.8

UndefinedClass

src/Bundle/DependencyInjection/SyliusResourceExtension.php:248:92: UndefinedClass: Class, interface or enum named Doctrine\ODM\MongoDB\DocumentManager does not exist (see https://psalm.dev/019)

Check failure on line 248 in src/Bundle/DependencyInjection/SyliusResourceExtension.php

View workflow job for this annotation

GitHub Actions / PHP 8.1, Symfony ^5.4, Persistence: ^2.0, Collections: ^1.8

UndefinedClass

src/Bundle/DependencyInjection/SyliusResourceExtension.php:248:92: UndefinedClass: Class, interface or enum named Doctrine\ODM\MongoDB\DocumentManager does not exist (see https://psalm.dev/019)

Check failure on line 248 in src/Bundle/DependencyInjection/SyliusResourceExtension.php

View workflow job for this annotation

GitHub Actions / PHP 8.1, Symfony ^5.4, Persistence: ^3.0, Collections: ^1.8

UndefinedClass

src/Bundle/DependencyInjection/SyliusResourceExtension.php:248:92: UndefinedClass: Class, interface or enum named Doctrine\ODM\MongoDB\DocumentManager does not exist (see https://psalm.dev/019)

Check failure on line 248 in src/Bundle/DependencyInjection/SyliusResourceExtension.php

View workflow job for this annotation

GitHub Actions / PHP 8.3, Symfony ^6.4, Persistence: ^3.0, Collections: ^1.8

UndefinedClass

src/Bundle/DependencyInjection/SyliusResourceExtension.php:248:92: UndefinedClass: Class, interface or enum named Doctrine\ODM\MongoDB\DocumentManager does not exist (see https://psalm.dev/019)

Check failure on line 248 in src/Bundle/DependencyInjection/SyliusResourceExtension.php

View workflow job for this annotation

GitHub Actions / PHP 8.1, Symfony ^5.4, Persistence: ^3.0, Collections: ^2.0

UndefinedClass

src/Bundle/DependencyInjection/SyliusResourceExtension.php:248:92: UndefinedClass: Class, interface or enum named Doctrine\ODM\MongoDB\DocumentManager does not exist (see https://psalm.dev/019)

Check failure on line 248 in src/Bundle/DependencyInjection/SyliusResourceExtension.php

View workflow job for this annotation

GitHub Actions / PHP 8.1, Symfony ^6.4, Persistence: ^3.0, Collections: ^1.8

UndefinedClass

src/Bundle/DependencyInjection/SyliusResourceExtension.php:248:92: UndefinedClass: Class, interface or enum named Doctrine\ODM\MongoDB\DocumentManager does not exist (see https://psalm.dev/019)

Check failure on line 248 in src/Bundle/DependencyInjection/SyliusResourceExtension.php

View workflow job for this annotation

GitHub Actions / PHP 8.3, Symfony ^5.4, Persistence: ^3.0, Collections: ^2.0

UndefinedClass

src/Bundle/DependencyInjection/SyliusResourceExtension.php:248:92: UndefinedClass: Class, interface or enum named Doctrine\ODM\MongoDB\DocumentManager does not exist (see https://psalm.dev/019)

Check failure on line 248 in src/Bundle/DependencyInjection/SyliusResourceExtension.php

View workflow job for this annotation

GitHub Actions / PHP 8.3, Symfony ^5.4, Persistence: ^2.0, Collections: ^1.8

UndefinedClass

src/Bundle/DependencyInjection/SyliusResourceExtension.php:248:92: UndefinedClass: Class, interface or enum named Doctrine\ODM\MongoDB\DocumentManager does not exist (see https://psalm.dev/019)

Check failure on line 248 in src/Bundle/DependencyInjection/SyliusResourceExtension.php

View workflow job for this annotation

GitHub Actions / PHP 8.2, Symfony ^6.4, Persistence: ^3.0, Collections: ^2.0

UndefinedClass

src/Bundle/DependencyInjection/SyliusResourceExtension.php:248:92: UndefinedClass: Class, interface or enum named Doctrine\ODM\MongoDB\DocumentManager does not exist (see https://psalm.dev/019)

Check failure on line 248 in src/Bundle/DependencyInjection/SyliusResourceExtension.php

View workflow job for this annotation

GitHub Actions / PHP 8.2, Symfony ^5.4, Persistence: ^2.0, Collections: ^1.8

UndefinedClass

src/Bundle/DependencyInjection/SyliusResourceExtension.php:248:92: UndefinedClass: Class, interface or enum named Doctrine\ODM\MongoDB\DocumentManager does not exist (see https://psalm.dev/019)
$availableDrivers[] = SyliusResourceBundle::DRIVER_DOCTRINE_MONGODB_ODM;
}

return $availableDrivers;
}

/**
* @param string[] $configuredDrivers
* @param string[] $availableDrivers
* @param array<string, string> $resourceDrivers
*/
private function checkConfiguredDrivers(array $configuredDrivers, array $availableDrivers, array $resourceDrivers): void
{
foreach ($configuredDrivers as $driver) {
if (!in_array($driver, $availableDrivers, true)) {
throw new InvalidArgumentException(sprintf(
'Driver "%s" is configured, but this driver is not available. Try running "composer require %s"',
$driver,
$driver,
));
}
}

foreach ($resourceDrivers as $resource => $driver) {
if (!in_array($driver, $availableDrivers, true)) {
throw new InvalidArgumentException(sprintf(
'Resource "%s" uses drivers "%s", but this driver is not available. Try running "composer require %s"',
$resource,
$driver,
$driver,
));
}

if (!in_array($driver, $configuredDrivers, true)) {
throw new InvalidArgumentException(sprintf(
'Resource "%s" uses drivers "%s", but this driver is not enabled. Try adding "%s" in sylius_resource.drivers option',
$resource,
$driver,
$driver,
));
}
}
}

private function loadResources(array $loadedResources, ContainerBuilder $container): void
{
/** @var array<string, array> $resources */
Expand Down
75 changes: 46 additions & 29 deletions tests/Bundle/Configuration/ConfigurationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@
use Matthias\SymfonyConfigTest\PhpUnit\ConfigurationTestCaseTrait;
use PHPUnit\Framework\TestCase;
use Sylius\Bundle\ResourceBundle\DependencyInjection\Configuration;
use Symfony\Component\Config\Definition\ConfigurationInterface;

class ConfigurationTest extends TestCase
{
use ConfigurationTestCaseTrait;

/**
* @test
*/
public function it_does_not_break_if_not_customized()
/** @test */
public function it_does_not_break_if_not_customized(): void
{
$this->assertConfigurationIsValid(
[
Expand All @@ -33,10 +32,38 @@ public function it_does_not_break_if_not_customized()
);
}

/**
* @test
*/
public function it_has_no_default_mapping_paths()
/** @test */
public function it_has_no_default_drivers(): void
{
$this->assertProcessedConfigurationEquals(
[],
[
'drivers' => [],
],
'drivers',
);
}

/** @test */
public function its_drivers_can_be_customized(): void
{
$this->assertProcessedConfigurationEquals(
[
['drivers' => [
'doctrine/orm',
]],
],
[
'drivers' => [
'doctrine/orm',
],
],
'drivers',
);
}

/** @test */
public function it_has_no_default_mapping_paths(): void
{
$this->assertProcessedConfigurationEquals(
[
Expand All @@ -51,10 +78,8 @@ public function it_has_no_default_mapping_paths()
);
}

/**
* @test
*/
public function its_mapping_paths_can_be_customized()
/** @test */
public function its_mapping_paths_can_be_customized(): void
{
$this->assertProcessedConfigurationEquals(
[
Expand All @@ -73,10 +98,8 @@ public function its_mapping_paths_can_be_customized()
);
}

/**
* @test
*/
public function its_default_templates_dir_can_be_customized()
/** @test */
public function its_default_templates_dir_can_be_customized(): void
{
$this->assertProcessedConfigurationEquals(
[
Expand All @@ -93,10 +116,8 @@ public function its_default_templates_dir_can_be_customized()
);
}

/**
* @test
*/
public function it_has_default_authorization_checker()
/** @test */
public function it_has_default_authorization_checker(): void
{
$this->assertProcessedConfigurationEquals(
[
Expand All @@ -107,10 +128,8 @@ public function it_has_default_authorization_checker()
);
}

/**
* @test
*/
public function its_authorization_checker_can_be_customized()
/** @test */
public function its_authorization_checker_can_be_customized(): void
{
$this->assertProcessedConfigurationEquals(
[
Expand All @@ -121,10 +140,8 @@ public function its_authorization_checker_can_be_customized()
);
}

/**
* @test
*/
public function its_authorization_checker_cannot_be_empty()
/** @test */
public function its_authorization_checker_cannot_be_empty(): void
{
$this->assertPartialConfigurationIsInvalid(
[
Expand All @@ -134,7 +151,7 @@ public function its_authorization_checker_cannot_be_empty()
);
}

protected function getConfiguration()
protected function getConfiguration(): ConfigurationInterface
{
return new Configuration();
}
Expand Down
Loading
Loading