diff --git a/composer.json b/composer.json index 764ffe5ec0..19de5529d6 100644 --- a/composer.json +++ b/composer.json @@ -52,6 +52,7 @@ "sonata-project/intl-bundle": "^2.2", "stof/doctrine-extensions-bundle": "^1.2", "swiftmailer/swiftmailer": "^6.0", + "sylius/fixtures-bundle": "~1.1.15", "sylius-labs/association-hydrator": "^1.0", "symfony/monolog-bundle": "^3.0", "symfony/polyfill-iconv": "^1.3", @@ -113,7 +114,6 @@ "sylius/currency-bundle": "self.version", "sylius/customer": "self.version", "sylius/customer-bundle": "self.version", - "sylius/fixtures-bundle": "self.version", "sylius/grid": "self.version", "sylius/grid-bundle": "self.version", "sylius/inventory": "self.version", diff --git a/phpspec.yml.dist b/phpspec.yml.dist index 7a2f6274e2..af5c55316e 100644 --- a/phpspec.yml.dist +++ b/phpspec.yml.dist @@ -29,7 +29,6 @@ suites: CoreBundle: { namespace: Sylius\Bundle\CoreBundle, psr4_prefix: Sylius\Bundle\CoreBundle, spec_path: src/Sylius/Bundle/CoreBundle, src_path: src/Sylius/Bundle/CoreBundle } CurrencyBundle: { namespace: Sylius\Bundle\CurrencyBundle, psr4_prefix: Sylius\Bundle\CurrencyBundle, spec_path: src/Sylius/Bundle/CurrencyBundle, src_path: src/Sylius/Bundle/CurrencyBundle } CustomerBundle: { namespace: Sylius\Bundle\CustomerBundle, psr4_prefix: Sylius\Bundle\CustomerBundle, spec_path: src/Sylius/Bundle/CustomerBundle, src_path: src/Sylius/Bundle/CustomerBundle } - FixturesBundle: { namespace: Sylius\Bundle\FixturesBundle, psr4_prefix: Sylius\Bundle\FixturesBundle, spec_path: src/Sylius/Bundle/FixturesBundle, src_path: src/Sylius/Bundle/FixturesBundle } GridBundle: { namespace: Sylius\Bundle\GridBundle, psr4_prefix: Sylius\Bundle\GridBundle, spec_path: src/Sylius/Bundle/GridBundle, src_path: src/Sylius/Bundle/GridBundle } InventoryBundle: { namespace: Sylius\Bundle\InventoryBundle, psr4_prefix: Sylius\Bundle\InventoryBundle, spec_path: src/Sylius/Bundle/InventoryBundle, src_path: src/Sylius/Bundle/InventoryBundle } LocaleBundle: { namespace: Sylius\Bundle\LocaleBundle, psr4_prefix: Sylius\Bundle\LocaleBundle, spec_path: src/Sylius/Bundle/LocaleBundle, src_path: src/Sylius/Bundle/LocaleBundle } diff --git a/src/Sylius/Bundle/FixturesBundle/.gitignore b/src/Sylius/Bundle/FixturesBundle/.gitignore deleted file mode 100644 index 6d374dec63..0000000000 --- a/src/Sylius/Bundle/FixturesBundle/.gitignore +++ /dev/null @@ -1,15 +0,0 @@ -/vendor -/bin - -/composer.phar -/composer.lock - -test/app/cache -test/app/logs - -/humbug.json -/phpspec.yml -/phpunit.xml - -/humbuglog.txt -/humbuglog.json diff --git a/src/Sylius/Bundle/FixturesBundle/Command/FixturesListCommand.php b/src/Sylius/Bundle/FixturesBundle/Command/FixturesListCommand.php deleted file mode 100644 index 3c12772f2e..0000000000 --- a/src/Sylius/Bundle/FixturesBundle/Command/FixturesListCommand.php +++ /dev/null @@ -1,87 +0,0 @@ -setName('sylius:fixtures:list') - ->setDescription('Lists available fixtures') - ; - } - - /** - * {@inheritdoc} - */ - protected function execute(InputInterface $input, OutputInterface $output): void - { - $this->listSuites($output); - $this->listFixtures($output); - } - - /** - * @param OutputInterface $output - */ - private function listSuites(OutputInterface $output): void - { - $suites = $this->getSuiteRegistry()->getSuites(); - - $output->writeln('Available suites:'); - - foreach ($suites as $suite) { - $output->writeln(' - ' . $suite->getName()); - } - } - - /** - * @param OutputInterface $output - */ - private function listFixtures(OutputInterface $output): void - { - $fixtures = $this->getFixtureRegistry()->getFixtures(); - - $output->writeln('Available fixtures:'); - - foreach ($fixtures as $name => $fixture) { - $output->writeln(' - ' . $name); - } - } - - /** - * @return SuiteRegistryInterface - */ - private function getSuiteRegistry(): SuiteRegistryInterface - { - return $this->getContainer()->get('sylius_fixtures.suite_registry'); - } - - /** - * @return FixtureRegistryInterface - */ - private function getFixtureRegistry(): FixtureRegistryInterface - { - return $this->getContainer()->get('sylius_fixtures.fixture_registry'); - } -} diff --git a/src/Sylius/Bundle/FixturesBundle/Command/FixturesLoadCommand.php b/src/Sylius/Bundle/FixturesBundle/Command/FixturesLoadCommand.php deleted file mode 100644 index 9959993e4f..0000000000 --- a/src/Sylius/Bundle/FixturesBundle/Command/FixturesLoadCommand.php +++ /dev/null @@ -1,87 +0,0 @@ -setName('sylius:fixtures:load') - ->setDescription('Loads fixtures from given suite') - ->addArgument('suite', InputArgument::OPTIONAL, 'Suite name', 'default') - ; - } - - /** - * {@inheritdoc} - */ - protected function execute(InputInterface $input, OutputInterface $output): void - { - if ($input->isInteractive()) { - /** @var QuestionHelper $questionHelper */ - $questionHelper = $this->getHelper('question'); - - $output->writeln(sprintf( - "\nWarning! Loading fixtures will purge your database for the %s environment.\n", - $input->getOption('env') - )); - - if (!$questionHelper->ask($input, $output, new ConfirmationQuestion('Continue? (y/N) ', false))) { - return; - } - } - - $this->loadSuites($input); - } - - /** - * @param InputInterface $input - */ - private function loadSuites(InputInterface $input): void - { - $suiteName = $input->getArgument('suite'); - $suite = $this->getSuiteRegistry()->getSuite($suiteName); - - $this->getSuiteLoader()->load($suite); - } - - /** - * @return SuiteRegistryInterface - */ - private function getSuiteRegistry(): SuiteRegistryInterface - { - return $this->getContainer()->get('sylius_fixtures.suite_registry'); - } - - /** - * @return SuiteLoaderInterface - */ - private function getSuiteLoader(): SuiteLoaderInterface - { - return $this->getContainer()->get('sylius_fixtures.suite_loader'); - } -} diff --git a/src/Sylius/Bundle/FixturesBundle/DependencyInjection/Compiler/FixtureRegistryPass.php b/src/Sylius/Bundle/FixturesBundle/DependencyInjection/Compiler/FixtureRegistryPass.php deleted file mode 100644 index aaa3e30519..0000000000 --- a/src/Sylius/Bundle/FixturesBundle/DependencyInjection/Compiler/FixtureRegistryPass.php +++ /dev/null @@ -1,38 +0,0 @@ -has('sylius_fixtures.fixture_registry')) { - return; - } - - $fixtureRegistry = $container->findDefinition('sylius_fixtures.fixture_registry'); - - $taggedServices = $container->findTaggedServiceIds('sylius_fixtures.fixture'); - foreach (array_keys($taggedServices) as $id) { - $fixtureRegistry->addMethodCall('addFixture', [new Reference($id)]); - } - } -} diff --git a/src/Sylius/Bundle/FixturesBundle/DependencyInjection/Compiler/ListenerRegistryPass.php b/src/Sylius/Bundle/FixturesBundle/DependencyInjection/Compiler/ListenerRegistryPass.php deleted file mode 100644 index b3d79c9126..0000000000 --- a/src/Sylius/Bundle/FixturesBundle/DependencyInjection/Compiler/ListenerRegistryPass.php +++ /dev/null @@ -1,38 +0,0 @@ -has('sylius_fixtures.listener_registry')) { - return; - } - - $listenerRegistry = $container->findDefinition('sylius_fixtures.listener_registry'); - - $taggedServices = $container->findTaggedServiceIds('sylius_fixtures.listener'); - foreach (array_keys($taggedServices) as $id) { - $listenerRegistry->addMethodCall('addListener', [new Reference($id)]); - } - } -} diff --git a/src/Sylius/Bundle/FixturesBundle/DependencyInjection/Configuration.php b/src/Sylius/Bundle/FixturesBundle/DependencyInjection/Configuration.php deleted file mode 100644 index 656e4d44bf..0000000000 --- a/src/Sylius/Bundle/FixturesBundle/DependencyInjection/Configuration.php +++ /dev/null @@ -1,139 +0,0 @@ -root('sylius_fixtures'); - - $this->buildSuitesNode($rootNode); - - return $treeBuilder; - } - - /** - * @param ArrayNodeDefinition $rootNode - */ - private function buildSuitesNode(ArrayNodeDefinition $rootNode): void - { - /** @var ArrayNodeDefinition $suitesNode */ - $suitesNode = $rootNode - ->children() - ->arrayNode('suites') - ->useAttributeAsKey('name') - ->arrayPrototype() - ; - - $suitesNode - ->validate() - ->ifArray() - ->then(function (array $value) { - if (!isset($value['fixtures'])) { - return $value; - } - - foreach ($value['fixtures'] as $fixtureKey => &$fixtureValue) { - if (!isset($fixtureValue['name'])) { - $fixtureValue['name'] = $fixtureKey; - } - } - - return $value; - }) - ; - - $this->buildFixturesNode($suitesNode); - $this->buildListenersNode($suitesNode); - } - - /** - * @param ArrayNodeDefinition $suitesNode - */ - private function buildFixturesNode(ArrayNodeDefinition $suitesNode): void - { - /** @var ArrayNodeDefinition $fixturesNode */ - $fixturesNode = $suitesNode - ->children() - ->arrayNode('fixtures') - ->useAttributeAsKey('alias') - ->arrayPrototype() - ; - - $fixturesNode->children()->scalarNode('name')->cannotBeEmpty(); - - $this->buildAttributesNode($fixturesNode); - } - - /** - * @param ArrayNodeDefinition $suitesNode - */ - private function buildListenersNode(ArrayNodeDefinition $suitesNode): void - { - /** @var ArrayNodeDefinition $listenersNode */ - $listenersNode = $suitesNode - ->children() - ->arrayNode('listeners') - ->useAttributeAsKey('name') - ->arrayPrototype() - ; - - $this->buildAttributesNode($listenersNode); - } - - /** - * @param ArrayNodeDefinition $node - */ - private function buildAttributesNode(ArrayNodeDefinition $node): void - { - $attributesNodeBuilder = $node->canBeUnset()->children(); - $attributesNodeBuilder->integerNode('priority')->defaultValue(0); - - /** @var ArrayNodeDefinition $optionsNode */ - $optionsNode = $attributesNodeBuilder->arrayNode('options'); - $optionsNode->addDefaultChildrenIfNoneSet(); - - $optionsNode - ->validate() - ->ifTrue(function (array $values) { - foreach ($values as $value) { - if (!is_array($value)) { - return true; - } - } - - return false; - }) - ->thenInvalid('Options have to be an array!') - ; - - $optionsNode - ->beforeNormalization() - ->always(function ($value) { - return [$value]; - }) - ; - - $optionsNode->variablePrototype()->cannotBeEmpty()->defaultValue([]); - } -} diff --git a/src/Sylius/Bundle/FixturesBundle/DependencyInjection/SyliusFixturesExtension.php b/src/Sylius/Bundle/FixturesBundle/DependencyInjection/SyliusFixturesExtension.php deleted file mode 100644 index d010397f1e..0000000000 --- a/src/Sylius/Bundle/FixturesBundle/DependencyInjection/SyliusFixturesExtension.php +++ /dev/null @@ -1,70 +0,0 @@ -processConfiguration($this->getConfiguration([], $container), $config); - $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); - - $loader->load('services.xml'); - - $this->registerSuites($config, $container); - } - - /** - * {@inheritdoc} - */ - public function prepend(ContainerBuilder $container): void - { - $loader = new XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); - - $extensionsNamesToConfigurationFiles = [ - 'doctrine' => 'doctrine/orm.xml', - 'doctrine_mongodb' => 'doctrine/mongodb-odm.xml', - 'doctrine_phpcr' => 'doctrine/phpcr-odm.xml', - ]; - - foreach ($extensionsNamesToConfigurationFiles as $extensionName => $configurationFile) { - if (!$container->hasExtension($extensionName)) { - continue; - } - - $loader->load('services/integrations/' . $configurationFile); - } - } - - /** - * @param array $config - * @param ContainerBuilder $container - */ - private function registerSuites(array $config, ContainerBuilder $container): void - { - $suiteRegistry = $container->findDefinition('sylius_fixtures.suite_registry'); - foreach ($config['suites'] as $suiteName => $suiteConfiguration) { - $suiteRegistry->addMethodCall('addSuite', [$suiteName, $suiteConfiguration]); - } - } -} diff --git a/src/Sylius/Bundle/FixturesBundle/Fixture/AbstractFixture.php b/src/Sylius/Bundle/FixturesBundle/Fixture/AbstractFixture.php deleted file mode 100644 index edf8336380..0000000000 --- a/src/Sylius/Bundle/FixturesBundle/Fixture/AbstractFixture.php +++ /dev/null @@ -1,41 +0,0 @@ -root($this->getName()); - - $this->configureOptionsNode($optionsNode); - - return $treeBuilder; - } - - /** - * @param ArrayNodeDefinition $optionsNode - */ - protected function configureOptionsNode(ArrayNodeDefinition $optionsNode): void - { - // empty - } -} diff --git a/src/Sylius/Bundle/FixturesBundle/Fixture/FixtureInterface.php b/src/Sylius/Bundle/FixturesBundle/Fixture/FixtureInterface.php deleted file mode 100644 index 0d26204250..0000000000 --- a/src/Sylius/Bundle/FixturesBundle/Fixture/FixtureInterface.php +++ /dev/null @@ -1,29 +0,0 @@ -fixtures, $fixture->getName(), 'Fixture with name "%s" is already registered.'); - - $this->fixtures[$fixture->getName()] = $fixture; - } - - /** - * {@inheritdoc} - */ - public function getFixture(string $name): FixtureInterface - { - if (!isset($this->fixtures[$name])) { - throw new FixtureNotFoundException($name); - } - - return $this->fixtures[$name]; - } - - /** - * {@inheritdoc} - */ - public function getFixtures(): array - { - return $this->fixtures; - } -} diff --git a/src/Sylius/Bundle/FixturesBundle/Fixture/FixtureRegistryInterface.php b/src/Sylius/Bundle/FixturesBundle/Fixture/FixtureRegistryInterface.php deleted file mode 100644 index e8fdcc2083..0000000000 --- a/src/Sylius/Bundle/FixturesBundle/Fixture/FixtureRegistryInterface.php +++ /dev/null @@ -1,31 +0,0 @@ -root($this->getName()); - - $this->configureOptionsNode($optionsNode); - - return $treeBuilder; - } - - /** - * @param ArrayNodeDefinition $optionsNode - */ - protected function configureOptionsNode(ArrayNodeDefinition $optionsNode): void - { - // empty - } -} diff --git a/src/Sylius/Bundle/FixturesBundle/Listener/AfterFixtureListenerInterface.php b/src/Sylius/Bundle/FixturesBundle/Listener/AfterFixtureListenerInterface.php deleted file mode 100644 index 8750085f83..0000000000 --- a/src/Sylius/Bundle/FixturesBundle/Listener/AfterFixtureListenerInterface.php +++ /dev/null @@ -1,23 +0,0 @@ -suite = $suite; - $this->fixture = $fixture; - $this->fixtureOptions = $fixtureOptions; - } - - /** - * @return SuiteInterface - */ - public function suite(): SuiteInterface - { - return $this->suite; - } - - /** - * @return FixtureInterface - */ - public function fixture(): FixtureInterface - { - return $this->fixture; - } - - /** - * @return array - */ - public function fixtureOptions(): array - { - return $this->fixtureOptions; - } -} diff --git a/src/Sylius/Bundle/FixturesBundle/Listener/ListenerInterface.php b/src/Sylius/Bundle/FixturesBundle/Listener/ListenerInterface.php deleted file mode 100644 index fcadc7888a..0000000000 --- a/src/Sylius/Bundle/FixturesBundle/Listener/ListenerInterface.php +++ /dev/null @@ -1,24 +0,0 @@ -listeners, $listener->getName(), 'Listener with name "%s" is already registered.'); - - $this->listeners[$listener->getName()] = $listener; - } - - /** - * {@inheritdoc} - */ - public function getListener(string $name): ListenerInterface - { - if (!isset($this->listeners[$name])) { - throw new ListenerNotFoundException($name); - } - - return $this->listeners[$name]; - } - - /** - * {@inheritdoc} - */ - public function getListeners(): array - { - return $this->listeners; - } -} diff --git a/src/Sylius/Bundle/FixturesBundle/Listener/ListenerRegistryInterface.php b/src/Sylius/Bundle/FixturesBundle/Listener/ListenerRegistryInterface.php deleted file mode 100644 index 4b8dfe88a9..0000000000 --- a/src/Sylius/Bundle/FixturesBundle/Listener/ListenerRegistryInterface.php +++ /dev/null @@ -1,31 +0,0 @@ -logger = $logger; - } - - /** - * {@inheritdoc} - */ - public function beforeSuite(SuiteEvent $suiteEvent, array $options): void - { - $this->logger->notice(sprintf('Running suite "%s"...', $suiteEvent->suite()->getName())); - } - - /** - * {@inheritdoc} - */ - public function beforeFixture(FixtureEvent $fixtureEvent, array $options): void - { - $this->logger->notice(sprintf('Running fixture "%s"...', $fixtureEvent->fixture()->getName())); - } - - /** - * {@inheritdoc} - */ - public function getName(): string - { - return 'logger'; - } -} diff --git a/src/Sylius/Bundle/FixturesBundle/Listener/MongoDBPurgerListener.php b/src/Sylius/Bundle/FixturesBundle/Listener/MongoDBPurgerListener.php deleted file mode 100644 index 405681374e..0000000000 --- a/src/Sylius/Bundle/FixturesBundle/Listener/MongoDBPurgerListener.php +++ /dev/null @@ -1,70 +0,0 @@ -managerRegistry = $managerRegistry; - } - - /** - * {@inheritdoc} - */ - public function beforeSuite(SuiteEvent $suiteEvent, array $options): void - { - foreach ($options['managers'] as $managerName) { - /** @var DocumentManager $manager */ - $manager = $this->managerRegistry->getManager($managerName); - - $purger = new MongoDBPurger($manager); - $purger->purge(); - } - } - - /** - * {@inheritdoc} - */ - public function getName(): string - { - return 'mongodb_purger'; - } - - /** - * {@inheritdoc} - */ - protected function configureOptionsNode(ArrayNodeDefinition $optionsNode): void - { - $optionsNode - ->children() - ->arrayNode('managers') - ->defaultValue([null]) - ->scalarPrototype() - ; - } -} diff --git a/src/Sylius/Bundle/FixturesBundle/Listener/ORMPurgerListener.php b/src/Sylius/Bundle/FixturesBundle/Listener/ORMPurgerListener.php deleted file mode 100644 index e20a07277b..0000000000 --- a/src/Sylius/Bundle/FixturesBundle/Listener/ORMPurgerListener.php +++ /dev/null @@ -1,92 +0,0 @@ - ORMPurger::PURGE_MODE_DELETE, - 'truncate' => ORMPurger::PURGE_MODE_TRUNCATE, - ]; - - /** - * @param ManagerRegistry $managerRegistry - */ - public function __construct(ManagerRegistry $managerRegistry) - { - $this->managerRegistry = $managerRegistry; - } - - /** - * {@inheritdoc} - */ - public function beforeSuite(SuiteEvent $suiteEvent, array $options): void - { - foreach ($options['managers'] as $managerName) { - /** @var EntityManagerInterface $manager */ - $manager = $this->managerRegistry->getManager($managerName); - - $purger = new ORMPurger($manager, $options['exclude']); - $purger->setPurgeMode(static::$purgeModes[$options['mode']]); - $purger->purge(); - } - } - - /** - * {@inheritdoc} - */ - public function getName(): string - { - return 'orm_purger'; - } - - /** - * {@inheritdoc} - */ - protected function configureOptionsNode(ArrayNodeDefinition $optionsNode): void - { - $optionsNodeBuilder = $optionsNode->children(); - - $optionsNodeBuilder - ->enumNode('mode') - ->values(['delete', 'truncate']) - ->defaultValue('delete') - ; - - $optionsNodeBuilder - ->arrayNode('managers') - ->defaultValue([null]) - ->scalarPrototype() - ; - - $optionsNodeBuilder - ->arrayNode('exclude') - ->defaultValue([]) - ->scalarPrototype() - ; - } -} diff --git a/src/Sylius/Bundle/FixturesBundle/Listener/PHPCRPurgerListener.php b/src/Sylius/Bundle/FixturesBundle/Listener/PHPCRPurgerListener.php deleted file mode 100644 index 3ced617ea0..0000000000 --- a/src/Sylius/Bundle/FixturesBundle/Listener/PHPCRPurgerListener.php +++ /dev/null @@ -1,70 +0,0 @@ -managerRegistry = $managerRegistry; - } - - /** - * {@inheritdoc} - */ - public function beforeSuite(SuiteEvent $suiteEvent, array $options): void - { - foreach ($options['managers'] as $managerName) { - /** @var DocumentManagerInterface $manager */ - $manager = $this->managerRegistry->getManager($managerName); - - $purger = new PHPCRPurger($manager); - $purger->purge(); - } - } - - /** - * {@inheritdoc} - */ - public function getName(): string - { - return 'phpcr_purger'; - } - - /** - * {@inheritdoc} - */ - protected function configureOptionsNode(ArrayNodeDefinition $optionsNode): void - { - $optionsNode - ->children() - ->arrayNode('managers') - ->defaultValue([null]) - ->scalarPrototype() - ; - } -} diff --git a/src/Sylius/Bundle/FixturesBundle/Listener/SuiteEvent.php b/src/Sylius/Bundle/FixturesBundle/Listener/SuiteEvent.php deleted file mode 100644 index 2edab70687..0000000000 --- a/src/Sylius/Bundle/FixturesBundle/Listener/SuiteEvent.php +++ /dev/null @@ -1,40 +0,0 @@ -suite = $suite; - } - - /** - * @return SuiteInterface - */ - public function suite(): SuiteInterface - { - return $this->suite; - } -} diff --git a/src/Sylius/Bundle/FixturesBundle/Loader/FixtureLoader.php b/src/Sylius/Bundle/FixturesBundle/Loader/FixtureLoader.php deleted file mode 100644 index 3dc2ac0592..0000000000 --- a/src/Sylius/Bundle/FixturesBundle/Loader/FixtureLoader.php +++ /dev/null @@ -1,28 +0,0 @@ -load($options); - } -} diff --git a/src/Sylius/Bundle/FixturesBundle/Loader/FixtureLoaderInterface.php b/src/Sylius/Bundle/FixturesBundle/Loader/FixtureLoaderInterface.php deleted file mode 100644 index 315a0e8dcf..0000000000 --- a/src/Sylius/Bundle/FixturesBundle/Loader/FixtureLoaderInterface.php +++ /dev/null @@ -1,27 +0,0 @@ -decoratedFixtureLoader = $decoratedFixtureLoader; - } - - /** - * {@inheritdoc} - */ - public function load(SuiteInterface $suite, FixtureInterface $fixture, array $options): void - { - $fixtureEvent = new FixtureEvent($suite, $fixture, $options); - - $this->executeBeforeFixtureListeners($suite, $fixtureEvent); - - $this->decoratedFixtureLoader->load($suite, $fixture, $options); - - $this->executeAfterFixtureListeners($suite, $fixtureEvent); - } - - /** - * @param SuiteInterface $suite - * @param FixtureEvent $fixtureEvent - */ - private function executeBeforeFixtureListeners(SuiteInterface $suite, FixtureEvent $fixtureEvent): void - { - foreach ($suite->getListeners() as $listener => $listenerOptions) { - if (!$listener instanceof BeforeFixtureListenerInterface) { - continue; - } - - $listener->beforeFixture($fixtureEvent, $listenerOptions); - } - } - - /** - * @param SuiteInterface $suite - * @param FixtureEvent $fixtureEvent - */ - private function executeAfterFixtureListeners(SuiteInterface $suite, FixtureEvent $fixtureEvent): void - { - foreach ($suite->getListeners() as $listener => $listenerOptions) { - if (!$listener instanceof AfterFixtureListenerInterface) { - continue; - } - - $listener->afterFixture($fixtureEvent, $listenerOptions); - } - } -} diff --git a/src/Sylius/Bundle/FixturesBundle/Loader/HookableSuiteLoader.php b/src/Sylius/Bundle/FixturesBundle/Loader/HookableSuiteLoader.php deleted file mode 100644 index 9169f59281..0000000000 --- a/src/Sylius/Bundle/FixturesBundle/Loader/HookableSuiteLoader.php +++ /dev/null @@ -1,79 +0,0 @@ -decoratedSuiteLoader = $decoratedSuiteLoader; - } - - /** - * {@inheritdoc} - */ - public function load(SuiteInterface $suite): void - { - $suiteEvent = new SuiteEvent($suite); - - $this->executeBeforeSuiteListeners($suite, $suiteEvent); - - $this->decoratedSuiteLoader->load($suite); - - $this->executeAfterSuiteListeners($suite, $suiteEvent); - } - - /** - * @param SuiteInterface $suite - * @param SuiteEvent $suiteEvent - */ - private function executeBeforeSuiteListeners(SuiteInterface $suite, SuiteEvent $suiteEvent): void - { - foreach ($suite->getListeners() as $listener => $listenerOptions) { - if (!$listener instanceof BeforeSuiteListenerInterface) { - continue; - } - - $listener->beforeSuite($suiteEvent, $listenerOptions); - } - } - - /** - * @param SuiteInterface $suite - * @param SuiteEvent $suiteEvent - */ - private function executeAfterSuiteListeners(SuiteInterface $suite, SuiteEvent $suiteEvent): void - { - foreach ($suite->getListeners() as $listener => $listenerOptions) { - if (!$listener instanceof AfterSuiteListenerInterface) { - continue; - } - - $listener->afterSuite($suiteEvent, $listenerOptions); - } - } -} diff --git a/src/Sylius/Bundle/FixturesBundle/Loader/SuiteLoader.php b/src/Sylius/Bundle/FixturesBundle/Loader/SuiteLoader.php deleted file mode 100644 index 8be4f5401c..0000000000 --- a/src/Sylius/Bundle/FixturesBundle/Loader/SuiteLoader.php +++ /dev/null @@ -1,45 +0,0 @@ -fixtureLoader = $fixtureLoader; - } - - /** - * {@inheritdoc} - */ - public function load(SuiteInterface $suite): void - { - /** @var FixtureInterface $fixture */ - /** @var array $fixtureOptions */ - foreach ($suite->getFixtures() as $fixture => $fixtureOptions) { - $this->fixtureLoader->load($suite, $fixture, $fixtureOptions); - } - } -} diff --git a/src/Sylius/Bundle/FixturesBundle/Loader/SuiteLoaderInterface.php b/src/Sylius/Bundle/FixturesBundle/Loader/SuiteLoaderInterface.php deleted file mode 100644 index 3003f7c1fc..0000000000 --- a/src/Sylius/Bundle/FixturesBundle/Loader/SuiteLoaderInterface.php +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - - - - - - - - diff --git a/src/Sylius/Bundle/FixturesBundle/Resources/config/services/fixture.xml b/src/Sylius/Bundle/FixturesBundle/Resources/config/services/fixture.xml deleted file mode 100644 index da969c6210..0000000000 --- a/src/Sylius/Bundle/FixturesBundle/Resources/config/services/fixture.xml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - diff --git a/src/Sylius/Bundle/FixturesBundle/Resources/config/services/integrations/doctrine/mongodb-odm.xml b/src/Sylius/Bundle/FixturesBundle/Resources/config/services/integrations/doctrine/mongodb-odm.xml deleted file mode 100644 index f51d11b67d..0000000000 --- a/src/Sylius/Bundle/FixturesBundle/Resources/config/services/integrations/doctrine/mongodb-odm.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - diff --git a/src/Sylius/Bundle/FixturesBundle/Resources/config/services/integrations/doctrine/orm.xml b/src/Sylius/Bundle/FixturesBundle/Resources/config/services/integrations/doctrine/orm.xml deleted file mode 100644 index 518434b1f1..0000000000 --- a/src/Sylius/Bundle/FixturesBundle/Resources/config/services/integrations/doctrine/orm.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - diff --git a/src/Sylius/Bundle/FixturesBundle/Resources/config/services/integrations/doctrine/phpcr-odm.xml b/src/Sylius/Bundle/FixturesBundle/Resources/config/services/integrations/doctrine/phpcr-odm.xml deleted file mode 100644 index cfb518e8f8..0000000000 --- a/src/Sylius/Bundle/FixturesBundle/Resources/config/services/integrations/doctrine/phpcr-odm.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - diff --git a/src/Sylius/Bundle/FixturesBundle/Resources/config/services/listener.xml b/src/Sylius/Bundle/FixturesBundle/Resources/config/services/listener.xml deleted file mode 100644 index e73d75c460..0000000000 --- a/src/Sylius/Bundle/FixturesBundle/Resources/config/services/listener.xml +++ /dev/null @@ -1,23 +0,0 @@ - - - - - - - - - - - - - - diff --git a/src/Sylius/Bundle/FixturesBundle/Resources/config/services/loader.xml b/src/Sylius/Bundle/FixturesBundle/Resources/config/services/loader.xml deleted file mode 100644 index e797f9dc82..0000000000 --- a/src/Sylius/Bundle/FixturesBundle/Resources/config/services/loader.xml +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/src/Sylius/Bundle/FixturesBundle/Resources/config/services/logger.xml b/src/Sylius/Bundle/FixturesBundle/Resources/config/services/logger.xml deleted file mode 100644 index a254d943b9..0000000000 --- a/src/Sylius/Bundle/FixturesBundle/Resources/config/services/logger.xml +++ /dev/null @@ -1,40 +0,0 @@ - - - - - - - - sylius_fixtures - - - - - - - null - true - - \Monolog\Logger::NOTICE - \Monolog\Logger::INFO - - - - - - - - - %%message%% %%context%% %%extra%% - - - diff --git a/src/Sylius/Bundle/FixturesBundle/Resources/config/services/suite.xml b/src/Sylius/Bundle/FixturesBundle/Resources/config/services/suite.xml deleted file mode 100644 index f141e21e66..0000000000 --- a/src/Sylius/Bundle/FixturesBundle/Resources/config/services/suite.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - - - - - - - - - - - - - - - diff --git a/src/Sylius/Bundle/FixturesBundle/Suite/LazySuiteRegistry.php b/src/Sylius/Bundle/FixturesBundle/Suite/LazySuiteRegistry.php deleted file mode 100644 index e5be712df9..0000000000 --- a/src/Sylius/Bundle/FixturesBundle/Suite/LazySuiteRegistry.php +++ /dev/null @@ -1,78 +0,0 @@ -suiteFactory = $suiteFactory; - } - - /** - * @param string $name - * @param array $configuration - */ - public function addSuite(string $name, array $configuration): void - { - $this->suiteDefinitions[$name] = $configuration; - } - - /** - * {@inheritdoc} - */ - public function getSuite(string $name): SuiteInterface - { - if (isset($this->suites[$name])) { - return $this->suites[$name]; - } - - if (!isset($this->suiteDefinitions[$name])) { - throw new SuiteNotFoundException($name); - } - - return $this->suites[$name] = $this->suiteFactory->createSuite($name, $this->suiteDefinitions[$name]); - } - - /** - * {@inheritdoc} - */ - public function getSuites(): array - { - $suites = []; - foreach (array_keys($this->suiteDefinitions) as $name) { - $suites[$name] = $this->getSuite($name); - } - - return $suites; - } -} diff --git a/src/Sylius/Bundle/FixturesBundle/Suite/Suite.php b/src/Sylius/Bundle/FixturesBundle/Suite/Suite.php deleted file mode 100644 index b91fc5683b..0000000000 --- a/src/Sylius/Bundle/FixturesBundle/Suite/Suite.php +++ /dev/null @@ -1,96 +0,0 @@ -name = $name; - $this->fixtures = new SplPriorityQueue(); - $this->listeners = new SplPriorityQueue(); - } - - /** - * @param FixtureInterface $fixture - * @param array $options - * @param int $priority - */ - public function addFixture(FixtureInterface $fixture, array $options, int $priority = 0): void - { - $this->fixtures->insert(['fixture' => $fixture, 'options' => $options], $priority); - } - - /** - * @param ListenerInterface $listener - * @param array $options - * @param int $priority - */ - public function addListener(ListenerInterface $listener, array $options, int $priority = 0): void - { - $this->listeners->insert(['listener' => $listener, 'options' => $options], $priority); - } - - /** - * {@inheritdoc} - */ - public function getName(): string - { - return $this->name; - } - - /** - * {@inheritdoc} - */ - public function getFixtures(): iterable - { - $fixtures = clone $this->fixtures; - foreach ($fixtures as $fixture) { - yield $fixture['fixture'] => $fixture['options']; - } - } - - /** - * {@inheritdoc} - */ - public function getListeners(): iterable - { - $listeners = clone $this->listeners; - foreach ($listeners as $listener) { - yield $listener['listener'] => $listener['options']; - } - } -} diff --git a/src/Sylius/Bundle/FixturesBundle/Suite/SuiteFactory.php b/src/Sylius/Bundle/FixturesBundle/Suite/SuiteFactory.php deleted file mode 100644 index 1498b9137b..0000000000 --- a/src/Sylius/Bundle/FixturesBundle/Suite/SuiteFactory.php +++ /dev/null @@ -1,106 +0,0 @@ -fixtureRegistry = $fixtureRegistry; - $this->listenerRegistry = $listenerRegistry; - $this->optionsProcessor = $optionsProcessor; - } - - /** - * {@inheritdoc} - */ - public function createSuite(string $name, array $configuration): SuiteInterface - { - Assert::keyExists($configuration, 'fixtures'); - Assert::keyExists($configuration, 'listeners'); - - $suite = new Suite($name); - - foreach ($configuration['fixtures'] as $fixtureAlias => $fixtureAttributes) { - $this->addFixtureToSuite($suite, $fixtureAlias, $fixtureAttributes); - } - - foreach ($configuration['listeners'] as $listenerName => $listenerAttributes) { - $this->addListenerToSuite($suite, $listenerName, $listenerAttributes); - } - - return $suite; - } - - /** - * @param Suite $suite - * @param string $fixtureAlias - * @param array $fixtureAttributes - */ - private function addFixtureToSuite(Suite $suite, string $fixtureAlias, array $fixtureAttributes): void - { - Assert::keyExists($fixtureAttributes, 'name'); - Assert::keyExists($fixtureAttributes, 'options'); - - $fixture = $this->fixtureRegistry->getFixture($fixtureAttributes['name']); - $fixtureOptions = $this->optionsProcessor->processConfiguration($fixture, $fixtureAttributes['options']); - $fixturePriority = $fixtureAttributes['priority'] ?? 0; - - $suite->addFixture($fixture, $fixtureOptions, $fixturePriority); - } - - /** - * @param Suite $suite - * @param string $listenerName - * @param array $listenerAttributes - */ - private function addListenerToSuite(Suite $suite, string $listenerName, array $listenerAttributes): void - { - Assert::keyExists($listenerAttributes, 'options'); - - $listener = $this->listenerRegistry->getListener($listenerName); - $listenerOptions = $this->optionsProcessor->processConfiguration($listener, $listenerAttributes['options']); - $listenerPriority = $listenerAttributes['priority'] ?? 0; - - $suite->addListener($listener, $listenerOptions, $listenerPriority); - } -} diff --git a/src/Sylius/Bundle/FixturesBundle/Suite/SuiteFactoryInterface.php b/src/Sylius/Bundle/FixturesBundle/Suite/SuiteFactoryInterface.php deleted file mode 100644 index 07774ab68a..0000000000 --- a/src/Sylius/Bundle/FixturesBundle/Suite/SuiteFactoryInterface.php +++ /dev/null @@ -1,25 +0,0 @@ -addCompilerPass(new FixtureRegistryPass()); - $container->addCompilerPass(new ListenerRegistryPass()); - } -} diff --git a/src/Sylius/Bundle/FixturesBundle/Tests/DependencyInjection/Compiler/FixtureRegistryPassTest.php b/src/Sylius/Bundle/FixturesBundle/Tests/DependencyInjection/Compiler/FixtureRegistryPassTest.php deleted file mode 100644 index fb04ab0aca..0000000000 --- a/src/Sylius/Bundle/FixturesBundle/Tests/DependencyInjection/Compiler/FixtureRegistryPassTest.php +++ /dev/null @@ -1,48 +0,0 @@ -setDefinition('sylius_fixtures.fixture_registry', new Definition()); - $this->setDefinition('acme.fixture', (new Definition())->addTag('sylius_fixtures.fixture')); - - $this->compile(); - - $this->assertContainerBuilderHasServiceDefinitionWithMethodCall( - 'sylius_fixtures.fixture_registry', - 'addFixture', - [new Reference('acme.fixture')] - ); - } - - /** - * {@inheritdoc} - */ - protected function registerCompilerPass(ContainerBuilder $container): void - { - $container->addCompilerPass(new FixtureRegistryPass()); - } -} diff --git a/src/Sylius/Bundle/FixturesBundle/Tests/DependencyInjection/Compiler/ListenerRegistryPassTest.php b/src/Sylius/Bundle/FixturesBundle/Tests/DependencyInjection/Compiler/ListenerRegistryPassTest.php deleted file mode 100644 index 6db7183e8d..0000000000 --- a/src/Sylius/Bundle/FixturesBundle/Tests/DependencyInjection/Compiler/ListenerRegistryPassTest.php +++ /dev/null @@ -1,48 +0,0 @@ -setDefinition('sylius_fixtures.listener_registry', new Definition()); - $this->setDefinition('acme.listener', (new Definition())->addTag('sylius_fixtures.listener')); - - $this->compile(); - - $this->assertContainerBuilderHasServiceDefinitionWithMethodCall( - 'sylius_fixtures.listener_registry', - 'addListener', - [new Reference('acme.listener')] - ); - } - - /** - * {@inheritdoc} - */ - protected function registerCompilerPass(ContainerBuilder $container): void - { - $container->addCompilerPass(new ListenerRegistryPass()); - } -} diff --git a/src/Sylius/Bundle/FixturesBundle/Tests/DependencyInjection/ConfigurationTest.php b/src/Sylius/Bundle/FixturesBundle/Tests/DependencyInjection/ConfigurationTest.php deleted file mode 100644 index f87559c873..0000000000 --- a/src/Sylius/Bundle/FixturesBundle/Tests/DependencyInjection/ConfigurationTest.php +++ /dev/null @@ -1,338 +0,0 @@ -assertConfigurationIsValid( - [['suites' => ['suite' => ['fixtures' => ['fixture' => null]]]]], - 'suites.*.fixtures' - ); - } - - /** - * @test - */ - public function multiple_suites_are_allowed(): void - { - $this->assertConfigurationIsValid( - [['suites' => [ - 'first_suite' => ['fixtures' => ['fixture' => null]], - 'second_suite' => ['fixtures' => ['fixture' => null]], - ]]], - 'suites.*.fixtures' - ); - } - - /** - * @test - */ - public function consecutive_configurations_can_add_suites(): void - { - $this->assertProcessedConfigurationEquals( - [ - ['suites' => [ - 'first_suite' => ['fixtures' => ['fixture' => null]], - ]], - ['suites' => [ - 'second_suite' => ['fixtures' => ['fixture' => null]], - ]], - ], - ['suites' => [ - 'first_suite' => ['fixtures' => ['fixture' => ['name' => 'fixture', 'options' => [[]], 'priority' => 0]]], - 'second_suite' => ['fixtures' => ['fixture' => ['name' => 'fixture', 'options' => [[]], 'priority' => 0]]], - ]], - 'suites.*.fixtures' - ); - } - - /** - * @test - */ - public function suite_can_have_multiple_fixtures(): void - { - $this->assertConfigurationIsValid( - [['suites' => ['suite' => ['fixtures' => [ - 'first_fixture' => null, - 'second_fixture' => null, - ]]]]], - 'suites.*.fixtures' - ); - } - - /** - * @test - */ - public function consecutive_configurations_can_remove_a_fixture_from_the_suite(): void - { - $this->assertProcessedConfigurationEquals( - [ - ['suites' => ['suite' => ['fixtures' => [ - 'first_fixture' => null, - 'second_fixture' => null, - ]]]], - ['suites' => ['suite' => ['fixtures' => [ - 'second_fixture' => false, - ]]]], - ], - ['suites' => ['suite' => ['fixtures' => [ - 'first_fixture' => ['name' => 'first_fixture', 'options' => [[]], 'priority' => 0], - ]]]], - 'suites.*.fixtures' - ); - } - - /** - * @test - */ - public function consecutive_configurations_can_add_fixtures_to_the_suite(): void - { - $this->assertProcessedConfigurationEquals( - [ - ['suites' => ['suite' => ['fixtures' => [ - 'first_fixture' => null, - ]]]], - ['suites' => ['suite' => ['fixtures' => [ - 'second_fixture' => null, - ]]]], - ], - ['suites' => ['suite' => ['fixtures' => [ - 'first_fixture' => ['name' => 'first_fixture', 'options' => [[]], 'priority' => 0], - 'second_fixture' => ['name' => 'second_fixture', 'options' => [[]], 'priority' => 0], - ]]]], - 'suites.*.fixtures' - ); - } - - /** - * @test - */ - public function all_fixture_options_from_consecutive_configurations_are_collected(): void - { - $this->assertProcessedConfigurationEquals( - [ - ['suites' => ['suite' => ['fixtures' => [ - 'fixture' => ['options' => ['option' => 4]], - ]]]], - ['suites' => ['suite' => ['fixtures' => [ - 'fixture' => ['options' => ['option' => 2]], - ]]]], - ], - ['suites' => ['suite' => ['fixtures' => [ - 'fixture' => ['name' => 'fixture', 'options' => [['option' => 4], ['option' => 2]], 'priority' => 0], - ]]]], - 'suites.*.fixtures' - ); - } - - /** - * @test - */ - public function fixture_options_are_not_replaced_implicitly(): void - { - $this->assertProcessedConfigurationEquals( - [ - ['suites' => ['suite' => ['fixtures' => [ - 'fixture' => ['options' => ['option' => 4]], - ]]]], - ['suites' => ['suite' => ['fixtures' => [ - 'fixture' => null, - ]]]], - ], - ['suites' => ['suite' => ['fixtures' => [ - 'fixture' => ['name' => 'fixture', 'options' => [['option' => 4]], 'priority' => 0], - ]]]], - 'suites.*.fixtures' - ); - } - - /** - * @test - */ - public function fixtures_options_are_an_array(): void - { - $this->assertPartialConfigurationIsInvalid( - [['suites' => ['suite' => ['fixtures' => ['fixture' => [ - 'options' => 42, - ]]]]]], - 'suites.*.fixtures' - ); - - $this->assertPartialConfigurationIsInvalid( - [['suites' => ['suite' => ['fixtures' => ['fixture' => [ - 'options' => 'string string', - ]]]]]], - 'suites.*.fixtures' - ); - } - - /** - * @test - */ - public function fixtures_options_may_contain_nested_arrays(): void - { - $this->assertProcessedConfigurationEquals( - [['suites' => ['suite' => ['fixtures' => ['fixture' => [ - 'options' => ['nested' => ['key' => 'value']], - ]]]]]], - ['suites' => ['suite' => ['fixtures' => ['fixture' => [ - 'options' => [['nested' => ['key' => 'value']]], - 'name' => 'fixture', // FIXME: something is wrong inside the test library and it's not excluded - ]]]]], - 'suites.*.fixtures.*.options' - ); - } - - /** - * @test - */ - public function listeners_options_are_an_array(): void - { - $this->assertPartialConfigurationIsInvalid( - [['suites' => ['suite' => ['listeners' => ['listener' => [ - 'options' => 42, - ]]]]]], - 'suites.*.listeners' - ); - - $this->assertPartialConfigurationIsInvalid( - [['suites' => ['suite' => ['listeners' => ['listener' => [ - 'options' => 'string string', - ]]]]]], - 'suites.*.listeners' - ); - } - - /** - * @test - */ - public function listeners_options_may_contain_nested_arrays(): void - { - $this->assertProcessedConfigurationEquals( - [['suites' => ['suite' => ['listeners' => ['listener' => [ - 'options' => ['nested' => ['key' => 'value']], - ]]]]]], - ['suites' => ['suite' => ['listeners' => ['listener' => [ - 'options' => [['nested' => ['key' => 'value']]], - ]]]]], - 'suites.*.listeners.*.options' - ); - } - - /** - * @test - */ - public function consecutive_configurations_can_remove_a_listener_from_the_suite(): void - { - $this->assertProcessedConfigurationEquals( - [ - ['suites' => ['suite' => ['listeners' => [ - 'first_listener' => null, - 'second_listener' => null, - ]]]], - ['suites' => ['suite' => ['listeners' => [ - 'second_listener' => false, - ]]]], - ], - ['suites' => ['suite' => ['listeners' => [ - 'first_listener' => ['options' => [[]], 'priority' => 0], - ]]]], - 'suites.*.listeners' - ); - } - - /** - * @test - */ - public function consecutive_configurations_can_add_a_listener_to_the_suite(): void - { - $this->assertProcessedConfigurationEquals( - [ - ['suites' => ['suite' => ['listeners' => [ - 'first_listener' => null, - ]]]], - ['suites' => ['suite' => ['listeners' => [ - 'second_listener' => null, - ]]]], - ], - ['suites' => ['suite' => ['listeners' => [ - 'first_listener' => ['options' => [[]], 'priority' => 0], - 'second_listener' => ['options' => [[]], 'priority' => 0], - ]]]], - 'suites.*.listeners' - ); - } - - /** - * @test - */ - public function fixtures_can_be_aliased_with_different_names(): void - { - $this->assertProcessedConfigurationEquals( - [ - ['suites' => ['suite' => ['fixtures' => [ - 'admin_user' => ['name' => 'user', 'options' => ['admin' => true]], - 'regular_user' => ['name' => 'user', 'options' => ['admin' => false]], - ]]]], - ], - ['suites' => ['suite' => ['fixtures' => [ - 'admin_user' => ['name' => 'user', 'options' => [['admin' => true]], 'priority' => 0], - 'regular_user' => ['name' => 'user', 'options' => [['admin' => false]], 'priority' => 0], - ]]]], - 'suites.*.fixtures' - ); - } - - /** - * @test - */ - public function consecutive_configurations_can_add_aliased_fixtures_to_the_suite(): void - { - $this->assertProcessedConfigurationEquals( - [ - ['suites' => ['suite' => ['fixtures' => [ - 'admin_user' => ['name' => 'user', 'options' => ['admin' => true]], - ]]]], - ['suites' => ['suite' => ['fixtures' => [ - 'regular_user' => ['name' => 'user', 'options' => ['admin' => false]], - ]]]], - ], - ['suites' => ['suite' => ['fixtures' => [ - 'admin_user' => ['name' => 'user', 'options' => [['admin' => true]], 'priority' => 0], - 'regular_user' => ['name' => 'user', 'options' => [['admin' => false]], 'priority' => 0], - ]]]], - 'suites.*.fixtures' - ); - } - - /** - * {@inheritdoc} - */ - protected function getConfiguration(): ConfigurationInterface - { - return new Configuration(); - } -} diff --git a/src/Sylius/Bundle/FixturesBundle/Tests/DependencyInjection/SyliusFixturesExtensionTest.php b/src/Sylius/Bundle/FixturesBundle/Tests/DependencyInjection/SyliusFixturesExtensionTest.php deleted file mode 100644 index 0e18d8d52d..0000000000 --- a/src/Sylius/Bundle/FixturesBundle/Tests/DependencyInjection/SyliusFixturesExtensionTest.php +++ /dev/null @@ -1,52 +0,0 @@ -load(); - } - - /** - * @test - */ - public function it_registers_configured_suites(): void - { - $this->load(['suites' => [ - 'suite_name' => [], - ]]); - - $suiteRegistryDefinition = $this->container->findDefinition('sylius_fixtures.suite_registry'); - $suiteMethodCall = $suiteRegistryDefinition->getMethodCalls()[0]; - - static::assertSame('addSuite', $suiteMethodCall[0]); - static::assertSame('suite_name', $suiteMethodCall[1][0]); - } - - /** - * {@inheritdoc} - */ - protected function getContainerExtensions(): array - { - return [new SyliusFixturesExtension()]; - } -} diff --git a/src/Sylius/Bundle/FixturesBundle/Tests/Listener/MongoDBPurgerListenerTest.php b/src/Sylius/Bundle/FixturesBundle/Tests/Listener/MongoDBPurgerListenerTest.php deleted file mode 100644 index 672e33d947..0000000000 --- a/src/Sylius/Bundle/FixturesBundle/Tests/Listener/MongoDBPurgerListenerTest.php +++ /dev/null @@ -1,49 +0,0 @@ -assertProcessedConfigurationEquals([[]], ['managers' => [null]], 'managers'); - } - - /** - * @test - */ - public function managers_are_optional(): void - { - $this->assertProcessedConfigurationEquals([['managers' => ['custom']]], ['managers' => ['custom']], 'managers'); - } - - /** - * {@inheritdoc} - */ - protected function getConfiguration(): ConfigurationInterface - { - return new MongoDBPurgerListener($this->getMockBuilder(ManagerRegistry::class)->getMock()); - } -} diff --git a/src/Sylius/Bundle/FixturesBundle/Tests/Listener/ORMPurgerListenerTest.php b/src/Sylius/Bundle/FixturesBundle/Tests/Listener/ORMPurgerListenerTest.php deleted file mode 100644 index 3e4c959336..0000000000 --- a/src/Sylius/Bundle/FixturesBundle/Tests/Listener/ORMPurgerListenerTest.php +++ /dev/null @@ -1,73 +0,0 @@ -assertProcessedConfigurationEquals([[]], ['mode' => 'delete'], 'mode'); - } - - /** - * @test - */ - public function purge_mode_can_be_changed_to_truncate(): void - { - $this->assertProcessedConfigurationEquals([['mode' => 'truncate']], ['mode' => 'truncate'], 'mode'); - } - - /** - * @test - */ - public function purge_mode_can_be_either_delete_or_truncate(): void - { - $this->assertPartialConfigurationIsInvalid([['mode' => 'lol']], 'mode'); - } - - /** - * @test - */ - public function managers_are_set_to_null_by_default(): void - { - $this->assertProcessedConfigurationEquals([[]], ['managers' => [null]], 'managers'); - } - - /** - * @test - */ - public function managers_are_optional(): void - { - $this->assertProcessedConfigurationEquals([['managers' => ['custom']]], ['managers' => ['custom']], 'managers'); - } - - /** - * {@inheritdoc} - */ - protected function getConfiguration(): ConfigurationInterface - { - return new ORMPurgerListener($this->getMockBuilder(ManagerRegistry::class)->getMock()); - } -} diff --git a/src/Sylius/Bundle/FixturesBundle/Tests/Listener/PHPCRPurgerListenerTest.php b/src/Sylius/Bundle/FixturesBundle/Tests/Listener/PHPCRPurgerListenerTest.php deleted file mode 100644 index 3e91cf6281..0000000000 --- a/src/Sylius/Bundle/FixturesBundle/Tests/Listener/PHPCRPurgerListenerTest.php +++ /dev/null @@ -1,49 +0,0 @@ -assertProcessedConfigurationEquals([[]], ['managers' => [null]], 'managers'); - } - - /** - * @test - */ - public function managers_are_optional(): void - { - $this->assertProcessedConfigurationEquals([['managers' => ['custom']]], ['managers' => ['custom']], 'managers'); - } - - /** - * {@inheritdoc} - */ - protected function getConfiguration(): ConfigurationInterface - { - return new PHPCRPurgerListener($this->getMockBuilder(ManagerRegistry::class)->getMock()); - } -} diff --git a/src/Sylius/Bundle/FixturesBundle/composer.json b/src/Sylius/Bundle/FixturesBundle/composer.json deleted file mode 100644 index 9e80b461a1..0000000000 --- a/src/Sylius/Bundle/FixturesBundle/composer.json +++ /dev/null @@ -1,73 +0,0 @@ -{ - "name": "sylius/fixtures-bundle", - "type": "symfony-bundle", - "description": "Configurable fixtures for Symfony applications.", - "keywords": ["sylius", "fixtures", "symfony"], - "homepage": "http://sylius.com", - "license": "MIT", - "authors": [ - { - "name": "Kamil Kokot", - "homepage": "http://kamil.kokot.me" - }, - { - "name": "Sylius project", - "homepage": "http://sylius.com" - }, - { - "name": "Community contributions", - "homepage": "http://github.com/Sylius/Sylius/contributors" - } - ], - "require": { - "php": "^7.1", - - "doctrine/data-fixtures": "^1.2", - "monolog/monolog": "^1.8", - "symfony/framework-bundle": "^3.4", - "symfony/monolog-bridge": "^3.4", - "webmozart/assert": "^1.0", - "zendframework/zend-stdlib": "^3.0" - }, - "require-dev": { - "doctrine/orm": "^2.5", - "doctrine/doctrine-bundle": "^1.3", - "matthiasnoback/symfony-config-test": "^3.0", - "matthiasnoback/symfony-dependency-injection-test": "^2.0", - "phpspec/phpspec": "^4.0", - "phpunit/phpunit": "^6.5", - "twig/twig": "^2.0", - "symfony/browser-kit": "^3.4", - "symfony/dependency-injection": "^3.4", - "symfony/templating": "^3.4", - "symfony/translation": "^3.4", - "symfony/twig-bundle": "^3.4", - "symfony/security-csrf": "^3.4", - "polishsymfonycommunity/symfony-mocker-container": "^1.0" - }, - "config": { - "bin-dir": "bin" - }, - "autoload": { - "psr-4": { "Sylius\\Bundle\\FixturesBundle\\": "" } - }, - "autoload-dev": { - "psr-4": { - "Sylius\\Bundle\\FixturesBundle\\spec\\": "spec/", - "AppBundle\\": "test/src/AppBundle/" - } - }, - "minimum-stability": "dev", - "prefer-stable": true, - "repositories": [ - { - "type": "path", - "url": "../../*/*" - } - ], - "extra": { - "branch-alias": { - "dev-master": "1.1-dev" - } - } -} diff --git a/src/Sylius/Bundle/FixturesBundle/humbug.json.dist b/src/Sylius/Bundle/FixturesBundle/humbug.json.dist deleted file mode 100644 index 353452a063..0000000000 --- a/src/Sylius/Bundle/FixturesBundle/humbug.json.dist +++ /dev/null @@ -1,17 +0,0 @@ -{ - "source": { - "directories": [ - "." - ], - "excludes": [ - "bin", - "spec", - "Tests", - "vendor" - ] - }, - "timeout": 2, - "logs": { - "text": "humbuglog.txt" - } -} diff --git a/src/Sylius/Bundle/FixturesBundle/phpspec.yml.dist b/src/Sylius/Bundle/FixturesBundle/phpspec.yml.dist deleted file mode 100644 index 8b324c7bc2..0000000000 --- a/src/Sylius/Bundle/FixturesBundle/phpspec.yml.dist +++ /dev/null @@ -1,5 +0,0 @@ -suites: - main: - namespace: Sylius\Bundle\FixturesBundle - psr4_prefix: Sylius\Bundle\FixturesBundle - src_path: . diff --git a/src/Sylius/Bundle/FixturesBundle/phpunit.xml.dist b/src/Sylius/Bundle/FixturesBundle/phpunit.xml.dist deleted file mode 100644 index 4cf2463185..0000000000 --- a/src/Sylius/Bundle/FixturesBundle/phpunit.xml.dist +++ /dev/null @@ -1,30 +0,0 @@ - - - - - - - - - - - - ./Tests - - - - ./test/ - - - - - - ./Tests - - - diff --git a/src/Sylius/Bundle/FixturesBundle/spec/Fixture/FixtureNotFoundExceptionSpec.php b/src/Sylius/Bundle/FixturesBundle/spec/Fixture/FixtureNotFoundExceptionSpec.php deleted file mode 100644 index 6fad4e0e0d..0000000000 --- a/src/Sylius/Bundle/FixturesBundle/spec/Fixture/FixtureNotFoundExceptionSpec.php +++ /dev/null @@ -1,34 +0,0 @@ -beConstructedWith('fixture_name'); - } - - function it_is_an_invalid_argument_exception(): void - { - $this->shouldHaveType(\InvalidArgumentException::class); - } - - function it_has_preformatted_message(): void - { - $this->getMessage()->shouldReturn('Fixture with name "fixture_name" could not be found!'); - } -} diff --git a/src/Sylius/Bundle/FixturesBundle/spec/Fixture/FixtureRegistrySpec.php b/src/Sylius/Bundle/FixturesBundle/spec/Fixture/FixtureRegistrySpec.php deleted file mode 100644 index 090e53924c..0000000000 --- a/src/Sylius/Bundle/FixturesBundle/spec/Fixture/FixtureRegistrySpec.php +++ /dev/null @@ -1,59 +0,0 @@ -shouldImplement(FixtureRegistryInterface::class); - } - - function it_has_a_fixtures(FixtureInterface $fixture): void - { - $fixture->getName()->willReturn('fixture'); - - $this->addFixture($fixture); - - $this->getFixture('fixture')->shouldReturn($fixture); - $this->getFixtures()->shouldReturn(['fixture' => $fixture]); - } - - function it_throws_an_exception_if_trying_to_another_fixture_with_the_same_name( - FixtureInterface $fixture, - FixtureInterface $anotherFixture - ): void { - $fixture->getName()->willReturn('fixture'); - $anotherFixture->getName()->willReturn('fixture'); - - $this->addFixture($fixture); - $this->shouldThrow(\InvalidArgumentException::class)->during('addFixture', [$fixture]); - $this->shouldThrow(\InvalidArgumentException::class)->during('addFixture', [$anotherFixture]); - } - - function it_returns_an_empty_fixtures_list_if_it_does_not_have_any_fixtures(): void - { - $this->getFixtures()->shouldReturn([]); - } - - function it_throws_an_exception_if_trying_to_get_unexisting_fixture_by_name(): void - { - $this->shouldThrow(FixtureNotFoundException::class)->during('getFixture', ['fixture']); - } -} diff --git a/src/Sylius/Bundle/FixturesBundle/spec/Listener/ListenerNotFoundExceptionSpec.php b/src/Sylius/Bundle/FixturesBundle/spec/Listener/ListenerNotFoundExceptionSpec.php deleted file mode 100644 index db97b5f408..0000000000 --- a/src/Sylius/Bundle/FixturesBundle/spec/Listener/ListenerNotFoundExceptionSpec.php +++ /dev/null @@ -1,34 +0,0 @@ -beConstructedWith('listener_name'); - } - - function it_is_an_invalid_argument_exception(): void - { - $this->shouldHaveType(\InvalidArgumentException::class); - } - - function it_has_preformatted_message(): void - { - $this->getMessage()->shouldReturn('Listener with name "listener_name" could not be found!'); - } -} diff --git a/src/Sylius/Bundle/FixturesBundle/spec/Listener/ListenerRegistrySpec.php b/src/Sylius/Bundle/FixturesBundle/spec/Listener/ListenerRegistrySpec.php deleted file mode 100644 index becfbb396d..0000000000 --- a/src/Sylius/Bundle/FixturesBundle/spec/Listener/ListenerRegistrySpec.php +++ /dev/null @@ -1,59 +0,0 @@ -shouldImplement(ListenerRegistryInterface::class); - } - - function it_has_a_listener(ListenerInterface $listener): void - { - $listener->getName()->willReturn('listener_name'); - - $this->addListener($listener); - - $this->getListener('listener_name')->shouldReturn($listener); - $this->getListeners()->shouldReturn(['listener_name' => $listener]); - } - - function it_throws_an_exception_if_trying_to_another_listener_with_the_same_name( - ListenerInterface $listener, - ListenerInterface $anotherListener - ): void { - $listener->getName()->willReturn('listener_name'); - $anotherListener->getName()->willReturn('listener_name'); - - $this->addListener($listener); - $this->shouldThrow(\InvalidArgumentException::class)->during('addListener', [$listener]); - $this->shouldThrow(\InvalidArgumentException::class)->during('addListener', [$anotherListener]); - } - - function it_returns_an_empty_listeners_list_if_it_does_not_have_any_listeners(): void - { - $this->getListeners()->shouldReturn([]); - } - - function it_throws_an_exception_if_trying_to_get_unexisting_listener_by_name(): void - { - $this->shouldThrow(ListenerNotFoundException::class)->during('getListener', ['listener_name']); - } -} diff --git a/src/Sylius/Bundle/FixturesBundle/spec/Listener/LoggerListenerSpec.php b/src/Sylius/Bundle/FixturesBundle/spec/Listener/LoggerListenerSpec.php deleted file mode 100644 index 98922173f7..0000000000 --- a/src/Sylius/Bundle/FixturesBundle/spec/Listener/LoggerListenerSpec.php +++ /dev/null @@ -1,70 +0,0 @@ -beConstructedWith($logger); - } - - function it_implements_listener_interface(): void - { - $this->shouldImplement(ListenerInterface::class); - } - - function it_listens_for_before_suite_events(): void - { - $this->shouldImplement(BeforeSuiteListenerInterface::class); - } - - function it_listens_for_before_fixture_events(): void - { - $this->shouldImplement(BeforeFixtureListenerInterface::class); - } - - function it_logs_suite_name_on_before_suite_event(LoggerInterface $logger, SuiteInterface $suite): void - { - $suite->getName()->willReturn('uber_suite'); - - $logger->notice(Argument::that(function ($argument) use ($suite) { - return false !== strpos($argument, $suite->getWrappedObject()->getName()); - }))->shouldBeCalled(); - - $this->beforeSuite(new SuiteEvent($suite->getWrappedObject()), []); - } - - function it_logs_fixture_name_on_before_fixture_event(LoggerInterface $logger, SuiteInterface $suite, FixtureInterface $fixture): void - { - $fixture->getName()->willReturn('uber_fixture'); - - $logger->notice(Argument::that(function ($argument) use ($fixture) { - return false !== strpos($argument, $fixture->getWrappedObject()->getName()); - }))->shouldBeCalled(); - - $this->beforeFixture(new FixtureEvent($suite->getWrappedObject(), $fixture->getWrappedObject(), []), []); - } -} diff --git a/src/Sylius/Bundle/FixturesBundle/spec/Loader/FixtureLoaderSpec.php b/src/Sylius/Bundle/FixturesBundle/spec/Loader/FixtureLoaderSpec.php deleted file mode 100644 index dbbcf1ad8a..0000000000 --- a/src/Sylius/Bundle/FixturesBundle/spec/Loader/FixtureLoaderSpec.php +++ /dev/null @@ -1,34 +0,0 @@ -shouldImplement(FixtureLoaderInterface::class); - } - - function it_loads_a_fixture(SuiteInterface $suite, FixtureInterface $fixture): void - { - $fixture->load(['options'])->shouldBeCalled(); - - $this->load($suite, $fixture, ['options']); - } -} diff --git a/src/Sylius/Bundle/FixturesBundle/spec/Loader/HookableFixtureLoaderSpec.php b/src/Sylius/Bundle/FixturesBundle/spec/Loader/HookableFixtureLoaderSpec.php deleted file mode 100644 index cbcade2896..0000000000 --- a/src/Sylius/Bundle/FixturesBundle/spec/Loader/HookableFixtureLoaderSpec.php +++ /dev/null @@ -1,104 +0,0 @@ -beConstructedWith($decoratedFixtureLoader); - } - - function it_implements_fixture_loader_interface(): void - { - $this->shouldImplement(FixtureLoaderInterface::class); - } - - function it_delegates_fixture_loading_to_the_base_loader( - FixtureLoaderInterface $decoratedFixtureLoader, - SuiteInterface $suite, - FixtureInterface $fixture - ): void { - $suite->getListeners()->willReturn([]); - - $decoratedFixtureLoader->load($suite, $fixture, ['fixture_option' => 'fixture_value'])->shouldBeCalled(); - - $this->load($suite, $fixture, ['fixture_option' => 'fixture_value']); - } - - function it_executes_before_fixture_listeners( - FixtureLoaderInterface $decoratedFixtureLoader, - SuiteInterface $suite, - FixtureInterface $fixture, - BeforeFixtureListenerInterface $beforeFixtureListener - ): void { - $suite->getListeners()->will(function () use ($beforeFixtureListener) { - yield $beforeFixtureListener->getWrappedObject() => []; - }); - - $beforeFixtureListener->beforeFixture(new FixtureEvent($suite->getWrappedObject(), $fixture->getWrappedObject(), ['fixture_option' => 'fixture_value']), [])->shouldBeCalledTimes(1); - - $decoratedFixtureLoader->load($suite, $fixture, ['fixture_option' => 'fixture_value'])->shouldBeCalled(); - - $this->load($suite, $fixture, ['fixture_option' => 'fixture_value']); - } - - function it_executes_after_fixture_listeners( - FixtureLoaderInterface $decoratedFixtureLoader, - SuiteInterface $suite, - FixtureInterface $fixture, - AfterFixtureListenerInterface $afterFixtureListener - ): void { - $suite->getListeners()->will(function () use ($afterFixtureListener) { - yield $afterFixtureListener->getWrappedObject() => []; - }); - - $decoratedFixtureLoader->load($suite, $fixture, ['fixture_option' => 'fixture_value'])->shouldBeCalled(); - - $afterFixtureListener->afterFixture(new FixtureEvent($suite->getWrappedObject(), $fixture->getWrappedObject(), ['fixture_option' => 'fixture_value']), [])->shouldBeCalledTimes(1); - - $this->load($suite, $fixture, ['fixture_option' => 'fixture_value']); - } - - function it_executes_customized_fixture_listeners( - FixtureLoaderInterface $decoratedFixtureLoader, - SuiteInterface $suite, - FixtureInterface $fixture, - BeforeFixtureListenerInterface $beforeFixtureListener, - AfterFixtureListenerInterface $afterFixtureListener - ): void { - $suite->getListeners()->will(function () use ($beforeFixtureListener, $afterFixtureListener) { - yield $beforeFixtureListener->getWrappedObject() => ['listener_option1' => 'listener_value1']; - yield $afterFixtureListener->getWrappedObject() => ['listener_option2' => 'listener_value2']; - }); - - $fixtureEvent = new FixtureEvent($suite->getWrappedObject(), $fixture->getWrappedObject(), ['fixture_option' => 'fixture_value']); - - $beforeFixtureListener->beforeFixture($fixtureEvent, ['listener_option1' => 'listener_value1'])->shouldBeCalledTimes(1); - - $decoratedFixtureLoader->load($suite, $fixture, ['fixture_option' => 'fixture_value'])->shouldBeCalled(); - - $afterFixtureListener->afterFixture($fixtureEvent, ['listener_option2' => 'listener_value2'])->shouldBeCalledTimes(1); - - $this->load($suite, $fixture, ['fixture_option' => 'fixture_value']); - } -} diff --git a/src/Sylius/Bundle/FixturesBundle/spec/Loader/HookableSuiteLoaderSpec.php b/src/Sylius/Bundle/FixturesBundle/spec/Loader/HookableSuiteLoaderSpec.php deleted file mode 100644 index a5daf11cd1..0000000000 --- a/src/Sylius/Bundle/FixturesBundle/spec/Loader/HookableSuiteLoaderSpec.php +++ /dev/null @@ -1,95 +0,0 @@ -beConstructedWith($decoratedSuiteLoader); - } - - function it_implements_suite_loader_interface(): void - { - $this->shouldImplement(SuiteLoaderInterface::class); - } - - function it_delegates_suite_loading_to_the_base_loader(SuiteLoaderInterface $decoratedSuiteLoader, SuiteInterface $suite): void - { - $suite->getListeners()->willReturn([]); - - $decoratedSuiteLoader->load($suite)->shouldBeCalled(); - - $this->load($suite); - } - - function it_executes_before_suite_listeners( - SuiteLoaderInterface $decoratedSuiteLoader, - SuiteInterface $suite, - BeforeSuiteListenerInterface $beforeSuiteListener - ): void { - $suite->getListeners()->will(function () use ($beforeSuiteListener) { - yield $beforeSuiteListener->getWrappedObject() => []; - }); - - $beforeSuiteListener->beforeSuite(new SuiteEvent($suite->getWrappedObject()), [])->shouldBeCalledTimes(1); - - $decoratedSuiteLoader->load($suite)->shouldBeCalled(); - - $this->load($suite); - } - - function it_executes_after_suite_listeners( - SuiteLoaderInterface $decoratedSuiteLoader, - SuiteInterface $suite, - AfterSuiteListenerInterface $afterSuiteListener - ): void { - $suite->getListeners()->will(function () use ($afterSuiteListener) { - yield $afterSuiteListener->getWrappedObject() => []; - }); - - $decoratedSuiteLoader->load($suite)->shouldBeCalled(); - - $afterSuiteListener->afterSuite(new SuiteEvent($suite->getWrappedObject()), [])->shouldBeCalledTimes(1); - - $this->load($suite); - } - - function it_executes_customized_suite_listeners( - SuiteLoaderInterface $decoratedSuiteLoader, - SuiteInterface $suite, - BeforeSuiteListenerInterface $beforeSuiteListener, - AfterSuiteListenerInterface $afterSuiteListener - ): void { - $suite->getListeners()->will(function () use ($beforeSuiteListener, $afterSuiteListener) { - yield $beforeSuiteListener->getWrappedObject() => ['listener_option1' => 'listener_value1']; - yield $afterSuiteListener->getWrappedObject() => ['listener_option2' => 'listener_value2']; - }); - - $beforeSuiteListener->beforeSuite(new SuiteEvent($suite->getWrappedObject()), ['listener_option1' => 'listener_value1'])->shouldBeCalledTimes(1); - - $decoratedSuiteLoader->load($suite)->shouldBeCalled(); - - $afterSuiteListener->afterSuite(new SuiteEvent($suite->getWrappedObject()), ['listener_option2' => 'listener_value2'])->shouldBeCalledTimes(1); - - $this->load($suite); - } -} diff --git a/src/Sylius/Bundle/FixturesBundle/spec/Loader/SuiteLoaderSpec.php b/src/Sylius/Bundle/FixturesBundle/spec/Loader/SuiteLoaderSpec.php deleted file mode 100644 index 97f27edc87..0000000000 --- a/src/Sylius/Bundle/FixturesBundle/spec/Loader/SuiteLoaderSpec.php +++ /dev/null @@ -1,50 +0,0 @@ -beConstructedWith($fixtureLoader); - } - - function it_implements_suite_loader_interface(): void - { - $this->shouldImplement(SuiteLoaderInterface::class); - } - - function it_loads_suite_fixtures( - FixtureLoaderInterface $fixtureLoader, - SuiteInterface $suite, - FixtureInterface $firstFixture, - FixtureInterface $secondFixture - ): void { - $suite->getFixtures()->will(function () use ($firstFixture, $secondFixture) { - yield $firstFixture->getWrappedObject() => ['options 1']; - yield $secondFixture->getWrappedObject() => ['options 2']; - }); - - $fixtureLoader->load($suite, $firstFixture, ['options 1'])->shouldBeCalled(); - $fixtureLoader->load($suite, $secondFixture, ['options 2'])->shouldBeCalled(); - - $this->load($suite); - } -} diff --git a/src/Sylius/Bundle/FixturesBundle/spec/Suite/LazySuiteRegistrySpec.php b/src/Sylius/Bundle/FixturesBundle/spec/Suite/LazySuiteRegistrySpec.php deleted file mode 100644 index 9932d96ff9..0000000000 --- a/src/Sylius/Bundle/FixturesBundle/spec/Suite/LazySuiteRegistrySpec.php +++ /dev/null @@ -1,63 +0,0 @@ -beConstructedWith($suiteFactory); - } - - function it_implements_suite_registry_interface(): void - { - $this->shouldImplement(SuiteRegistryInterface::class); - } - - function it_returns_a_constructed_suite(SuiteFactoryInterface $suiteFactory, SuiteInterface $suite): void - { - $this->addSuite('suite_name', ['fixtures' => []]); - - $suiteFactory->createSuite('suite_name', ['fixtures' => []])->willReturn($suite); - - $this->getSuite('suite_name')->shouldReturn($suite); - $this->getSuites()->shouldReturn(['suite_name' => $suite]); - } - - function it_constructs_a_suite_only_once(SuiteFactoryInterface $suiteFactory, SuiteInterface $suite): void - { - $this->addSuite('suite_name', ['fixtures' => []]); - - $suiteFactory->createSuite('suite_name', ['fixtures' => []])->shouldBeCalledTimes(1)->willReturn($suite); - - $this->getSuite('suite_name')->shouldReturn($suite); - $this->getSuite('suite_name')->shouldReturn($suite); - } - - function it_returns_an_empty_suites_list_if_none_was_registered(): void - { - $this->getSuites()->shouldReturn([]); - } - - function it_throws_an_exception_if_trying_to_get_unexisting_suite(): void - { - $this->shouldThrow(SuiteNotFoundException::class)->during('getSuite', ['the_river_snake_is_dangerous']); - } -} diff --git a/src/Sylius/Bundle/FixturesBundle/spec/Suite/SuiteFactorySpec.php b/src/Sylius/Bundle/FixturesBundle/spec/Suite/SuiteFactorySpec.php deleted file mode 100644 index b427e8eacd..0000000000 --- a/src/Sylius/Bundle/FixturesBundle/spec/Suite/SuiteFactorySpec.php +++ /dev/null @@ -1,223 +0,0 @@ -beConstructedWith($fixtureRegistry, $listenerRegistry, $optionsProcessor); - } - - function it_implements_suite_factory_interface(): void - { - $this->shouldImplement(SuiteFactoryInterface::class); - } - - function it_creates_a_new_empty_suite(): void - { - $suite = $this->createSuite('suite_name', ['listeners' => [], 'fixtures' => []]); - - $suite->getName()->shouldReturn('suite_name'); - $suite->getFixtures()->shouldIterateAs([]); - } - - function it_creates_a_new_suite_with_fixtures( - FixtureRegistryInterface $fixtureRegistry, - Processor $optionsProcessor, - FixtureInterface $firstFixture, - FixtureInterface $secondFixture - ): void { - $fixtureRegistry->getFixture('first_fixture')->willReturn($firstFixture); - $fixtureRegistry->getFixture('second_fixture')->willReturn($secondFixture); - - $optionsProcessor->processConfiguration($firstFixture, [[]])->willReturn([]); - $optionsProcessor->processConfiguration($secondFixture, [[]])->willReturn([]); - - $suite = $this->createSuite('suite_name', ['listeners' => [], 'fixtures' => [ - 'first_fixture' => ['name' => 'first_fixture', 'options' => [[]]], - 'second_fixture' => ['name' => 'second_fixture', 'options' => [[]]], - ]]); - - $suite->getName()->shouldReturn('suite_name'); - $suite->getFixtures()->shouldIterateAs($this->createGenerator($firstFixture, $secondFixture)); - } - - function it_creates_a_new_suite_with_fixtures_based_on_its_name_rather_than_alias( - FixtureRegistryInterface $fixtureRegistry, - Processor $optionsProcessor, - FixtureInterface $fixture - ): void { - $fixtureRegistry->getFixture('fixture_name')->shouldBeCalled()->willReturn($fixture); - $fixtureRegistry->getFixture('fixture_alias')->shouldNotBeCalled(); - - $optionsProcessor->processConfiguration($fixture, [[]])->willReturn([]); - - $suite = $this->createSuite('suite_name', ['listeners' => [], 'fixtures' => [ - 'fixture_alias' => ['name' => 'fixture_name', 'options' => [[]]], - ]]); - - $suite->getName()->shouldReturn('suite_name'); - $suite->getFixtures()->shouldIterateAs($this->createGenerator($fixture)); - } - - function it_creates_a_new_suite_with_prioritized_fixtures( - FixtureRegistryInterface $fixtureRegistry, - Processor $optionsProcessor, - FixtureInterface $fixture, - FixtureInterface $higherPriorityFixture - ): void { - $fixtureRegistry->getFixture('fixture')->willReturn($fixture); - $fixtureRegistry->getFixture('higher_priority_fixture')->willReturn($higherPriorityFixture); - - $optionsProcessor->processConfiguration($fixture, [[]])->willReturn([]); - $optionsProcessor->processConfiguration($higherPriorityFixture, [[]])->willReturn([]); - - $suite = $this->createSuite('suite_name', ['listeners' => [], 'fixtures' => [ - 'fixture' => ['name' => 'fixture', 'priority' => 5, 'options' => [[]]], - 'higher_priority_fixture' => ['name' => 'higher_priority_fixture', 'priority' => 10, 'options' => [[]]], - ]]); - - $suite->getName()->shouldReturn('suite_name'); - $suite->getFixtures()->shouldIterateAs($this->createGenerator($higherPriorityFixture, $fixture)); - } - - function it_creates_a_new_suite_with_customized_fixture( - FixtureRegistryInterface $fixtureRegistry, - Processor $optionsProcessor, - FixtureInterface $fixture - ): void { - $fixtureRegistry->getFixture('fixture')->willReturn($fixture); - - $optionsProcessor->processConfiguration($fixture, [['fixture_option' => 'fixture_value']])->willReturn(['fixture_option' => 'fixture_value']); - - $suite = $this->createSuite('suite_name', ['listeners' => [], 'fixtures' => [ - 'fixture' => ['name' => 'fixture', 'options' => [['fixture_option' => 'fixture_value']]], - ]]); - - $suite->getName()->shouldReturn('suite_name'); - $suite->getFixtures()->shouldHaveKeyWithValue($fixture, ['fixture_option' => 'fixture_value']); - } - - function it_creates_a_new_suite_with_listeners( - ListenerRegistryInterface $listenerRegistry, - Processor $optionsProcessor, - ListenerInterface $firstListener, - ListenerInterface $secondListener - ): void { - $listenerRegistry->getListener('first_listener')->willReturn($firstListener); - $listenerRegistry->getListener('second_listener')->willReturn($secondListener); - - $optionsProcessor->processConfiguration($firstListener, [[]])->willReturn([]); - $optionsProcessor->processConfiguration($secondListener, [[]])->willReturn([]); - - $suite = $this->createSuite('suite_name', ['fixtures' => [], 'listeners' => [ - 'first_listener' => ['options' => [[]]], - 'second_listener' => ['options' => [[]]], - ]]); - - $suite->getName()->shouldReturn('suite_name'); - $suite->getListeners()->shouldIterateAs($this->createGenerator($firstListener, $secondListener)); - } - - function it_creates_a_new_suite_with_prioritized_listeners( - ListenerRegistryInterface $listenerRegistry, - Processor $optionsProcessor, - ListenerInterface $listener, - ListenerInterface $higherPriorityListener - ): void { - $listenerRegistry->getListener('listener')->willReturn($listener); - $listenerRegistry->getListener('higher_priority_listener')->willReturn($higherPriorityListener); - - $optionsProcessor->processConfiguration($listener, [[]])->willReturn([]); - $optionsProcessor->processConfiguration($higherPriorityListener, [[]])->willReturn([]); - - $suite = $this->createSuite('suite_name', ['fixtures' => [], 'listeners' => [ - 'listener' => ['priority' => 5, 'options' => [[]]], - 'higher_priority_listener' => ['priority' => 10, 'options' => [[]]], - ]]); - - $suite->getName()->shouldReturn('suite_name'); - $suite->getListeners()->shouldIterateAs($this->createGenerator($higherPriorityListener, $listener)); - } - - function it_creates_a_new_suite_with_customized_listener( - ListenerRegistryInterface $listenerRegistry, - Processor $optionsProcessor, - ListenerInterface $listener - ): void { - $listenerRegistry->getListener('listener')->willReturn($listener); - - $optionsProcessor->processConfiguration($listener, [['listener_option' => 'listener_value']])->willReturn(['listener_option' => 'listener_value']); - - $suite = $this->createSuite('suite_name', ['fixtures' => [], 'listeners' => [ - 'listener' => ['options' => [['listener_option' => 'listener_value']]], - ]]); - - $suite->getName()->shouldReturn('suite_name'); - $suite->getListeners()->shouldHaveKeyWithValue($listener, ['listener_option' => 'listener_value']); - } - - function it_throws_an_exception_if_suite_options_does_not_have_fixtures(): void - { - $this->shouldThrow(\InvalidArgumentException::class)->during('createSuite', ['suite_name', ['listeners' => []]]); - } - - function it_throws_an_exception_if_suite_options_does_not_have_listeners(): void - { - $this->shouldThrow(\InvalidArgumentException::class)->during('createSuite', ['suite_name', ['fixtures' => []]]); - } - - function it_throws_an_exception_if_fixture_does_not_have_options_defined(): void - { - $this->shouldThrow(\InvalidArgumentException::class)->during('createSuite', ['suite_name', ['listeners' => [], 'fixtures' => [ - 'fixture' => ['name' => 'fixture'], - ]]]); - } - - function it_throws_an_exception_if_fixture_does_not_have_name_defined(): void - { - $this->shouldThrow(\InvalidArgumentException::class)->during('createSuite', ['suite_name', ['listeners' => [], 'fixtures' => [ - 'fixture' => ['options' => []], - ]]]); - } - - function it_throws_an_exception_if_listener_does_not_have_options_defined(): void - { - $this->shouldThrow(\InvalidArgumentException::class)->during('createSuite', ['suite_name', ['fixtures' => [], 'listeners' => [ - 'listener' => [], - ]]]); - } - - /** - * @param Collaborator[] ...$collaborators - * - * @return \Generator - */ - private function createGenerator(Collaborator ...$collaborators): \Generator - { - foreach ($collaborators as $collaborator) { - yield $collaborator->getWrappedObject() => []; - } - } -} diff --git a/src/Sylius/Bundle/FixturesBundle/spec/Suite/SuiteNotFoundExceptionSpec.php b/src/Sylius/Bundle/FixturesBundle/spec/Suite/SuiteNotFoundExceptionSpec.php deleted file mode 100644 index 354811cbe7..0000000000 --- a/src/Sylius/Bundle/FixturesBundle/spec/Suite/SuiteNotFoundExceptionSpec.php +++ /dev/null @@ -1,34 +0,0 @@ -beConstructedWith('suite_name'); - } - - function it_is_an_invalid_argument_exception(): void - { - $this->shouldHaveType(\InvalidArgumentException::class); - } - - function it_has_preformatted_message(): void - { - $this->getMessage()->shouldReturn('Suite with name "suite_name" could not be found!'); - } -} diff --git a/src/Sylius/Bundle/FixturesBundle/spec/Suite/SuiteSpec.php b/src/Sylius/Bundle/FixturesBundle/spec/Suite/SuiteSpec.php deleted file mode 100644 index 08404a86c3..0000000000 --- a/src/Sylius/Bundle/FixturesBundle/spec/Suite/SuiteSpec.php +++ /dev/null @@ -1,88 +0,0 @@ -beConstructedWith('suite_name'); - } - - function it_implements_suite_interface(): void - { - $this->shouldImplement(SuiteInterface::class); - } - - function it_has_name(): void - { - $this->getName()->shouldReturn('suite_name'); - } - - function it_has_no_fixtures_by_default(): void - { - $this->getFixtures()->shouldIterateAs([]); - } - - function it_allows_for_adding_a_fixture(FixtureInterface $fixture): void - { - $this->addFixture($fixture, []); - - $this->getFixtures()->shouldHaveKey($fixture); - } - - function it_stores_a_fixture_with_its_options(FixtureInterface $fixture): void - { - $this->addFixture($fixture, ['fixture_option' => 'fixture_name']); - - $this->getFixtures()->shouldHaveKeyWithValue($fixture, ['fixture_option' => 'fixture_name']); - } - - function it_stores_multiple_fixtures_as_queue(FixtureInterface $firstFixture, FixtureInterface $secondFixture): void - { - $this->addFixture($firstFixture, []); - $this->addFixture($secondFixture, []); - - $this->getFixtures()->shouldIterateAs($this->createGenerator($firstFixture, $secondFixture)); - } - - function it_keeps_the_priority_of_fixtures( - FixtureInterface $regularFixture, - FixtureInterface $higherPriorityFixture, - FixtureInterface $lowerPriorityFixture - ): void { - $this->addFixture($regularFixture, []); - $this->addFixture($higherPriorityFixture, [], 10); - $this->addFixture($lowerPriorityFixture, [], -10); - - $this->getFixtures()->shouldIterateAs($this->createGenerator($higherPriorityFixture, $regularFixture, $lowerPriorityFixture)); - } - - /** - * @param Collaborator[] ...$collaborators - * - * @return \Generator - */ - private function createGenerator(Collaborator ...$collaborators): \Generator - { - foreach ($collaborators as $collaborator) { - yield $collaborator->getWrappedObject() => []; - } - } -} diff --git a/src/Sylius/Bundle/FixturesBundle/test/app/AppKernel.php b/src/Sylius/Bundle/FixturesBundle/test/app/AppKernel.php deleted file mode 100644 index 23c236cf9c..0000000000 --- a/src/Sylius/Bundle/FixturesBundle/test/app/AppKernel.php +++ /dev/null @@ -1,60 +0,0 @@ -load(__DIR__ . '/config/config.yml'); - } - - /** - * {@inheritdoc} - */ - protected function getContainerBaseClass() - { - if ('test' === $this->environment) { - return MockerContainer::class; - } - - return parent::getContainerBaseClass(); - } -} diff --git a/src/Sylius/Bundle/FixturesBundle/test/app/autoload.php b/src/Sylius/Bundle/FixturesBundle/test/app/autoload.php deleted file mode 100644 index 3aa013d4ae..0000000000 --- a/src/Sylius/Bundle/FixturesBundle/test/app/autoload.php +++ /dev/null @@ -1,30 +0,0 @@ -run($input); diff --git a/src/Sylius/Bundle/FixturesBundle/test/src/Tests/SyliusFixturesBundleTest.php b/src/Sylius/Bundle/FixturesBundle/test/src/Tests/SyliusFixturesBundleTest.php deleted file mode 100644 index e3f0a39650..0000000000 --- a/src/Sylius/Bundle/FixturesBundle/test/src/Tests/SyliusFixturesBundleTest.php +++ /dev/null @@ -1,39 +0,0 @@ -getContainer(); - - $services = $container->getServiceIds(); - - $services = array_filter($services, function ($serviceId) { - return 0 === strpos($serviceId, 'sylius.'); - }); - - foreach ($services as $id) { - $container->get($id); - } - } -}