diff --git a/.gitignore b/.gitignore index 46aed3371099..ea31d1b70fd5 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,7 @@ bin/ composer.phar composer.lock + +test/app/cache +test/app/logs +test/app/db.sql \ No newline at end of file diff --git a/composer.json b/composer.json index 5e88350a895d..ddf32a227e40 100644 --- a/composer.json +++ b/composer.json @@ -28,8 +28,14 @@ "symfony/templating": "^3.2@rc" }, "require-dev": { + "doctrine/orm": "^2.5", "phpspec/phpspec": "^3.2", - "twig/twig": "^1.0" + "phpunit/phpunit": "^5.6", + "twig/twig": "^1.0", + "ocramius/proxy-manager": "^2.0", + "symfony/browser-kit": "^3.2@rc", + "incenteev/composer-parameter-handler": "~2.0", + "polishsymfonycommunity/symfony-mocker-container": "^1.0" }, "config": { "bin-dir": "bin" @@ -38,7 +44,10 @@ "psr-4": { "Sylius\\Bundle\\LocaleBundle\\": "" } }, "autoload-dev": { - "psr-4": { "Sylius\\Bundle\\LocaleBundle\\spec\\": "spec/" } + "psr-4": { + "Sylius\\Bundle\\LocaleBundle\\spec\\": "spec/", + "AppBundle\\": "test/src/AppBundle/" + } }, "minimum-stability": "dev", "prefer-stable": true, @@ -51,6 +60,9 @@ "extra": { "branch-alias": { "dev-master": "1.0-dev" + }, + "incenteev-parameters": { + "file": "test/app/config/parameters.yml" } } } diff --git a/phpunit.xml.dist b/phpunit.xml.dist new file mode 100644 index 000000000000..a5aeb2af33d5 --- /dev/null +++ b/phpunit.xml.dist @@ -0,0 +1,18 @@ + + + + + + + + + + ./test/ + + + diff --git a/test/app/AppKernel.php b/test/app/AppKernel.php new file mode 100644 index 000000000000..314bbc73a8ab --- /dev/null +++ b/test/app/AppKernel.php @@ -0,0 +1,59 @@ + + */ +class AppKernel extends Kernel +{ + /** + * {@inheritdoc} + */ + public function registerBundles() + { + return [ + new Symfony\Bundle\FrameworkBundle\FrameworkBundle(), + new winzou\Bundle\StateMachineBundle\winzouStateMachineBundle(), + new FOS\RestBundle\FOSRestBundle(), + new JMS\SerializerBundle\JMSSerializerBundle($this), + new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(), + new WhiteOctober\PagerfantaBundle\WhiteOctoberPagerfantaBundle(), + new Sylius\Bundle\LocaleBundle\SyliusLocaleBundle(), + new Sylius\Bundle\ResourceBundle\SyliusResourceBundle(), + new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(), + new Symfony\Bundle\TwigBundle\TwigBundle(), + ]; + } + + /** + * {@inheritdoc} + */ + public function registerContainerConfiguration(LoaderInterface $loader) + { + $loader->load(__DIR__.'/config/config.yml'); + } + + /** + * {@inheritdoc} + */ + protected function getContainerBaseClass() + { + if ('test' === $this->environment) { + return MockerContainer::class; + } + + return parent::getContainerBaseClass(); + } +} diff --git a/test/app/autoload.php b/test/app/autoload.php new file mode 100644 index 000000000000..7c2884c9da5b --- /dev/null +++ b/test/app/autoload.php @@ -0,0 +1,20 @@ +run($input); diff --git a/test/src/Tests/SyliusLocaleBundleTest.php b/test/src/Tests/SyliusLocaleBundleTest.php new file mode 100644 index 000000000000..42407401e9f3 --- /dev/null +++ b/test/src/Tests/SyliusLocaleBundleTest.php @@ -0,0 +1,40 @@ + + */ +class SyliusLocaleBundleTest extends WebTestCase +{ + /** + * @test + */ + public function its_services_are_intitializable() + { + /** @var ContainerInterface $container */ + $container = self::createClient()->getContainer(); + + $services = $container->getServiceIds(); + + $services = array_filter($services, function ($serviceId) { + return false !== strpos($serviceId, 'sylius'); + }); + + foreach ($services as $id) { + $container->get($id); + } + } +}