Skip to content

Commit

Permalink
Remove testing commands
Browse files Browse the repository at this point in the history
  • Loading branch information
tienvx committed Aug 31, 2019
1 parent 8bc146b commit 93a23fb
Show file tree
Hide file tree
Showing 39 changed files with 177 additions and 504 deletions.
29 changes: 29 additions & 0 deletions src/Annotation/AbstractAnnotation.php
@@ -0,0 +1,29 @@
<?php

namespace Tienvx\Bundle\MbtBundle\Annotation;

abstract class AbstractAnnotation
{
private $name;

public function __construct(array $options)
{
if (isset($options['value'])) {
$options['name'] = $options['value'];
unset($options['value']);
}

foreach ($options as $key => $value) {
if (!property_exists($this, $key)) {
throw new \InvalidArgumentException(sprintf('Property "%s" does not exist', $key));
}

$this->$key = $value;
}
}

public function getName()
{
return $this->name;
}
}
24 changes: 1 addition & 23 deletions src/Annotation/Place.php
Expand Up @@ -9,28 +9,6 @@
* @Annotation
* @Target({"METHOD"})
*/
class Place
class Place extends AbstractAnnotation
{
private $name;

public function __construct(array $options)
{
if (isset($options['value'])) {
$options['name'] = $options['value'];
unset($options['value']);
}

foreach ($options as $key => $value) {
if (!property_exists($this, $key)) {
throw new \InvalidArgumentException(sprintf('Property "%s" does not exist', $key));
}

$this->$key = $value;
}
}

public function getName()
{
return $this->name;
}
}
14 changes: 14 additions & 0 deletions src/Annotation/Subject.php
@@ -0,0 +1,14 @@
<?php

namespace Tienvx\Bundle\MbtBundle\Annotation;

use Doctrine\Common\Annotations\Annotation;
use Doctrine\Common\Annotations\Annotation\Target;

/**
* @Annotation
* @Target({"CLASS"})
*/
class Subject extends AbstractAnnotation
{
}
24 changes: 1 addition & 23 deletions src/Annotation/Transition.php
Expand Up @@ -9,28 +9,6 @@
* @Annotation
* @Target({"METHOD"})
*/
class Transition
class Transition extends AbstractAnnotation
{
private $name;

public function __construct(array $options)
{
if (isset($options['value'])) {
$options['name'] = $options['value'];
unset($options['value']);
}

foreach ($options as $key => $value) {
if (!property_exists($this, $key)) {
throw new \InvalidArgumentException(sprintf('Property "%s" does not exist', $key));
}

$this->$key = $value;
}
}

public function getName()
{
return $this->name;
}
}
6 changes: 3 additions & 3 deletions src/Command/SubjectTrait.php
Expand Up @@ -3,7 +3,7 @@
namespace Tienvx\Bundle\MbtBundle\Command;

use Exception;
use Tienvx\Bundle\MbtBundle\Subject\AbstractSubject;
use Tienvx\Bundle\MbtBundle\Subject\SubjectInterface;
use Tienvx\Bundle\MbtBundle\Subject\SubjectManager;

trait SubjectTrait
Expand All @@ -16,11 +16,11 @@ trait SubjectTrait
/**
* @param string $model
*
* @return AbstractSubject
* @return SubjectInterface
*
* @throws Exception
*/
protected function getSubject(string $model): AbstractSubject
protected function getSubject(string $model): SubjectInterface
{
$subject = $this->subjectManager->createSubject($model);
$subject->setUp();
Expand Down
91 changes: 0 additions & 91 deletions src/Command/TestModelCommand.php

This file was deleted.

103 changes: 0 additions & 103 deletions src/Command/TestSubjectCommand.php

This file was deleted.

10 changes: 6 additions & 4 deletions src/DependencyInjection/Compiler/GeneratorPass.php
Expand Up @@ -9,13 +9,15 @@

class GeneratorPass implements CompilerPassInterface
{
use TaggedServiceTrait;
use PluginTrait;

private $generatorService;
private $generatorTag;

public function __construct(string $generatorService = 'mbt.generator_manager', string $generatorTag = 'mbt.generator')
{
public function __construct(
string $generatorService = 'mbt.generator_manager',
string $generatorTag = 'mbt.generator'
) {
$this->generatorService = $generatorService;
$this->generatorTag = $generatorTag;
}
Expand All @@ -31,7 +33,7 @@ public function process(ContainerBuilder $container)
return;
}

if (!$generators = $this->findTaggedServices($container, $this->generatorTag)) {
if (!$generators = $this->findPlugins($container, $this->generatorTag)) {
throw new RuntimeException(sprintf('You must tag at least one service as "%s" to use the "%s" service.', $this->generatorTag, $this->generatorService));
}

Expand Down
Expand Up @@ -7,18 +7,17 @@
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Reference;

trait TaggedServiceTrait
trait PluginTrait
{
/**
* @param ContainerBuilder $container
* @param string $tagName
* @param bool $reference
*
* @return array
*
* @throws Exception
*/
private function findTaggedServices(ContainerBuilder $container, string $tagName, bool $reference = true)
private function findPlugins(ContainerBuilder $container, string $tagName)
{
$services = [];
foreach ($container->findTaggedServiceIds($tagName, true) as $serviceId => $attributes) {
Expand All @@ -38,7 +37,7 @@ private function findTaggedServices(ContainerBuilder $container, string $tagName
$support = call_user_func([$class, 'support']);
if ($support) {
$serviceName = call_user_func([$class, 'getName']);
$services[$serviceName] = $reference ? (new Reference($serviceId)) : $class;
$services[$serviceName] = new Reference($serviceId);
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/DependencyInjection/Compiler/ReducerPass.php
Expand Up @@ -9,7 +9,7 @@

class ReducerPass implements CompilerPassInterface
{
use TaggedServiceTrait;
use PluginTrait;

private $reducerService;
private $reducerTag;
Expand All @@ -33,7 +33,7 @@ public function process(ContainerBuilder $container)
return;
}

if (!$reducers = $this->findTaggedServices($container, $this->reducerTag)) {
if (!$reducers = $this->findPlugins($container, $this->reducerTag)) {
throw new RuntimeException(sprintf('You must tag at least one service as "%s" to use the "%s" service.', $this->reducerTag, $this->reducerService));
}

Expand Down

0 comments on commit 93a23fb

Please sign in to comment.