diff --git a/.travis.yml b/.travis.yml index 1a86a4a..bdf6f77 100644 --- a/.travis.yml +++ b/.travis.yml @@ -4,23 +4,20 @@ php: - 7.0 - 7.1 - 7.2 + - 7.3 env: - - SYMFONY_VERSION="3.3.*" - SYMFONY_VERSION="3.4.*" - - SYMFONY_VERSION="4.0.*" - - SYMFONY_VERSION="4.1.*" - - SYMFONY_VERSION="4.2.x-dev" + - SYMFONY_VERSION="4.2.*" + - SYMFONY_VERSION="4.3.*" matrix: exclude: # Symfony >= 4.0 PHP requirement is ^7.1.3 - php: 7.0 - env: SYMFONY_VERSION="4.0.*" + env: SYMFONY_VERSION="4.2.*" - php: 7.0 - env: SYMFONY_VERSION="4.1.*" - - php: 7.0 - env: SYMFONY_VERSION="4.2.x-dev" + env: SYMFONY_VERSION="4.3.*" sudo: false @@ -29,10 +26,10 @@ cache: - $HOME/.composer/cache before_install: - - composer selfupdate + - rm -rf composer.lock vendor/ - if [ "$SYMFONY_VERSION" != "" ]; then composer require "symfony/workflow:${SYMFONY_VERSION}" --no-update; fi; -install: composer update --prefer-dist --no-interaction $COMPOSER_FLAGS +install: COMPOSER_MEMORY_LIMIT=-1 travis_retry composer install --prefer-dist --no-interaction script: - vendor/bin/phpunit --coverage-clover=build/coverage/clover.xml diff --git a/src/Admin/Extension/WorkflowExtension.php b/src/Admin/Extension/WorkflowExtension.php index cb10699..6ffd85e 100644 --- a/src/Admin/Extension/WorkflowExtension.php +++ b/src/Admin/Extension/WorkflowExtension.php @@ -90,7 +90,7 @@ public function configureSideMenu( $transitions = $workflow->getEnabledTransitions($subject); if (count($transitions) === 0) { - $this->noTransitions($menu); + $this->noTransitions($menu, $admin); } else { $this->transitionsDropdown($menu, $admin, $transitions, $subject); } @@ -139,8 +139,9 @@ protected function configureOptions(OptionsResolver $resolver) /** * @param MenuItemInterface $menu + * @param AdminInterface $admin */ - protected function noTransitions(MenuItemInterface $menu) + protected function noTransitions(MenuItemInterface $menu, AdminInterface $admin) { if ($this->options['no_transition_display']) { $menu->addChild($this->options['no_transition_label'], [ @@ -148,6 +149,9 @@ protected function noTransitions(MenuItemInterface $menu) 'attributes' => [ 'icon' => $this->options['no_transition_icon'], ], + 'extras' => [ + 'translation_domain' => $admin->getTranslationDomain(), + ], ]); } } @@ -165,6 +169,9 @@ protected function transitionsDropdown(MenuItemInterface $menu, AdminInterface $ 'dropdown' => true, 'icon' => $this->options['dropdown_transitions_icon'], ], + 'extras' => [ + 'translation_domain' => $admin->getTranslationDomain(), + ], ]); foreach ($transitions as $transition) { @@ -183,6 +190,9 @@ protected function transitionsItem(MenuItemInterface $menu, AdminInterface $admi $options = [ 'uri' => $this->generateTransitionUri($admin, $transition, $subject), 'attributes' => [], + 'extras' => [ + 'translation_domain' => $admin->getTranslationDomain(), + ], ]; if ($icon = $this->getTransitionIcon($transition)) { @@ -190,7 +200,7 @@ protected function transitionsItem(MenuItemInterface $menu, AdminInterface $admi } $menu->addChild( - $admin->getLabelTranslatorStrategy()->getLabel($transition->getName(), 'workflow'), + $admin->getLabelTranslatorStrategy()->getLabel($transition->getName(), 'workflow', 'transition'), $options ); } diff --git a/tests/Admin/Extension/WorkflowExtensionTest.php b/tests/Admin/Extension/WorkflowExtensionTest.php index 038544a..37e7b70 100644 --- a/tests/Admin/Extension/WorkflowExtensionTest.php +++ b/tests/Admin/Extension/WorkflowExtensionTest.php @@ -11,7 +11,6 @@ use Symfony\Component\Routing\Route; use Symfony\Component\Workflow\Registry; use Symfony\Component\Workflow\StateMachine; -use Symfony\Component\Workflow\SupportStrategy\InstanceOfSupportStrategy; use Yokai\SonataWorkflow\Admin\Extension\WorkflowExtension; use Yokai\SonataWorkflow\Controller\WorkflowController; use Yokai\SonataWorkflow\Tests\PullRequest; @@ -106,13 +105,14 @@ public function testConfigureSideMenu($marking, array $transitions) /** @var AdminInterface|ObjectProphecy $admin */ $admin = $this->prophesize(AdminInterface::class); + $admin->getTranslationDomain()->willReturn('admin'); $admin->getLabelTranslatorStrategy()->willReturn($labelStrategy->reveal()); $admin->getSubject()->willReturn($pullRequest); foreach ($transitions as $transition) { - $labelStrategy->getLabel($transition, 'workflow') + $labelStrategy->getLabel($transition, 'workflow', 'transition') ->shouldBeCalledTimes(1) - ->willReturn('transition.'.$transition); + ->willReturn('workflow.transition.'.$transition); $admin->generateObjectUrl('workflow_apply_transition', $pullRequest, ['transition' => $transition]) ->shouldBeCalledTimes(1) ->willReturn('/pull-request/42/workflow/transition/'.$transition.'/apply'); @@ -135,11 +135,13 @@ public function testConfigureSideMenu($marking, array $transitions) self::assertNull($child = $menu->getChild('workflow_transitions')); self::assertNotNull($child = $menu->getChild('workflow_transitions_empty')); self::assertSame('#', $child->getUri()); + self::assertSame('admin', $child->getExtra('translation_domain')); self::assertFalse($child->hasChildren()); self::assertEmpty($child->getChildren()); } else { self::assertNull($child = $menu->getChild('workflow_transitions_empty')); self::assertNotNull($child = $menu->getChild('workflow_transitions')); + self::assertSame('admin', $child->getExtra('translation_domain')); self::assertTrue($child->getAttribute('dropdown')); self::assertSame('fa fa-code-fork', $child->getAttribute('icon')); self::assertTrue($child->hasChildren()); @@ -150,8 +152,9 @@ public function testConfigureSideMenu($marking, array $transitions) $icon = 'fa fa-times'; } - self::assertNotNull($item = $child->getChild('transition.'.$transition)); + self::assertNotNull($item = $child->getChild('workflow.transition.'.$transition)); self::assertSame('/pull-request/42/workflow/transition/'.$transition.'/apply', $item->getUri()); + self::assertSame('admin', $item->getExtra('translation_domain')); self::assertSame($icon, $item->getAttribute('icon')); } }