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

Remove rest dependencies #173

Merged
merged 7 commits into from
Oct 13, 2020
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
5 changes: 3 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ script:

- vendor/bin/phpunit

- composer require doctrine/orm:^2.5 --no-update --no-scripts --prefer-dist
# Test the whole bundle without FOSRestBundle dependency
- composer require doctrine/orm:^2.5 --no-update --no-scripts
- composer update --no-dev --prefer-dist
- (cd src/Bundle/test && app/console cache:clear --env=prod)
- (cd src/Bundle/test && app/console cache:clear --env=test_without_fosrest)
31 changes: 4 additions & 27 deletions src/Bundle/test/app/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,13 @@

declare(strict_types=1);

use PSS\SymfonyMockerContainer\DependencyInjection\MockerContainer;
use Symfony\Component\Config\Loader\LoaderInterface;
use Symfony\Component\HttpKernel\Kernel;

class AppKernel extends Kernel
{
/**
* {@inheritdoc}
*/
public function registerBundles()
{
if ('prod' === $this->getEnvironment()) {
$loader = require __DIR__ . '/../../../../vendor/autoload.php';
$loader->addPsr4('AppBundle\\', __DIR__ . '/../src/AppBundle/');
}

$bundles = [
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
Expand All @@ -38,7 +29,7 @@ public function registerBundles()
new AppBundle\AppBundle(),
];

if (in_array($this->getEnvironment(), ['dev', 'test'], true)) {
if ($this->getEnvironment() !== 'test_without_fosrest') {
$bundles[] = new FOS\RestBundle\FOSRestBundle();
$bundles[] = new JMS\SerializerBundle\JMSSerializerBundle();
$bundles[] = new Bazinga\Bundle\HateoasBundle\BazingaHateoasBundle();
Expand All @@ -49,23 +40,9 @@ public function registerBundles()
return $bundles;
}

/**
* {@inheritdoc}
*/
public function registerContainerConfiguration(LoaderInterface $loader)
public function registerContainerConfiguration(LoaderInterface $loader): void
{
$loader->load(__DIR__ . '/config/config_' . $this->getEnvironment() . '.yml');
}

/**
* {@inheritdoc}
*/
protected function getContainerBaseClass()
{
if (0 === strpos($this->environment, 'test')) {
return MockerContainer::class;
}

return parent::getContainerBaseClass();
$loader->load(__DIR__ . '/config/{config}.{php,xml,yaml,yml}', 'glob');
$loader->load(__DIR__ . '/config/{config}_' . $this->getEnvironment() . '.{php,xml,yaml,yml}', 'glob');
Copy link
Contributor

Choose a reason for hiding this comment

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

Makes the environment config file optional, it's the same behaviour as in Symfony 4+ apps.

}
}
13 changes: 0 additions & 13 deletions src/Bundle/test/app/config/config_dev.yml

This file was deleted.

2 changes: 0 additions & 2 deletions src/Bundle/test/app/config/config_prod.yml

This file was deleted.

12 changes: 10 additions & 2 deletions src/Bundle/test/app/config/config_test.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,10 @@
imports:
- { resource: config_dev.yml }
fos_rest:
view:
formats:
json: true
empty_content: 204
format_listener:
rules:
- { path: '^/', priorities: ['json'], fallback_format: json, prefer_extension: true }
exception:
enabled: false
2 changes: 1 addition & 1 deletion src/Bundle/test/app/console
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use Symfony\Bundle\FrameworkBundle\Console\Application;
use Symfony\Component\Console\Input\ArgvInput;

$input = new ArgvInput();
$env = $input->getParameterOption(array('--env', '-e'), getenv('SYMFONY_ENV') ?: 'test');
$env = $input->getParameterOption(['--env', '-e'], getenv('APP_ENV') ?? 'test');
Copy link
Contributor

Choose a reason for hiding this comment

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

Replaced SYMFONY_ENV to more recent APP_ENV.


$application = new Application(new AppKernel($env, true));
Copy link
Contributor

Choose a reason for hiding this comment

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

What's the idea behind that? Do we really need it?

Copy link
Member Author

Choose a reason for hiding this comment

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

The idea is to test prod requirements (without optional rest bundles).

Copy link
Member Author

Choose a reason for hiding this comment

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

@pamil Maybe you have a better idea to test without optional bundles...

$application->run($input);