mark example

$dumper = new MermaidDumper($transitionType);
                break;

            case 'dot':
            default:
                $dumper = ('workflow' === $type) ? new GraphvizDumper() : new StateMachineGraphvizDumper();
        }

        $marking = new Marking();

        foreach ($input->getArgument('marking') as $place) {
            $marking->mark($place);
        }

        $options = [
            'name' => $workflowName,
            'with-metadata' => $input->getOption('with-metadata'),
            'nofooter' => true,
            'label' => $input->getOption('label'),
        ];
        $output->writeln($dumper->dump($definition$marking$options));

        return 0;
    }
class PropertiesMarkingStoreTest extends TestCase
{
    public function testGetSetMarkingWithMultipleState()
    {
        $subject = new SubjectWithProperties();
        $markingStore = new MethodMarkingStore(false);

        $marking = $markingStore->getMarking($subject);

        $this->assertCount(0, $marking->getPlaces());

        $marking->mark('first_place');

        $markingStore->setMarking($subject$marking['foo' => 'bar']);

        $this->assertSame(['first_place' => 1]$subject->marking);

        $marking2 = $markingStore->getMarking($subject);

        $this->assertEquals($marking$marking2);
    }

    public function testGetSetMarkingWithSingleState()
    {
class Marking
{
    private array $places = [];
    private ?array $context = null;

    /** * @param int[] $representation Keys are the place name and values should be 1 */
    public function __construct(array $representation = [])
    {
        foreach ($representation as $place => $nbToken) {
            $this->mark($place);
        }
    }

    /** * @return void */
    public function mark(string $place)
    {
        $this->places[$place] = 1;
    }

    

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

        $markingStore = new MethodMarkingStore(false);

        $marking = $markingStore->getMarking($subject);

        $this->assertCount(0, $marking->getPlaces());

        $marking->mark('first_place');

        $markingStore->setMarking($subject$marking['foo' => 'bar']);

        $this->assertSame(['first_place' => 1]$subject->getMarking());
        $this->assertSame(['foo' => 'bar']$subject->getContext());

        $marking2 = $markingStore->getMarking($subject);

        $this->assertEquals($marking$marking2);
    }

    
public function getMarking(object $subject, array $context = []): Marking
    {
        $marking = $this->markingStore->getMarking($subject);

        // check if the subject is already in the workflow         if (!$marking->getPlaces()) {
            if (!$this->definition->getInitialPlaces()) {
                throw new LogicException(sprintf('The Marking is empty and there is no initial place for workflow "%s".', $this->name));
            }
            foreach ($this->definition->getInitialPlaces() as $place) {
                $marking->mark($place);
            }

            // update the subject with the new marking             $this->markingStore->setMarking($subject$marking);

            if (!$context) {
                $context = self::DEFAULT_INITIAL_CONTEXT;
            }

            $this->entered($subject, null, $marking$context);
        }

        
"place0-->|\"t1\"|place1\n"
            ."place3-->|\"My custom transition label 3\"|place1\n"
            ."linkStyle 1 stroke:Grey\n"
            ."place1-->|\"t2\"|place2\n"
            ."place1-->|\"t3\"|place3",
        ];
    }

    public static function provideWorkflowWithMarking(): iterable
    {
        $marking = new Marking();
        $marking->mark('b');
        $marking->mark('c');

        yield [
            self::createSimpleWorkflowDefinition(),
            $marking,
            "graph LR\n"
            ."place0([\"a\"])\n"
            ."place1((\"b\"))\n"
            ."style place1 stroke-width:4px\n"
            ."place2((\"c\"))\n"
            ."style place2 fill:DeepSkyBlue,stroke-width:4px\n"
            .
class MarkingTest extends TestCase
{
    public function testMarking()
    {
        $marking = new Marking(['a' => 1]);

        $this->assertTrue($marking->has('a'));
        $this->assertFalse($marking->has('b'));
        $this->assertSame(['a' => 1]$marking->getPlaces());

        $marking->mark('b');

        $this->assertTrue($marking->has('a'));
        $this->assertTrue($marking->has('b'));
        $this->assertSame(['a' => 1, 'b' => 1]$marking->getPlaces());

        $marking->unmark('a');

        $this->assertFalse($marking->has('a'));
        $this->assertTrue($marking->has('b'));
        $this->assertSame(['b' => 1]$marking->getPlaces());

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