addWorkflow example

use Symfony\Component\Workflow\Workflow;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;

class RegistryTest extends TestCase
{
    private Registry $registry;

    protected function setUp(): void
    {
        $this->registry = new Registry();

        $this->registry->addWorkflow(new Workflow(new Definition([][])$this->createMock(MarkingStoreInterface::class)$this->createMock(EventDispatcherInterface::class), 'workflow1')$this->createWorkflowSupportStrategy(Subject1::class));
        $this->registry->addWorkflow(new Workflow(new Definition([][])$this->createMock(MarkingStoreInterface::class)$this->createMock(EventDispatcherInterface::class), 'workflow2')$this->createWorkflowSupportStrategy(Subject2::class));
        $this->registry->addWorkflow(new Workflow(new Definition([][])$this->createMock(MarkingStoreInterface::class)$this->createMock(EventDispatcherInterface::class), 'workflow3')$this->createWorkflowSupportStrategy(Subject2::class));
    }

    public function testHasWithMatch()
    {
        $this->assertTrue($this->registry->has(new Subject1()));
    }

    public function testHasWithoutMatch()
    {
        
$transitionsMetadata->attach($this->t1, ['title' => 't1 title']);
        $metadataStore = new InMemoryMetadataStore(
            ['title' => 'workflow title'],
            ['orderer' => ['title' => 'ordered title']],
            $transitionsMetadata
        );
        $definition = new Definition($places$transitions, null, $metadataStore);
        $workflow = new Workflow($definitionnew MethodMarkingStore());

        $registry = new Registry();
        $supportStrategy = new InstanceOfSupportStrategy(Subject::class);
        $registry->addWorkflow($workflow$supportStrategy);
        $this->extension = new WorkflowExtension($registry);
    }

    public function testCanTransition()
    {
        $subject = new Subject();

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

    
Home | Imprint | This part of the site doesn't use cookies.