Skip to content

[TwigBridge] Fix workflow test with deps=low #25458

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
41 changes: 6 additions & 35 deletions src/Symfony/Bridge/Twig/Tests/Extension/WorkflowExtensionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Symfony\Bridge\Twig\Extension\WorkflowExtension;
use Symfony\Component\Workflow\Definition;
use Symfony\Component\Workflow\Registry;
use Symfony\Component\Workflow\SupportStrategy\ClassInstanceSupportStrategy;
use Symfony\Component\Workflow\SupportStrategy\InstanceOfSupportStrategy;
use Symfony\Component\Workflow\Transition;
use Symfony\Component\Workflow\Workflow;
Expand All @@ -24,25 +25,6 @@ class WorkflowExtensionTest extends TestCase
private $extension;

protected function setUp()
{
$places = array('ordered', 'waiting_for_payment', 'processed');
$transitions = array(
new Transition('t1', 'ordered', 'waiting_for_payment'),
new Transition('t2', 'waiting_for_payment', 'processed'),
);
$definition = new Definition($places, $transitions);
$workflow = new Workflow($definition);

$registry = new Registry();
$registry->addWorkflow($workflow, new InstanceOfSupportStrategy(\stdClass::class));

$this->extension = new WorkflowExtension($registry);
}

/**
* @group legacy
*/
protected function setUpLegacyAdd()
{
if (!class_exists(Workflow::class)) {
$this->markTestSkipped('The Workflow component is needed to run tests for this extension.');
Expand All @@ -57,25 +39,14 @@ protected function setUpLegacyAdd()
$workflow = new Workflow($definition);

$registry = new Registry();
$registry->add($workflow, new InstanceOfSupportStrategy(\stdClass::class));

$addWorkflow = method_exists($registry, 'addWorkflow') ? 'addWorkflow' : 'add';
$supportStrategy = class_exists(InstanceOfSupportStrategy::class)
? new InstanceOfSupportStrategy(\stdClass::class)
: new ClassInstanceSupportStrategy(\stdClass::class);
$registry->$addWorkflow($workflow, $supportStrategy);
$this->extension = new WorkflowExtension($registry);
}

/**
* @group legacy
* @expectedDeprecation Symfony\Component\Workflow\Registry::add is deprecated since Symfony 4.1. Use addWorkflow() instead.
*/
public function testCanTransitionLegacy()
{
$this->setUpLegacyAdd();
$subject = new \stdClass();
$subject->marking = array();

$this->assertTrue($this->extension->canTransition($subject, 't1'));
$this->assertFalse($this->extension->canTransition($subject, 't2'));
}

public function testCanTransition()
{
$subject = new \stdClass();
Expand Down