-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Test conditions with global data store
- Loading branch information
Showing
2 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
39 changes: 39 additions & 0 deletions
39
tests/unit/ProcessMaker/Nayra/Bpmn/ConditionedExclusiveTransitionTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace ProcessMaker\Nayra\Bpmn; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use ProcessMaker\Nayra\Bpmn\Models\DataStore; | ||
use ProcessMaker\Nayra\Bpmn\Models\ExclusiveGateway; | ||
use ProcessMaker\Nayra\Bpmn\Models\Process; | ||
use ProcessMaker\Nayra\Contracts\Engine\EngineInterface; | ||
|
||
/** | ||
* Tests for the ConditionedTransition class | ||
*/ | ||
class ConditionedExclusiveTransitionTest extends TestCase | ||
{ | ||
/** | ||
* Tests that setters and getters are working properly | ||
*/ | ||
public function testAssertCondition() | ||
{ | ||
$gateway = new ExclusiveGateway(); | ||
$conditionedTransition = new ConditionedExclusiveTransition($gateway); | ||
$conditionedTransition->setCondition(function ($data) { | ||
return $data['foo']; | ||
}); | ||
|
||
// Mock a engine data store | ||
$process = new Process(); | ||
$engine = $this->getMockBuilder(EngineInterface::class)->getMock(); | ||
$dataStore = new DataStore(); | ||
$dataStore->setData(['foo' => 'bar']); | ||
$engine->method('getDataStore')->willReturn($dataStore); | ||
$process->setEngine($engine); | ||
$conditionedTransition->setOwnerProcess($process); | ||
|
||
// Assertion: The condition should return 'bar' | ||
$this->assertEquals('bar', $conditionedTransition->assertCondition()); | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
tests/unit/ProcessMaker/Nayra/Bpmn/ConditionedTransitionTest.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace ProcessMaker\Nayra\Bpmn; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use ProcessMaker\Nayra\Bpmn\Models\DataStore; | ||
use ProcessMaker\Nayra\Bpmn\Models\ExclusiveGateway; | ||
use ProcessMaker\Nayra\Bpmn\Models\Process; | ||
use ProcessMaker\Nayra\Contracts\Engine\EngineInterface; | ||
|
||
/** | ||
* Tests for the ConditionedTransition class | ||
*/ | ||
class ConditionedTransitionTest extends TestCase | ||
{ | ||
/** | ||
* Tests that setters and getters are working properly | ||
*/ | ||
public function testAssertCondition() | ||
{ | ||
$gateway = new ExclusiveGateway(); | ||
$conditionedTransition = new ConditionedTransition($gateway); | ||
$conditionedTransition->setCondition(function ($data) { | ||
return $data['foo']; | ||
}); | ||
|
||
// Mock a engine data store | ||
$process = new Process(); | ||
$engine = $this->getMockBuilder(EngineInterface::class)->getMock(); | ||
$dataStore = new DataStore(); | ||
$dataStore->setData(['foo' => 'bar']); | ||
$engine->method('getDataStore')->willReturn($dataStore); | ||
$process->setEngine($engine); | ||
$conditionedTransition->setOwnerProcess($process); | ||
|
||
// Assertion: The condition should return 'bar' | ||
$this->assertEquals('bar', $conditionedTransition->assertCondition()); | ||
} | ||
} |