Skip to content
This repository has been archived by the owner on Dec 21, 2023. It is now read-only.

Feature/symfony 5 #218

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion .atoum.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

use \mageekguy\atoum;
use \atoum\atoum;

$script->bootstrapFile(__DIR__ . DIRECTORY_SEPARATOR . '.atoum.bootstrap.php');

Expand Down
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
language: php

php:
- 7.1
- 7.2
- 7.3
- 8.0

install: composer install -n

script:
- bin/atoum
- bin/atoum -ncc

notifications:
email:
Expand Down
35 changes: 26 additions & 9 deletions Command/DeployActionCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,23 @@

namespace Spy\TimelineBundle\Command;

use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Exception;
use InvalidArgumentException;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
* This command will deploy each actions (see limit option) which
* has PUBLISHED on status_wanted.
*/
class DeployActionCommand extends ContainerAwareCommand
class DeployActionCommand extends Command implements ContainerAwareInterface
{
private $container;

/**
* {@inheritdoc}
*/
Expand All @@ -28,37 +34,48 @@ protected function configure()
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output):int
{
$limit = (int) $input->getOption('limit');

if ($limit < 1) {
throw new \InvalidArgumentException('Limit defined should be biggest than 0 ...');
throw new InvalidArgumentException('Limit defined should be biggest than 0 ...');
}

$container = $this->getContainer();
$actionManager = $container->get('spy_timeline.action_manager');
$actionManager = $this->container->get('spy_timeline.action_manager');
$results = $actionManager->findActionsWithStatusWantedPublished($limit);

$output->writeln(sprintf('<info>There is %s action(s) to deploy</info>', count($results)));

$deployer = $container->get('spy_timeline.spread.deployer');
$deployer = $this->container->get('spy_timeline.spread.deployer');

foreach ($results as $action) {
try {
$deployer->deploy($action, $actionManager);
$output->writeln(sprintf('<comment>Deploy action %s</comment>', $action->getId()));
} catch (\Exception $e) {
} catch (Exception $e) {
$message = sprintf('[TIMELINE] Error during deploy action %s', $action->getId());
if (OutputInterface::VERBOSITY_VERBOSE <= $output->getVerbosity()) {
$message .= sprintf('%s: %s', $message, $e->getMessage());
}

$container->get('logger')->crit($message);
$this->container->get('logger')->crit($message);
$output->writeln(sprintf('<error>%s</error>', $message));
}
}

$output->writeln('<info>Done</info>');

return 0;
}

/**
* @param ContainerInterface|null $container
*
* @return void
*/
public function setContainer(?ContainerInterface $container): void
{
$this->container = $container;
}
}
22 changes: 16 additions & 6 deletions Command/SpreadListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,19 @@

namespace Spy\TimelineBundle\Command;

use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;

/**
* This command will show all services which are defined as spread.
*/
class SpreadListCommand extends ContainerAwareCommand
class SpreadListCommand extends Command implements ContainerAwareInterface
{
private $container;

/**
* {@inheritdoc}
*/
Expand All @@ -25,17 +29,23 @@ protected function configure()
/**
* {@inheritdoc}
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$spreads = $this->getContainer()
$spreads = $this->container
->get('spy_timeline.spread.deployer')
->getSpreads()
;
->getSpreads();

$output->writeln(sprintf('<info>There is %s timeline spread(s) defined</info>', count($spreads)));

foreach ($spreads as $spread) {
$output->writeln(sprintf('<comment>- %s</comment>', get_class($spread)));
}

return 0;
}

public function setContainer(?ContainerInterface $container)
{
$this->container = $container;
}
}
4 changes: 2 additions & 2 deletions DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class Configuration implements ConfigurationInterface
*/
public function getConfigTreeBuilder()
{
$tb = new TreeBuilder();
$rootNode = $tb->root('spy_timeline');
$tb = new TreeBuilder("spy_timeline");
$rootNode = $tb->getRootNode();

$this->addDriverSection($rootNode);
$this->addQueryBuilderSection($rootNode);
Expand Down
2 changes: 1 addition & 1 deletion Driver/Doctrine/AbstractActionManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Spy\TimelineBundle\Driver\Doctrine;

use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\Persistence\ObjectManager;
use Spy\Timeline\Model\ActionInterface;
use Spy\Timeline\ResultBuilder\ResultBuilderInterface;
use Spy\Timeline\Driver\AbstractActionManager as BaseActionManager;
Expand Down
8 changes: 4 additions & 4 deletions Driver/Doctrine/AbstractTimelineManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Spy\TimelineBundle\Driver\Doctrine;

use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\ORM\EntityManager;
use Spy\Timeline\Model\ActionInterface;
use Spy\Timeline\Model\ComponentInterface;
use Spy\Timeline\Model\TimelineInterface;
Expand All @@ -11,7 +11,7 @@
class AbstractTimelineManager
{
/**
* @var ObjectManager
* @var EntityManager
*/
protected $objectManager;

Expand All @@ -26,11 +26,11 @@ class AbstractTimelineManager
protected $timelineClass;

/**
* @param ObjectManager $objectManager objectManager
* @param EntityManager $objectManager objectManager
* @param ResultBuilderInterface $resultBuilder resultBuilder
* @param string $timelineClass timelineClass
*/
public function __construct(ObjectManager $objectManager, ResultBuilderInterface $resultBuilder, $timelineClass)
public function __construct(EntityManager $objectManager, ResultBuilderInterface $resultBuilder, $timelineClass)
{
$this->objectManager = $objectManager;
$this->resultBuilder = $resultBuilder;
Expand Down
2 changes: 1 addition & 1 deletion Driver/Doctrine/ODM/PostLoadListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Spy\TimelineBundle\Driver\Doctrine\ODM;

use Doctrine\Common\EventSubscriber;
use Doctrine\Common\Persistence\Mapping\MappingException;
use Doctrine\Persistence\Mapping\MappingException;
use Doctrine\ODM\MongoDB\Event\LifecycleEventArgs;
use Doctrine\ODM\MongoDB\DocumentNotFoundException;
use Spy\Timeline\Model\ComponentInterface;
Expand Down
2 changes: 1 addition & 1 deletion Driver/Doctrine/ORM/PostLoadListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Spy\TimelineBundle\Driver\Doctrine\ORM;

use Doctrine\Common\EventSubscriber;
use Doctrine\Common\Persistence\Mapping\MappingException;
use Doctrine\Persistence\Mapping\MappingException;
use Doctrine\ORM\Event\LifecycleEventArgs;
use Doctrine\ORM\EntityNotFoundException;
use Spy\Timeline\Model\ComponentInterface;
Expand Down
2 changes: 1 addition & 1 deletion Driver/ORM/QueryBuilder/QueryBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
use Spy\Timeline\Driver\QueryBuilder\QueryBuilderFactory;
use Spy\Timeline\Driver\QueryBuilder\Criteria\Asserter;
use Spy\Timeline\Driver\QueryBuilder\Criteria\Operator;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\Persistence\ObjectManager;
use Spy\Timeline\ResultBuilder\ResultBuilderInterface;
use Spy\TimelineBundle\Driver\ORM\QueryBuilder\Criteria\CriteriaCollection;

Expand Down
4 changes: 2 additions & 2 deletions Filter/DataHydrator/Locator/DoctrineODM.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
namespace Spy\TimelineBundle\Filter\DataHydrator\Locator;

use Spy\Timeline\Filter\DataHydrator\Locator\LocatorInterface;
use Doctrine\Common\Persistence\ManagerRegistry;
use Doctrine\Persistence\ManagerRegistry;

class DoctrineODM implements LocatorInterface
{
Expand All @@ -13,7 +13,7 @@ class DoctrineODM implements LocatorInterface
protected $registry;

/**
* @param ManagerRegistry $registry registry
* @param ManagerRegistry|null $registry registry
*/
public function __construct(ManagerRegistry $registry = null)
{
Expand Down
4 changes: 2 additions & 2 deletions Filter/DataHydrator/Locator/DoctrineORM.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

use Doctrine\ORM\QueryBuilder;
use Spy\Timeline\Filter\DataHydrator\Locator\LocatorInterface;
use Doctrine\Common\Persistence\ManagerRegistry;
use Doctrine\Common\Persistence\ObjectManager;
use Doctrine\Persistence\ManagerRegistry;
use Doctrine\Persistence\ObjectManager;

class DoctrineORM implements LocatorInterface
{
Expand Down
7 changes: 4 additions & 3 deletions ResolveComponent/DoctrineComponentDataResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

namespace Spy\TimelineBundle\ResolveComponent;

use Doctrine\Persistence\ManagerRegistry;
use Doctrine\Persistence\Mapping\ClassMetadata;
use Spy\Timeline\ResolveComponent\ValueObject\ResolvedComponentData;
use Spy\Timeline\Exception\ResolveComponentDataException;
use Spy\Timeline\ResolveComponent\ComponentDataResolverInterface;
use Doctrine\Common\Persistence\ManagerRegistry;
use Spy\Timeline\ResolveComponent\ValueObject\ResolveComponentModelIdentifier;

/**
Expand Down Expand Up @@ -92,7 +93,7 @@ public function addRegistry(ManagerRegistry $manager)
/**
* @param string $class
*
* @return \Doctrine\Common\Persistence\Mapping\ClassMetadata|null
* @return ClassMetadata|null
*/
protected function getClassMetadata($class)
{
Expand All @@ -102,6 +103,6 @@ protected function getClassMetadata($class)
}
}

return;
return null;
}
}
2 changes: 1 addition & 1 deletion Tests/Units/Command/DeployActionCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Spy\TimelineBundle\Command\DeployActionCommand as TestedCommand;
use Symfony\Component\Console\Application;
use Symfony\Component\Console\Tester\CommandTester;
use mageekguy\atoum;
use atoum\atoum;

class DeployActionCommand extends atoum\test
{
Expand Down
2 changes: 1 addition & 1 deletion Tests/Units/Command/SpreadListCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Spy\TimelineBundle\Tests\Units\Command;

use mageekguy\atoum;
use atoum\atoum;
use Spy\TimelineBundle\Command\SpreadListCommand as TestedCommand;
use Symfony\Component\Console\Tester\CommandTester;
use Symfony\Component\Console\Application;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Spy\TimelineBundle\Tests\Units\DependencyInjection\Compiler;

use mageekguy\atoum;
use atoum\atoum;
use Spy\TimelineBundle\DependencyInjection\Compiler\AddLocatorCompilerPass as TestedModel;

class AddLocatorCompilerPass extends atoum\test
Expand Down Expand Up @@ -38,6 +38,9 @@ public function testProcess()
->and($this->calling($containerBuilder)->findTaggedServiceIds = function () use ($taggedServicesResult) {
return $taggedServicesResult;
})
->and($this->calling($definition)->addMethodCall = function () use ($definition) {
return $definition;
})
->and($compiler = new TestedModel())
->when($compiler->process($containerBuilder))
->then(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

namespace Spy\TimelineBundle\Tests\Units\DependencyInjection\Compiler;

use mageekguy\atoum;
use atoum\atoum;
use Spy\TimelineBundle\DependencyInjection\Compiler\AddSpreadCompilerPass as TestedModel;
use Symfony\Component\DependencyInjection\Alias;

class AddSpreadCompilerPass extends atoum\test
{
Expand All @@ -17,7 +18,8 @@ public function testProcess()
->and($this->mockGenerator->orphanize('__construct'))
->and($this->mockGenerator->shuntParentClassCalls())
->and($definition = new \mock\Symfony\Component\DependencyInjection\Definition())
->and($this->calling($containerBuilder)->getAlias = function ($alias) {
->and($alias = new Alias(1, false))
->and($this->calling($containerBuilder)->getAlias = function () use ($alias) {
return $alias;
})
->and($this->calling($containerBuilder)->getDefinition = function () use ($definition) {
Expand All @@ -26,6 +28,9 @@ public function testProcess()
->and($this->calling($containerBuilder)->findTaggedServiceIds = function () use ($taggedServicesResult) {
return $taggedServicesResult;
})
->and($this->calling($definition)->addMethodCall = function () use ($definition) {
return $definition;
})
->and($compiler = new TestedModel())
->when($compiler->process($containerBuilder))
->then(
Expand Down
4 changes: 2 additions & 2 deletions Tests/Units/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Spy\TimelineBundle\Tests\Units\DependencyInjection;

use mageekguy\atoum;
use atoum\atoum;
use Spy\TimelineBundle\DependencyInjection\Configuration as ConfigurationTested;
use Symfony\Component\Config\Definition\Processor;

Expand Down Expand Up @@ -43,7 +43,7 @@ public function testMultipleDrivers()
})
->isInstanceOf('\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException')
->hasMessage('Invalid configuration for path "spy_timeline.drivers": Please define only one driver.')
;
;
}

public function processConfiguration($config)
Expand Down
Loading