diff --git a/README.md b/README.md
index 898aaf9..bc33259 100644
--- a/README.md
+++ b/README.md
@@ -6,10 +6,6 @@ Yokai Sonata Workflow
[![Total Downloads](https://poser.pugx.org/yokai/sonata-workflow/downloads)](https://packagist.org/packages/yokai/sonata-workflow)
[![License](https://poser.pugx.org/yokai/sonata-workflow/license)](https://packagist.org/packages/yokai/sonata-workflow)
-[![Build Status](https://api.travis-ci.org/yokai-php/sonata-workflow.png?branch=master)](https://travis-ci.org/yokai-php/sonata-workflow)
-[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/yokai-php/sonata-workflow/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/yokai-php/sonata-workflow/?branch=master)
-[![Code Coverage](https://scrutinizer-ci.com/g/yokai-php/sonata-workflow/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/yokai-php/sonata-workflow/?branch=master)
-
Introduction
------------
@@ -44,38 +40,6 @@ Configuration
Let say that you have an entity named `PullRequest` that is under workflow and for which you have an admin.
-#### symfony/workflow <4.3
-```yaml
-# config/packages/workflow.yml
-framework:
- workflows:
- pull_request:
- type: state_machine
- marking_store:
- type: single_state
- arguments:
- - status
- supports:
- - App\Entity\PullRequest
- places:
- - opened
- - pending_review
- - merged
- - closed
- initial_place: opened
- transitions:
- start_review:
- from: opened
- to: pending_review
- merge:
- from: pending_review
- to: merged
- close:
- from: pending_review
- to: closed
-```
-
-#### symfony/workflow ^4.3|^5.0
```yaml
# config/packages/workflow.yml
framework:
@@ -224,18 +188,21 @@ services:
createForm(
StartReviewType::class,
diff --git a/composer.json b/composer.json
index fb64114..ac5b4b8 100644
--- a/composer.json
+++ b/composer.json
@@ -25,12 +25,12 @@
}
},
"require": {
- "php": "^5.6|^7.0",
+ "php": "^7.1",
"sonata-project/admin-bundle": "^3.0",
- "symfony/workflow": "^3.2|^4.0|^5.0"
+ "symfony/workflow": "^4.4|^5.0"
},
"require-dev": {
- "phpunit/phpunit": "^5.0",
+ "phpunit/phpunit": "^7.5",
"squizlabs/php_codesniffer": "^3.5"
},
"minimum-stability": "stable",
diff --git a/phpcs.xml.dist b/phpcs.xml.dist
index 3d26c56..b25a8a1 100644
--- a/phpcs.xml.dist
+++ b/phpcs.xml.dist
@@ -11,6 +11,7 @@
src/
+ tests/
diff --git a/phpunit.xml.dist b/phpunit.xml.dist
index 0c1c221..9f8bda0 100644
--- a/phpunit.xml.dist
+++ b/phpunit.xml.dist
@@ -7,7 +7,6 @@
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
- syntaxCheck="false"
colors="true"
bootstrap="vendor/autoload.php"
>
diff --git a/src/Admin/Extension/WorkflowExtension.php b/src/Admin/Extension/WorkflowExtension.php
index 67831ac..b037588 100644
--- a/src/Admin/Extension/WorkflowExtension.php
+++ b/src/Admin/Extension/WorkflowExtension.php
@@ -1,5 +1,7 @@
add(
'workflow_apply_transition',
@@ -53,7 +55,7 @@ public function configureRoutes(AdminInterface $admin, RouteCollection $collecti
/**
* @inheritdoc
*/
- public function alterNewInstance(AdminInterface $admin, $object)
+ public function alterNewInstance(AdminInterface $admin, $object): void
{
try {
$workflow = $this->getWorkflow($object, $this->options['workflow_name']);
@@ -72,7 +74,7 @@ public function configureSideMenu(
MenuItemInterface $menu,
$action,
AdminInterface $childAdmin = null
- ) {
+ ): void {
if (null !== $childAdmin || !in_array($action, $this->options['render_actions'], true)) {
return;
}
@@ -100,7 +102,7 @@ public function configureSideMenu(
/**
* @inheritdoc
*/
- public function getAccessMapping(AdminInterface $admin)
+ public function getAccessMapping(AdminInterface $admin): array
{
return [
'viewTransitions' => $this->options['view_transitions_role'],
@@ -115,7 +117,7 @@ public function getAccessMapping(AdminInterface $admin)
* @return Workflow
* @throws InvalidArgumentException
*/
- protected function getWorkflow($subject, $workflowName = null)
+ protected function getWorkflow($subject, string $workflowName = null): Workflow
{
return $this->registry->get($subject, $workflowName);
}
@@ -123,7 +125,7 @@ protected function getWorkflow($subject, $workflowName = null)
/**
* @param OptionsResolver $resolver
*/
- protected function configureOptions(OptionsResolver $resolver)
+ protected function configureOptions(OptionsResolver $resolver): void
{
$resolver
->setDefaults([
@@ -157,7 +159,7 @@ protected function configureOptions(OptionsResolver $resolver)
* @param MenuItemInterface $menu
* @param AdminInterface $admin
*/
- protected function noTransitions(MenuItemInterface $menu, AdminInterface $admin)
+ protected function noTransitions(MenuItemInterface $menu, AdminInterface $admin): void
{
if ($this->options['no_transition_display']) {
$menu->addChild($this->options['no_transition_label'], [
@@ -173,13 +175,17 @@ protected function noTransitions(MenuItemInterface $menu, AdminInterface $admin)
}
/**
- * @param MenuItemInterface $menu
- * @param AdminInterface $admin
- * @param Transition[] $transitions
- * @param object $subject
+ * @param MenuItemInterface $menu
+ * @param AdminInterface $admin
+ * @param iterable|Transition[] $transitions
+ * @param object $subject
*/
- protected function transitionsDropdown(MenuItemInterface $menu, AdminInterface $admin, $transitions, $subject)
- {
+ protected function transitionsDropdown(
+ MenuItemInterface $menu,
+ AdminInterface $admin,
+ iterable $transitions,
+ $subject
+ ): void {
$workflowMenu = $menu->addChild($this->options['dropdown_transitions_label'], [
'attributes' => [
'dropdown' => true,
@@ -201,8 +207,12 @@ protected function transitionsDropdown(MenuItemInterface $menu, AdminInterface $
* @param Transition $transition
* @param object $subject
*/
- protected function transitionsItem(MenuItemInterface $menu, AdminInterface $admin, Transition $transition, $subject)
- {
+ protected function transitionsItem(
+ MenuItemInterface $menu,
+ AdminInterface $admin,
+ Transition $transition,
+ $subject
+ ): void {
$options = [
'attributes' => [],
'extras' => [
@@ -229,7 +239,7 @@ protected function transitionsItem(MenuItemInterface $menu, AdminInterface $admi
*
* @return string|null
*/
- protected function getTransitionIcon(Transition $transition)
+ protected function getTransitionIcon(Transition $transition): ?string
{
if (isset($this->options['transitions_icons'][$transition->getName()])) {
return $this->options['transitions_icons'][$transition->getName()];
@@ -245,7 +255,7 @@ protected function getTransitionIcon(Transition $transition)
*
* @return string
*/
- protected function generateTransitionUri(AdminInterface $admin, Transition $transition, $subject)
+ protected function generateTransitionUri(AdminInterface $admin, Transition $transition, $subject): string
{
return $admin->generateObjectUrl(
'workflow_apply_transition',
@@ -260,7 +270,7 @@ protected function generateTransitionUri(AdminInterface $admin, Transition $tran
*
* @return bool
*/
- protected function isGrantedView(AdminInterface $admin, $subject)
+ protected function isGrantedView(AdminInterface $admin, $subject): bool
{
try {
$admin->checkAccess('viewTransitions', $subject);
@@ -277,7 +287,7 @@ protected function isGrantedView(AdminInterface $admin, $subject)
*
* @return bool
*/
- protected function isGrantedApply(AdminInterface $admin, $subject)
+ protected function isGrantedApply(AdminInterface $admin, $subject): bool
{
try {
$admin->checkAccess('applyTransitions', $subject);
diff --git a/src/Controller/WorkflowController.php b/src/Controller/WorkflowController.php
index 35406c7..936101f 100644
--- a/src/Controller/WorkflowController.php
+++ b/src/Controller/WorkflowController.php
@@ -1,5 +1,7 @@
workflowRegistry = $workflowRegistry;
}
@@ -53,7 +55,7 @@ public function setWorkflowRegistry(Registry $workflowRegistry)
*
* @return Response
*/
- public function workflowApplyTransitionAction(Request $request)
+ public function workflowApplyTransitionAction(Request $request): Response
{
$id = $request->get($this->admin->getIdParameter());
@@ -153,7 +155,7 @@ public function workflowApplyTransitionAction(Request $request)
* @return Workflow
* @throws InvalidArgumentException
*/
- protected function getWorkflow($object)
+ protected function getWorkflow($object): Workflow
{
$registry = $this->workflowRegistry;
if ($registry === null) {
@@ -183,7 +185,7 @@ protected function getWorkflow($object)
*
* @return null|Response
*/
- protected function preApplyTransition($object, $transition)
+ protected function preApplyTransition($object, string $transition): ?Response
{
return null;
}
diff --git a/tests/Admin/Extension/WorkflowExtensionTest.php b/tests/Admin/Extension/WorkflowExtensionTest.php
index 3cd173a..f77b931 100644
--- a/tests/Admin/Extension/WorkflowExtensionTest.php
+++ b/tests/Admin/Extension/WorkflowExtensionTest.php
@@ -1,9 +1,13 @@
*/
-class WorkflowExtensionTest extends \PHPUnit_Framework_TestCase
+class WorkflowExtensionTest extends TestCase
{
- public function testConfigureRoutes()
+ public function testConfigureRoutes(): void
{
/** @var AdminInterface|ObjectProphecy $admin */
$admin = $this->prophesize(AdminInterface::class);
@@ -43,7 +46,7 @@ public function testConfigureRoutes()
self::assertSame('pull_request', $defaults['_sonata_admin']);
}
- public function testAlterNewInstanceWithoutWorkflow()
+ public function testAlterNewInstanceWithoutWorkflow(): void
{
/** @var AdminInterface|ObjectProphecy $admin */
$admin = $this->prophesize(AdminInterface::class);
@@ -54,13 +57,13 @@ public function testAlterNewInstanceWithoutWorkflow()
self::assertNull($pullRequest->getMarking());
}
- public function testAlterNewInstance()
+ public function testAlterNewInstance(): void
{
/** @var AdminInterface|ObjectProphecy $admin */
$admin = $this->prophesize(AdminInterface::class);
- $registry = new LegacyWorkflowRegistry();
- $registry->add(
+ $registry = new Registry();
+ $registry->addWorkflow(
new StateMachine(PullRequest::createWorkflowDefinition()),
PullRequest::createSupportStrategy()
);
@@ -71,7 +74,7 @@ public function testAlterNewInstance()
self::assertSame('opened', $pullRequest->getMarking());
}
- public function testAccessMapping()
+ public function testAccessMapping(): void
{
/** @var AdminInterface|ObjectProphecy $admin */
$admin = $this->prophesize(AdminInterface::class);
@@ -83,7 +86,7 @@ public function testAccessMapping()
);
}
- public function testConfigureSideMenuWithoutSubject()
+ public function testConfigureSideMenuWithoutSubject(): void
{
/** @var AdminInterface|ObjectProphecy $admin */
$admin = $this->prophesize(AdminInterface::class);
@@ -95,7 +98,7 @@ public function testConfigureSideMenuWithoutSubject()
self::assertFalse($menu->hasChildren());
}
- public function testConfigureSideMenuWithoutPermission()
+ public function testConfigureSideMenuWithoutPermission(): void
{
/** @var AdminInterface|ObjectProphecy $admin */
$admin = $this->prophesize(AdminInterface::class);
@@ -108,7 +111,7 @@ public function testConfigureSideMenuWithoutPermission()
self::assertFalse($menu->hasChildren());
}
- public function testConfigureSideMenuWithoutWorkflow()
+ public function testConfigureSideMenuWithoutWorkflow(): void
{
/** @var AdminInterface|ObjectProphecy $admin */
$admin = $this->prophesize(AdminInterface::class);
@@ -124,7 +127,7 @@ public function testConfigureSideMenuWithoutWorkflow()
/**
* @dataProvider markingToTransition
*/
- public function testConfigureSideMenu($marking, array $transitions, $grantedApply)
+ public function testConfigureSideMenu(string $marking, array $transitions, bool $grantedApply): void
{
$pullRequest = new PullRequest();
$pullRequest->setMarking($marking);
@@ -147,19 +150,19 @@ public function testConfigureSideMenu($marking, array $transitions, $grantedAppl
foreach ($transitions as $transition) {
$labelStrategy->getLabel($transition, 'workflow', 'transition')
->shouldBeCalledTimes(1)
- ->willReturn('workflow.transition.'.$transition);
+ ->willReturn('workflow.transition.' . $transition);
if ($grantedApply) {
$admin->generateObjectUrl('workflow_apply_transition', $pullRequest, ['transition' => $transition])
->shouldBeCalledTimes(1)
- ->willReturn('/pull-request/42/workflow/transition/'.$transition.'/apply');
+ ->willReturn('/pull-request/42/workflow/transition/' . $transition . '/apply');
} else {
$admin->generateObjectUrl('workflow_apply_transition', $pullRequest, ['transition' => $transition])
->shouldNotBeCalled();
}
}
- $registry = new LegacyWorkflowRegistry();
- $registry->add(
+ $registry = new Registry();
+ $registry->addWorkflow(
new StateMachine(PullRequest::createWorkflowDefinition()),
PullRequest::createSupportStrategy()
);
@@ -192,9 +195,9 @@ public function testConfigureSideMenu($marking, array $transitions, $grantedAppl
$icon = 'fa fa-times';
}
- self::assertNotNull($item = $child->getChild('workflow.transition.'.$transition));
+ self::assertNotNull($item = $child->getChild('workflow.transition.' . $transition));
if ($grantedApply) {
- self::assertSame('/pull-request/42/workflow/transition/'.$transition.'/apply', $item->getUri());
+ self::assertSame('/pull-request/42/workflow/transition/' . $transition . '/apply', $item->getUri());
} else {
self::assertNull($item->getUri());
}
@@ -204,14 +207,14 @@ public function testConfigureSideMenu($marking, array $transitions, $grantedAppl
}
}
- public function markingToTransition()
+ public function markingToTransition(): Generator
{
foreach ([true, false] as $grantedApply) {
$grantedApplyStr = $grantedApply ? 'with links' : 'without links';
- yield 'opened '.$grantedApplyStr => ['opened', ['start_review'], $grantedApply];
- yield 'pending_review '.$grantedApplyStr => ['pending_review', ['merge', 'close'], $grantedApply];
- yield 'closed '.$grantedApplyStr => ['closed', [], $grantedApply];
+ yield 'opened ' . $grantedApplyStr => ['opened', ['start_review'], $grantedApply];
+ yield 'pending_review ' . $grantedApplyStr => ['pending_review', ['merge', 'close'], $grantedApply];
+ yield 'closed ' . $grantedApplyStr => ['closed', [], $grantedApply];
}
}
}
diff --git a/tests/Controller/WorkflowControllerTest.php b/tests/Controller/WorkflowControllerTest.php
index 0219bde..a5a9a38 100644
--- a/tests/Controller/WorkflowControllerTest.php
+++ b/tests/Controller/WorkflowControllerTest.php
@@ -1,7 +1,10 @@
*/
-class WorkflowControllerTest extends \PHPUnit_Framework_TestCase
+class WorkflowControllerTest extends TestCase
{
/**
* @var ContainerInterface|ObjectProphecy
@@ -55,18 +59,13 @@ class WorkflowControllerTest extends \PHPUnit_Framework_TestCase
*/
private $flashBag;
- /**
- * @var StubTranslator
- */
- private $translator;
-
public function setUp()
{
$this->container = $this->prophesize(ContainerInterface::class);
$this->admin = $this->prophesize(AdminInterface::class);
- $this->registry = new LegacyWorkflowRegistry();
+ $this->registry = new Registry();
$this->flashBag = new FlashBag();
- $this->translator = new StubTranslator();
+ $translator = new StubTranslator();
$stack = new RequestStack();
$stack->push($this->request = new Request());
@@ -83,10 +82,12 @@ public function setUp()
$this->container->get('workflow.registry')->willReturn($this->registry);
$this->container->get('kernel')->willReturn(new TestKernel());
$this->container->has('session')->willReturn(true);
- $this->container->get('session')->willReturn(new Session(new MockArraySessionStorage(), null, $this->flashBag));
- $this->container->get('translator')->willReturn($this->translator);
+ $this->container->get('session')
+ ->willReturn(new Session(new MockArraySessionStorage(), null, $this->flashBag));
+ $this->container->get('translator')->willReturn($translator);
$this->container->has('logger')->willReturn(false);
- $this->container->get('admin.pull_request.template_registry')->willReturn($this->prophesize(TemplateRegistryInterface::class)->reveal());
+ $this->container->get('admin.pull_request.template_registry')
+ ->willReturn($this->prophesize(TemplateRegistryInterface::class)->reveal());
$this->admin->isChild()->willReturn(false);
$this->admin->setRequest($this->request)->willReturn(null);
@@ -94,34 +95,22 @@ public function setUp()
$this->admin->getCode()->willReturn('admin.pull_request');
}
- public function tearDown()
+ public function testWorkflowApplyTransitionActionObjectNotFound(): void
{
- $this->container =
- $this->request =
- $this->admin =
- $this->registry =
- $this->flashBag =
- $this->translator = null;
- }
+ $this->expectException(NotFoundHttpException::class);
+ $this->expectExceptionMessage('unable to find the object with id: 42');
- /**
- * @expectedException \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
- * @expectedExceptionMessage unable to find the object with id: 42
- */
- public function testWorkflowApplyTransitionActionObjectNotFound()
- {
$this->admin->getObject(42)->shouldBeCalledTimes(1)
->willReturn(null);
$this->controller()->workflowApplyTransitionAction($this->request);
}
- /**
- * @expectedException \Symfony\Component\HttpKernel\Exception\NotFoundHttpException
- * @expectedExceptionMessage Not found
- */
- public function testWorkflowApplyTransitionActionWorkflowNotFound()
+ public function testWorkflowApplyTransitionActionWorkflowNotFound(): void
{
+ $this->expectException(NotFoundHttpException::class);
+ $this->expectExceptionMessage('Not found');
+
$this->admin->getObject(42)->shouldBeCalledTimes(1)
->willReturn($subject = new PullRequest());
$this->admin->setSubject($subject)->shouldBeCalledTimes(1);
@@ -131,13 +120,12 @@ public function testWorkflowApplyTransitionActionWorkflowNotFound()
$this->controller()->workflowApplyTransitionAction($this->request);
}
- /**
- * @expectedException \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
- * @expectedExceptionMessage missing transition to apply
- */
- public function testWorkflowApplyTransitionActionMissingTransition()
+ public function testWorkflowApplyTransitionActionMissingTransition(): void
{
- $this->registry->add(
+ $this->expectException(BadRequestHttpException::class);
+ $this->expectExceptionMessage('missing transition to apply');
+
+ $this->registry->addWorkflow(
new StateMachine(PullRequest::createWorkflowDefinition()),
PullRequest::createSupportStrategy()
);
@@ -151,13 +139,12 @@ public function testWorkflowApplyTransitionActionMissingTransition()
$this->controller()->workflowApplyTransitionAction($this->request);
}
- /**
- * @expectedException \Symfony\Component\HttpKernel\Exception\BadRequestHttpException
- * @expectedExceptionMessage transition transition_that_do_not_exists could not be applied to object pr42
- */
- public function testWorkflowApplyTransitionActionTransitionException()
+ public function testWorkflowApplyTransitionActionTransitionException(): void
{
- $this->registry->add(
+ $this->expectException(BadRequestHttpException::class);
+ $this->expectExceptionMessage('transition transition_that_do_not_exists could not be applied to object pr42');
+
+ $this->registry->addWorkflow(
new StateMachine(PullRequest::createWorkflowDefinition()),
PullRequest::createSupportStrategy()
);
@@ -174,13 +161,12 @@ public function testWorkflowApplyTransitionActionTransitionException()
$this->controller()->workflowApplyTransitionAction($this->request);
}
- /**
- * @expectedException \Sonata\AdminBundle\Exception\ModelManagerException
- * @expectedExceptionMessage phpunit error
- */
- public function testWorkflowApplyTransitionActionModelManagerException()
+ public function testWorkflowApplyTransitionActionModelManagerException(): void
{
- $this->registry->add(
+ $this->expectException(ModelManagerException::class);
+ $this->expectExceptionMessage('phpunit error');
+
+ $this->registry->addWorkflow(
new StateMachine(PullRequest::createWorkflowDefinition()),
PullRequest::createSupportStrategy()
);
@@ -199,9 +185,9 @@ public function testWorkflowApplyTransitionActionModelManagerException()
$this->controller()->workflowApplyTransitionAction($this->request);
}
- public function testWorkflowApplyTransitionActionLockException()
+ public function testWorkflowApplyTransitionActionLockException(): void
{
- $this->registry->add(
+ $this->registry->addWorkflow(
new StateMachine(PullRequest::createWorkflowDefinition()),
PullRequest::createSupportStrategy()
);
@@ -235,9 +221,9 @@ public function testWorkflowApplyTransitionActionLockException()
self::assertSame('[trans]flash_lock_error[/trans]', $errors[0]);
}
- public function testWorkflowApplyTransitionActionSuccessXmlHttp()
+ public function testWorkflowApplyTransitionActionSuccessXmlHttp(): void
{
- $this->registry->add(
+ $this->registry->addWorkflow(
new StateMachine(PullRequest::createWorkflowDefinition()),
PullRequest::createSupportStrategy()
);
@@ -264,9 +250,9 @@ public function testWorkflowApplyTransitionActionSuccessXmlHttp()
self::assertCount(0, $errors);
}
- public function testWorkflowApplyTransitionActionSuccessHttp()
+ public function testWorkflowApplyTransitionActionSuccessHttp(): void
{
- $this->registry->add(
+ $this->registry->addWorkflow(
new StateMachine(PullRequest::createWorkflowDefinition()),
PullRequest::createSupportStrategy()
);
@@ -300,9 +286,9 @@ public function testWorkflowApplyTransitionActionSuccessHttp()
self::assertSame('[trans]flash_edit_success[/trans]', $successes[0]);
}
- public function testWorkflowApplyTransitionActionPreApply()
+ public function testWorkflowApplyTransitionActionPreApply(): void
{
- $this->registry->add(
+ $this->registry->addWorkflow(
new StateMachine(PullRequest::createWorkflowDefinition()),
PullRequest::createSupportStrategy()
);
@@ -330,7 +316,7 @@ public function testWorkflowApplyTransitionActionPreApply()
self::assertCount(0, $successes);
}
- private function controller()
+ private function controller(): PullRequestWorkflowController
{
$controller = new PullRequestWorkflowController();
diff --git a/tests/Fixtures/LegacyWorkflowRegistry.php b/tests/Fixtures/LegacyWorkflowRegistry.php
deleted file mode 100644
index 497aa52..0000000
--- a/tests/Fixtures/LegacyWorkflowRegistry.php
+++ /dev/null
@@ -1,26 +0,0 @@
-addWorkflow($workflow, $supportStrategy);
-
- return;
- }
-
- parent::add($workflow, $supportStrategy);
- }
-}
diff --git a/tests/Fixtures/StubTranslator.php b/tests/Fixtures/StubTranslator.php
index 90d56bf..dacaa02 100644
--- a/tests/Fixtures/StubTranslator.php
+++ b/tests/Fixtures/StubTranslator.php
@@ -4,39 +4,12 @@
namespace Yokai\SonataWorkflow\Tests\Fixtures;
-use Symfony\Component\Translation\TranslatorInterface as LegacyTranslatorInterface;
use Symfony\Contracts\Translation\TranslatorInterface;
-/**
- * `StubTranslator` provides a simple implementation for the "translator" service.
- */
-if (interface_exists(TranslatorInterface::class)) {
- final class StubTranslator implements TranslatorInterface
+final class StubTranslator implements TranslatorInterface
+{
+ public function trans($id, array $parameters = [], $domain = null, $locale = null): string
{
- public function trans($id, array $parameters = [], $domain = null, $locale = null): string
- {
- return '[trans]'.strtr($id, $parameters).'[/trans]';
- }
- }
-} else {
- final class StubTranslator implements LegacyTranslatorInterface
- {
- public function trans($id, array $parameters = [], $domain = null, $locale = null)
- {
- return '[trans]'.$id.'[/trans]';
- }
-
- public function transChoice($id, $number, array $parameters = [], $domain = null, $locale = null)
- {
- return '[trans]'.$id.'[/trans]';
- }
-
- public function setLocale($locale)
- {
- }
-
- public function getLocale()
- {
- }
+ return '[trans]' . strtr($id, $parameters) . '[/trans]';
}
}
diff --git a/tests/PullRequest.php b/tests/PullRequest.php
index 8af6b04..9e8adb0 100644
--- a/tests/PullRequest.php
+++ b/tests/PullRequest.php
@@ -1,27 +1,29 @@
marking;
}
- public function setMarking($marking)
+ public function setMarking(string $marking): void
{
$this->marking = $marking;
}
- public static function createWorkflowDefinition()
+ public static function createWorkflowDefinition(): Definition
{
return new Definition(
['opened', 'pending_review', 'merged', 'closed'],
@@ -34,12 +36,8 @@ public static function createWorkflowDefinition()
);
}
- public static function createSupportStrategy()
+ public static function createSupportStrategy(): WorkflowSupportStrategyInterface
{
- if (class_exists(InstanceOfSupportStrategy::class)) {
- return new InstanceOfSupportStrategy(__CLASS__);
- }
-
- return new ClassInstanceSupportStrategy(__CLASS__);
+ return new InstanceOfSupportStrategy(__CLASS__);
}
}
diff --git a/tests/PullRequestWorkflowController.php b/tests/PullRequestWorkflowController.php
index 67b4c2a..9237cd5 100644
--- a/tests/PullRequestWorkflowController.php
+++ b/tests/PullRequestWorkflowController.php
@@ -1,5 +1,7 @@