Repository: ProcessMaker/nayra (php)

Issue:
Add persistence method for Start Event Triggered
Add a persistence method used when a Start Event is Triggered.

interface **TokenRepositoryInterface**:
```
    /**
     * Persists tokens that triggered a Start Event
     *
     * @param StartEventInterface $startEvent
     * @param CollectionInterface $tokens
     *
     * @return mixed
     */
    public function persistStartEventTriggered(StartEventInterface $startEvent, CollectionInterface $tokens);
```

ref: src/ProcessMaker/Nayra/Bpmn/StartEventTrait.php


Pull request:
Add persistence method for Start Event Triggered. Resolves #120
feature https://github.com/ProcessMaker/nayra/issues/120

- change method execute start event.
- remove file StartTransition.php
- add method persistStartEventTriggered in toker repository

Patch:
diff --git a/src/ProcessMaker/Nayra/Bpmn/ProcessTrait.php b/src/ProcessMaker/Nayra/Bpmn/ProcessTrait.php
index d702ddd..da4c319 100755
--- a/src/ProcessMaker/Nayra/Bpmn/ProcessTrait.php
+++ b/src/ProcessMaker/Nayra/Bpmn/ProcessTrait.php
@@ -443,9 +443,9 @@ trait ProcessTrait
             $dataStore = $this->getRepository()->createDataStore();
         }
         $instance = $this->getEngine()->createExecutionInstance($this, $dataStore);
-        $this->getEvents()->find(function(EventInterface $event){
+        $this->getEvents()->find(function(EventInterface $event) use($instance) {
             if ($event instanceof StartEventInterface && $event->getEventDefinitions()->count() === 0) {
-                $event->start();
+                $event->start($instance);
             }
         });
         return $instance;
diff --git a/src/ProcessMaker/Nayra/Bpmn/StartEventTrait.php b/src/ProcessMaker/Nayra/Bpmn/StartEventTrait.php
index 26d8f16..c6b28f6 100755
--- a/src/ProcessMaker/Nayra/Bpmn/StartEventTrait.php
+++ b/src/ProcessMaker/Nayra/Bpmn/StartEventTrait.php
@@ -40,18 +40,26 @@ trait StartEventTrait
     public function buildTransitions(RepositoryInterface $factory)
     {
         $this->setRepository($factory);
-        $this->transition = new StartTransition($this);
+        $this->transition = new Transition($this);
         $this->transition->attachEvent(
             TransitionInterface::EVENT_BEFORE_TRANSIT,
             function(TransitionInterface $transition, CollectionInterface $consumeTokens) {
+                $this->getRepository()
+                    ->getTokenRepository()
+                    ->persistStartEventTriggered($this, $consumeTokens);
                 $this->notifyEvent(EventInterface::EVENT_EVENT_TRIGGERED, $this, $transition, $consumeTokens);
             }
         );
 
-        foreach($this->getEventDefinitions() as $index => $eventDefinition) {
+        $eventDefinitions = $this->getEventDefinitions();
+        foreach($eventDefinitions as $index => $eventDefinition) {
             $this->triggerPlace[$index] = new State($this, $eventDefinition->getId());
             $this->triggerPlace[$index]->connectTo($this->transition);
         }
+        if ($eventDefinitions->count() === 0) {
+            $this->triggerPlace[0] = new State($this);
+            $this->triggerPlace[0]->connectTo($this->transition);
+        }
     }
 
     /**
@@ -80,11 +88,13 @@ trait StartEventTrait
     /**
      * Start event.
      *
+     * @param \ProcessMaker\Nayra\Contracts\Engine\ExecutionInstanceInterface $instance
+     *
      * @return $this;
      */
-    public function start()
+    public function start(ExecutionInstanceInterface $instance)
     {
-        $this->transition->start();
+        $this->triggerPlace[0]->addNewToken($instance);
         return $this;
     }
 
@@ -99,27 +109,16 @@ trait StartEventTrait
      */
     public function execute(EventDefinitionInterface $event, ExecutionInstanceInterface $instance = null, TokenInterface $token = null)
     {
-        $start = $this->getEventDefinitions()->count() === 0;
-        $index = -1;
         foreach ($this->getEventDefinitions() as $index => $eventDefinition) {
             if ($eventDefinition->assertsRule($event, $this, $instance)) {
-                $start = true;
-                break;
-            }
-        }
-        if ($start) {
-            if ($instance === null) {
-                $process = $this->getOwnerProcess();
-                $dataStorage = $process->getRepository()->createDataStore();
-                $instance = $process->getEngine()->createExecutionInstance($process, $dataStorage);
-            }
-            //Execute the behavior of the EventDefinition
-            foreach ($this->getEventDefinitions() as $index => $eventDefinition) {
+                if ($instance === null) {
+                    $process = $this->getOwnerProcess();
+                    $dataStorage = $process->getRepository()->createDataStore();
+                    $instance = $process->getEngine()->createExecutionInstance($process, $dataStorage);
+                }
+                $this->triggerPlace[$index]->addNewToken($instance);
                 $eventDefinition->execute($event, $this, $instance, $token);
             }
-            $this->start();
-            // with a new token in the trigger place, the event catch element will be fired
-            $index < 0 ?: $this->triggerPlace[$index]->addNewToken($instance);
         }
         return $this;
     }
diff --git a/src/ProcessMaker/Nayra/Bpmn/StartTransition.php b/src/ProcessMaker/Nayra/Bpmn/StartTransition.php
deleted file mode 100755
index c3abf4a..0000000
--- a/src/ProcessMaker/Nayra/Bpmn/StartTransition.php
+++ /dev/null
@@ -1,55 +0,0 @@
-<?php
-
-namespace ProcessMaker\Nayra\Bpmn;
-
-use ProcessMaker\Nayra\Bpmn\TransitionTrait;
-use ProcessMaker\Nayra\Contracts\Bpmn\TokenInterface;
-use ProcessMaker\Nayra\Contracts\Bpmn\TransitionInterface;
-use ProcessMaker\Nayra\Contracts\Engine\ExecutionInstanceInterface;
-
-/**
- * Transition rule for a start event.
- *
- * @package ProcessMaker\Nayra\Bpmn
- */
-class StartTransition implements TransitionInterface
-{
-
-    use TransitionTrait;
-    private $startCount = 0;
-
-    protected function initStartTransition()
-    {
-        $this->attachEvent(
-            TransitionInterface::EVENT_AFTER_CONSUME,
-            function() {
-                $this->startCount--;
-            }
-        );
-    }
-
-    public function start()
-    {
-        $this->startCount++;
-    }
-
-    public function assertCondition(TokenInterface $token= null, ExecutionInstanceInterface $executionInstance)
-    {
-        return $this->startCount > 0;
-    }
-
-    public function hasAllRequiredTokens(ExecutionInstanceInterface $executionInstance)
-    {
-        // if the start event is a normal event, always return true, otherwise check for the presence of
-        //the trigger count by counting the number of tokens
-
-        if ($this->owner->getEventDefinitions()->count() === 0) {
-            return true;
-        }
-        else {
-            return $this->incoming()->count() > 0 && $this->incoming()->find(function ($flow) use ($executionInstance) {
-                    return $flow->origin()->getTokens($executionInstance)->count() === 0;
-                })->count() === 0;
-        }
-    }
-}
diff --git a/src/ProcessMaker/Nayra/Contracts/Bpmn/StartEventInterface.php b/src/ProcessMaker/Nayra/Contracts/Bpmn/StartEventInterface.php
index 1d45667..bd4dd70 100644
--- a/src/ProcessMaker/Nayra/Contracts/Bpmn/StartEventInterface.php
+++ b/src/ProcessMaker/Nayra/Contracts/Bpmn/StartEventInterface.php
@@ -2,6 +2,8 @@
 
 namespace ProcessMaker\Nayra\Contracts\Bpmn;
 
+use ProcessMaker\Nayra\Contracts\Engine\ExecutionInstanceInterface;
+
 /**
  * End event interface.
  *
@@ -12,7 +14,9 @@ interface StartEventInterface extends CatchEventInterface
     /**
      * Start event.
      *
+     * @param \ProcessMaker\Nayra\Contracts\Engine\ExecutionInstanceInterface $instance
+     *
      * @return $this;
      */
-    public function start();
+    public function start(ExecutionInstanceInterface $instance);
 }
diff --git a/src/ProcessMaker/Nayra/Contracts/Repositories/TokenRepositoryInterface.php b/src/ProcessMaker/Nayra/Contracts/Repositories/TokenRepositoryInterface.php
index 90c7e7b..d8d68ab 100755
--- a/src/ProcessMaker/Nayra/Contracts/Repositories/TokenRepositoryInterface.php
+++ b/src/ProcessMaker/Nayra/Contracts/Repositories/TokenRepositoryInterface.php
@@ -5,7 +5,9 @@ namespace ProcessMaker\Nayra\Contracts\Repositories;
 use ProcessMaker\Nayra\Bpmn\Collection;
 use ProcessMaker\Nayra\Contracts\Bpmn\ActivityInterface;
 use ProcessMaker\Nayra\Contracts\Bpmn\CatchEventInterface;
+use ProcessMaker\Nayra\Contracts\Bpmn\CollectionInterface;
 use ProcessMaker\Nayra\Contracts\Bpmn\GatewayInterface;
+use ProcessMaker\Nayra\Contracts\Bpmn\StartEventInterface;
 use ProcessMaker\Nayra\Contracts\Bpmn\ThrowEventInterface;
 use ProcessMaker\Nayra\Contracts\Bpmn\TokenInterface;
 
@@ -175,7 +177,7 @@ interface TokenRepositoryInterface
 
     /**
      * Persists instance and token data when a message arrives to a catch event
-     * 
+     *
      * @param CatchEventInterface $intermediateCatchEvent
      * @param TokenInterface $token
      */
@@ -183,9 +185,19 @@ interface TokenRepositoryInterface
 
     /**
      * Persists instance and token data when a message is consumed in a catch event
-     * 
+     *
      * @param CatchEventInterface $intermediateCatchEvent
      * @param TokenInterface $token
      */
     public function persistCatchEventMessageConsumed(CatchEventInterface $intermediateCatchEvent, TokenInterface $token);
+
+    /**
+     * Persists tokens that triggered a Start Event
+     *
+     * @param \ProcessMaker\Nayra\Contracts\Bpmn\StartEventInterface $startEvent
+     * @param \ProcessMaker\Nayra\Contracts\Bpmn\CollectionInterface $tokens
+     *
+     * @return mixed
+     */
+    public function persistStartEventTriggered(StartEventInterface $startEvent, CollectionInterface $tokens);
 }


Test patch:
diff --git a/tests/Feature/Engine/ActivityExceptionTest.php b/tests/Feature/Engine/ActivityExceptionTest.php
index 74efc9a..e32991a 100755
--- a/tests/Feature/Engine/ActivityExceptionTest.php
+++ b/tests/Feature/Engine/ActivityExceptionTest.php
@@ -66,7 +66,7 @@ class ActivityExceptionTest extends EngineTestCase
         $this->assertEquals(0, $activity->getTokens($instance)->count());
 
         //Trigger start event
-        $start->start();
+        $start->start($instance);
         $this->engine->runToNextState();
         $this->assertEvents([
             ProcessInterface::EVENT_PROCESS_INSTANCE_CREATED,
diff --git a/tests/Feature/Engine/BasicsTest.php b/tests/Feature/Engine/BasicsTest.php
index 27d1710..08d1a15 100755
--- a/tests/Feature/Engine/BasicsTest.php
+++ b/tests/Feature/Engine/BasicsTest.php
@@ -66,7 +66,7 @@ class BasicsTest extends EngineTestCase
         $this->assertEquals(0, $activity->getTokens($instance)->count());
 
         //Trigger start event
-        $start->start();
+        $start->start($instance);
         $this->engine->runToNextState();
         $this->assertEvents([
             ProcessInterface::EVENT_PROCESS_INSTANCE_CREATED,
diff --git a/tests/Feature/Engine/ExclusiveGatewayTest.php b/tests/Feature/Engine/ExclusiveGatewayTest.php
index 4dbf675..c4b23f6 100644
--- a/tests/Feature/Engine/ExclusiveGatewayTest.php
+++ b/tests/Feature/Engine/ExclusiveGatewayTest.php
@@ -177,7 +177,7 @@ class ExclusiveGatewayTest extends EngineTestCase
         $activityB = $process->getActivities()->item(1);
 
         //Start the process
-        $start->start();
+        $start->start($instance);
 
         $this->engine->runToNextState();
 
@@ -211,13 +211,13 @@ class ExclusiveGatewayTest extends EngineTestCase
 
         //Load the process
         $process = $this->createProcessWithExclusiveGatewayAndDefaultTransition();
-        $this->engine->createExecutionInstance($process, $dataStore);
+        $instance = $this->engine->createExecutionInstance($process, $dataStore);
 
         //Get References
         $start = $process->getEvents()->item(0);
 
         //Start the process
-        $start->start();
+        $start->start($instance);
 
         $this->engine->runToNextState();
 
@@ -252,7 +252,7 @@ class ExclusiveGatewayTest extends EngineTestCase
         $activityC = $process->getActivities()->item(2);
 
         //Start the process
-        $start->start();
+        $start->start($instance);
 
         $this->engine->runToNextState();
 
@@ -314,7 +314,7 @@ class ExclusiveGatewayTest extends EngineTestCase
         $activityC = $process->getActivities()->item(2);
 
         //Start the process
-        $start->start();
+        $start->start($instance);
 
         $this->engine->runToNextState();
 
diff --git a/tests/Feature/Engine/InclusiveGatewayTest.php b/tests/Feature/Engine/InclusiveGatewayTest.php
index d53a752..34b3bdc 100755
--- a/tests/Feature/Engine/InclusiveGatewayTest.php
+++ b/tests/Feature/Engine/InclusiveGatewayTest.php
@@ -134,7 +134,7 @@ class InclusiveGatewayTest extends EngineTestCase
         $activityB = $process->getActivities()->item(1);
 
         //Start the process
-        $start->start();
+        $start->start($instance);
 
         $this->engine->runToNextState();
 
@@ -209,7 +209,7 @@ class InclusiveGatewayTest extends EngineTestCase
         $activityB = $process->getActivities()->item(1);
 
         //Start the process
-        $start->start();
+        $start->start($instance);
         $this->engine->runToNextState();
 
         //Assertion: Verify the triggered engine events. One activity is activated.
@@ -252,13 +252,13 @@ class InclusiveGatewayTest extends EngineTestCase
         $dataStore = $this->repository->createDataStore();
         $dataStore->putData('A', '2');
         $process = $this->createProcessWithDefaultTransition();
-        $this->engine->createExecutionInstance($process, $dataStore);
+        $instance = $this->engine->createExecutionInstance($process, $dataStore);
 
         //Get References
         $start = $process->getEvents()->item(0);
 
         //Start the process
-        $start->start();
+        $start->start($instance);
         $this->engine->runToNextState();
 
         //Assertion: The correct events of the default transition should be triggered
@@ -274,13 +274,13 @@ class InclusiveGatewayTest extends EngineTestCase
 
         $dataStore->putData('A', '1');
         $process = $this->createProcessWithDefaultTransition();
-        $this->engine->createExecutionInstance($process, $dataStore);
+        $instance = $this->engine->createExecutionInstance($process, $dataStore);
 
         //Get References
         $start = $process->getEvents()->item(0);
 
         //Start the process
-        $start->start();
+        $start->start($instance);
         $this->engine->runToNextState();
         //Assertion: The correct events of the default transition should be triggered
         $this->assertEvents([
diff --git a/tests/Feature/Engine/IntermediateMessageEventTest.php b/tests/Feature/Engine/IntermediateMessageEventTest.php
index ef1d565..681f269 100644
--- a/tests/Feature/Engine/IntermediateMessageEventTest.php
+++ b/tests/Feature/Engine/IntermediateMessageEventTest.php
@@ -257,7 +257,7 @@ class IntermediateMessageEventTest extends EngineTestCase
         $startC = $processB->getEvents()->item(0);
         $activityC = $processB->getActivities()->item(0);
 
-        $startC->start();
+        $startC->start($instanceB);
         $this->engine->runToNextState();
 
         //Assertion: The activity must be activated
@@ -285,7 +285,7 @@ class IntermediateMessageEventTest extends EngineTestCase
         $startA = $processA->getEvents()->item(0);
         $activityA = $processA->getActivities()->item(0);
 
-        $startA->start();
+        $startA->start($instanceA);
         $this->engine->runToNextState();
 
         //Assertion: The activity must be activated
@@ -368,7 +368,7 @@ class IntermediateMessageEventTest extends EngineTestCase
         $startC = $processB->getEvents()->item(0);
         $activityC = $processB->getActivities()->item(0);
 
-        $startC->start();
+        $startC->start($instanceB);
         $this->engine->runToNextState();
 
         //Assertion: The first activity of the second flow must be activated
@@ -396,7 +396,7 @@ class IntermediateMessageEventTest extends EngineTestCase
         $startA = $processA->getEvents()->item(0);
         $activityA = $processA->getActivities()->item(0);
 
-        $startA->start();
+        $startA->start($instanceA);
         $this->engine->runToNextState();
 
         //Assertion: The activity must be activated
diff --git a/tests/Feature/Engine/IntermediateTimerEventTest.php b/tests/Feature/Engine/IntermediateTimerEventTest.php
index 60f8f35..f25ef91 100644
--- a/tests/Feature/Engine/IntermediateTimerEventTest.php
+++ b/tests/Feature/Engine/IntermediateTimerEventTest.php
@@ -76,7 +76,7 @@ class IntermediateTimerEventTest extends EngineTestCase
         $instance = $this->engine->createExecutionInstance($process, $dataStore);
 
         //run the process
-        $start->start();
+        $start->start($instance);
         $this->engine->runToNextState();
 
         //Complete the first task
@@ -136,7 +136,7 @@ class IntermediateTimerEventTest extends EngineTestCase
         $instance = $this->engine->createExecutionInstance($process, $dataStore);
 
         //run the process
-        $start->start();
+        $start->start($instance);
         $this->engine->runToNextState();
 
         //Complete the first task
@@ -196,7 +196,7 @@ class IntermediateTimerEventTest extends EngineTestCase
         $instance = $this->engine->createExecutionInstance($process, $dataStore);
 
         //run the process
-        $start->start();
+        $start->start($instance);
         $this->engine->runToNextState();
 
         //Complete the first task
diff --git a/tests/Feature/Engine/LoadFromBPMNFileTest.php b/tests/Feature/Engine/LoadFromBPMNFileTest.php
index 6af4d8c..f7a36ca 100644
--- a/tests/Feature/Engine/LoadFromBPMNFileTest.php
+++ b/tests/Feature/Engine/LoadFromBPMNFileTest.php
@@ -78,7 +78,7 @@ class LoadFromBPMNFileTest extends EngineTestCase
         $endActivity = $bpmnRepository->getScriptTask('end');
 
         //Start the process
-        $start->start();
+        $start->start($instance);
         $this->engine->runToNextState();
 
         //Completes the Activity 0
@@ -193,7 +193,7 @@ class LoadFromBPMNFileTest extends EngineTestCase
         $instance = $this->engine->createExecutionInstance($process, $dataStore);
 
         //Start the process
-        $start->start();
+        $start->start($instance);
         $this->engine->runToNextState();
 
         //Completes the Activity 0
diff --git a/tests/Feature/Engine/MessageEndEventTest.php b/tests/Feature/Engine/MessageEndEventTest.php
index e586b93..96eab09 100644
--- a/tests/Feature/Engine/MessageEndEventTest.php
+++ b/tests/Feature/Engine/MessageEndEventTest.php
@@ -144,7 +144,7 @@ class MessageEndEventTest extends EngineTestCase
         $startA = $processA->getEvents()->item(0);
         $activityA1 = $processA->getActivities()->item(0);
 
-        $startA->start();
+        $startA->start($instanceA);
         $this->engine->runToNextState();
 
         //Assertion: The activity must be activated
@@ -168,7 +168,7 @@ class MessageEndEventTest extends EngineTestCase
             IntermediateCatchEventInterface::EVENT_CATCH_TOKEN_ARRIVES,
         ]);
 
-        $startB->start();
+        $startB->start($instanceB);
         $this->engine->runToNextState();
 
         //Assertion: Process B - The activity must be activated
diff --git a/tests/Feature/Engine/MessageStartEventTest.php b/tests/Feature/Engine/MessageStartEventTest.php
index e94ed50..edade72 100644
--- a/tests/Feature/Engine/MessageStartEventTest.php
+++ b/tests/Feature/Engine/MessageStartEventTest.php
@@ -142,7 +142,7 @@ class MessageStartEventTest extends EngineTestCase
         $startA = $processA->getEvents()->item(0);
         $activityA1 = $processA->getActivities()->item(0);
 
-        $startA->start();
+        $startA->start($instanceA);
         $this->engine->runToNextState();
 
         //Assertion: The activity must be activated
diff --git a/tests/Feature/Engine/NayraModelTest.php b/tests/Feature/Engine/NayraModelTest.php
index e3a69ef..544772c 100644
--- a/tests/Feature/Engine/NayraModelTest.php
+++ b/tests/Feature/Engine/NayraModelTest.php
@@ -38,7 +38,7 @@ class NayraModelTest extends EngineTestCase
         $instance = $this->engine->createExecutionInstance($process, $dataStore);
 
         //Start the process
-        $start->start();
+        $start->start($instance);
 
         $this->engine->runToNextState();
 
@@ -77,7 +77,7 @@ class NayraModelTest extends EngineTestCase
         $instance = $this->engine->createExecutionInstance($process, $dataStore);
 
         //Start the process
-        $start->start();
+        $start->start($instance);
 
         $this->engine->runToNextState();
 
diff --git a/tests/Feature/Engine/ParallelGatewayTest.php b/tests/Feature/Engine/ParallelGatewayTest.php
index aa51a48..ec26c20 100644
--- a/tests/Feature/Engine/ParallelGatewayTest.php
+++ b/tests/Feature/Engine/ParallelGatewayTest.php
@@ -134,7 +134,7 @@ class ParallelGatewayTest extends EngineTestCase
         $activityC = $process->getActivities()->item(2);
 
         //Start the process
-        $start->start();
+        $start->start($instance);
 
         $this->engine->runToNextState();
 
@@ -227,7 +227,7 @@ class ParallelGatewayTest extends EngineTestCase
         $activityC = $process->getActivities()->item(2);
 
         //Start the process
-        $start->start();
+        $start->start($instance);
 
         $this->engine->runToNextState();
 
diff --git a/tests/Feature/Engine/ScriptTaskTest.php b/tests/Feature/Engine/ScriptTaskTest.php
index 1eead53..cd82903 100644
--- a/tests/Feature/Engine/ScriptTaskTest.php
+++ b/tests/Feature/Engine/ScriptTaskTest.php
@@ -39,7 +39,7 @@ class ScriptTaskTest extends EngineTestCase
         $scriptTask = $process->getActivities()->item(1);
 
         //start the process an instance of the process
-        $start->start();
+        $start->start($instance);
         $this->engine->runToNextState();
 
         //Assert: that the process is stared and the first activity activated
@@ -97,7 +97,7 @@ class ScriptTaskTest extends EngineTestCase
         $scriptTask2 = $process->getActivities()->item(1);
 
         //start the process an instance of the process
-        $start->start();
+        $start->start($instance);
         $this->engine->runToNextState();
 
         //Assertion: all activities should run and the process finish immediately
@@ -164,7 +164,7 @@ class ScriptTaskTest extends EngineTestCase
         $scriptTask->setScript('throw new Exception ("test exception");');
 
         //start the process an instance of the process
-        $start->start();
+        $start->start($instance);
         $this->engine->runToNextState();
 
         //Assert: that the process is stared and the first activity activated
diff --git a/tests/Feature/Engine/ServiceTaskTest.php b/tests/Feature/Engine/ServiceTaskTest.php
index 93a33ac..027c68f 100644
--- a/tests/Feature/Engine/ServiceTaskTest.php
+++ b/tests/Feature/Engine/ServiceTaskTest.php
@@ -45,7 +45,7 @@ class ServiceTaskTest extends EngineTestCase
         $serviceCalls = static::$serviceCalls;
 
         //start the process an instance of the process
-        $start->start();
+        $start->start($instance);
         $this->engine->runToNextState();
 
         //Assert: that the process is stared and the service task is activated
@@ -104,7 +104,7 @@ class ServiceTaskTest extends EngineTestCase
         $serviceCalls = static::$serviceCalls;
 
         //start the process an instance of the process
-        $start->start();
+        $start->start($instance);
         $this->engine->runToNextState();
 
         //Assert: that the process is stared and the service task is activated
diff --git a/tests/Feature/Engine/SignalEndEventTest.php b/tests/Feature/Engine/SignalEndEventTest.php
index fcf7417..2f9a1fe 100644
--- a/tests/Feature/Engine/SignalEndEventTest.php
+++ b/tests/Feature/Engine/SignalEndEventTest.php
@@ -146,7 +146,7 @@ class SignalEndEventTest extends EngineTestCase
         $startA = $processA->getEvents()->item(0);
         $activityA1 = $processA->getActivities()->item(0);
 
-        $startA->start();
+        $startA->start($instanceA);
         $this->engine->runToNextState();
 
         //Assertion: The activity must be activated
@@ -171,7 +171,7 @@ class SignalEndEventTest extends EngineTestCase
             ]);
 
         //Start the process B
-        $startB->start();
+        $startB->start($instanceB);
         $this->engine->runToNextState();
 
         //Assertion: Process B - The activity must be activated
diff --git a/tests/Feature/Engine/SignalStartEventTest.php b/tests/Feature/Engine/SignalStartEventTest.php
index 0a06b8e..bd0edae 100644
--- a/tests/Feature/Engine/SignalStartEventTest.php
+++ b/tests/Feature/Engine/SignalStartEventTest.php
@@ -139,7 +139,7 @@ class SignalStartEventTest extends EngineTestCase
         $startA = $processA->getEvents()->item(0);
         $activityA1 = $processA->getActivities()->item(0);
 
-        $startA->start();
+        $startA->start($instanceA);
         $this->engine->runToNextState();
 
         //Assertion: The activity must be activated
diff --git a/tests/ProcessMaker/Test/Models/TokenRepository.php b/tests/ProcessMaker/Test/Models/TokenRepository.php
index 7e09ff7..2d0f641 100755
--- a/tests/ProcessMaker/Test/Models/TokenRepository.php
+++ b/tests/ProcessMaker/Test/Models/TokenRepository.php
@@ -6,7 +6,9 @@ use ProcessMaker\Nayra\Bpmn\Collection;
 use ProcessMaker\Nayra\Bpmn\Models\Token;
 use ProcessMaker\Nayra\Contracts\Bpmn\ActivityInterface;
 use ProcessMaker\Nayra\Contracts\Bpmn\CatchEventInterface;
+use ProcessMaker\Nayra\Contracts\Bpmn\CollectionInterface;
 use ProcessMaker\Nayra\Contracts\Bpmn\GatewayInterface;
+use ProcessMaker\Nayra\Contracts\Bpmn\StartEventInterface;
 use ProcessMaker\Nayra\Contracts\Bpmn\ThrowEventInterface;
 use ProcessMaker\Nayra\Contracts\Bpmn\TokenInterface;
 use ProcessMaker\Nayra\Contracts\Repositories\TokenRepositoryInterface;
@@ -66,7 +68,7 @@ class TokenRepository implements TokenRepositoryInterface
      */
     public function persistActivityActivated(ActivityInterface $activity, TokenInterface $token)
     {
-        
+
     }
 
     /**
@@ -79,7 +81,7 @@ class TokenRepository implements TokenRepositoryInterface
      */
     public function persistActivityException(ActivityInterface $activity, TokenInterface $token)
     {
-        
+
     }
 
     /**
@@ -92,7 +94,7 @@ class TokenRepository implements TokenRepositoryInterface
      */
     public function persistActivityCompleted(ActivityInterface $activity, TokenInterface $token)
     {
-        
+
     }
 
     /**
@@ -105,7 +107,7 @@ class TokenRepository implements TokenRepositoryInterface
      */
     public function persistActivityClosed(ActivityInterface $activity, TokenInterface $token)
     {
-        
+
     }
 
     /**
@@ -246,7 +248,7 @@ class TokenRepository implements TokenRepositoryInterface
 
     /**
      * Persists instance and token data when a message arrives to a catch event
-     * 
+     *
      * @param CatchEventInterface $intermediateCatchEvent
      * @param TokenInterface $token
      */
@@ -257,7 +259,7 @@ class TokenRepository implements TokenRepositoryInterface
 
     /**
      * Persists instance and token data when a message is consumed in a catch event
-     * 
+     *
      * @param CatchEventInterface $intermediateCatchEvent
      * @param TokenInterface $token
      */
@@ -265,4 +267,16 @@ class TokenRepository implements TokenRepositoryInterface
     {
         $this->persistCalls++;
     }
+
+    /**
+     * Persists tokens that triggered a Start Event
+     *
+     * @param StartEventInterface $startEvent
+     * @param CollectionInterface $tokens
+     *
+     */
+    public function persistStartEventTriggered(StartEventInterface $startEvent, CollectionInterface $tokens)
+    {
+
+    }
 }