Subject1 example

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()
    {
        $this->assertFalse($this->registry->has(new Subject1(), 'nope'));
    }

    public function testGetWithSuccess()
    {
        $workflow = $this->registry->get(new Subject1());
        $this->assertInstanceOf(Workflow::class$workflow);
        
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Symfony\Component\Workflow\SupportStrategy\InstanceOfSupportStrategy;
use Symfony\Component\Workflow\Workflow;

class InstanceOfSupportStrategyTest extends TestCase
{
    public function testSupportsIfClassInstance()
    {
        $strategy = new InstanceOfSupportStrategy(Subject1::class);

        $this->assertTrue($strategy->supports($this->createWorkflow()new Subject1()));
    }

    public function testSupportsIfNotClassInstance()
    {
        $strategy = new InstanceOfSupportStrategy(Subject2::class);

        $this->assertFalse($strategy->supports($this->createWorkflow()new Subject1()));
    }

    private function createWorkflow(): MockObject&Workflow
    {
        
Home | Imprint | This part of the site doesn't use cookies.