summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorxjm2017-02-12 04:01:08 (GMT)
committerxjm2017-02-12 04:01:08 (GMT)
commit0e666ab07090755a8e93ac674f9f5c814a8e5817 (patch)
treed734d59a315a87642bfe33168e1bb7b6a1292860
parent178a615c6bbf087c8f260cac9be544d73ee0cb59 (diff)
Issue #2850670 by scott_euser, timmillwood: Add unit test coverage to ensure already existing transitions aren't allowed
-rw-r--r--core/modules/workflows/tests/src/Unit/WorkflowTest.php16
1 files changed, 16 insertions, 0 deletions
diff --git a/core/modules/workflows/tests/src/Unit/WorkflowTest.php b/core/modules/workflows/tests/src/Unit/WorkflowTest.php
index b055fab..89ee31f 100644
--- a/core/modules/workflows/tests/src/Unit/WorkflowTest.php
+++ b/core/modules/workflows/tests/src/Unit/WorkflowTest.php
@@ -611,6 +611,22 @@ class WorkflowTest extends UnitTestCase {
}
/**
+ * @covers ::setTransitionFromStates
+ */
+ public function testSetTransitionFromStatesAlreadyExists() {
+ $this->setExpectedException(\InvalidArgumentException::class, "The 'create_new_draft' transition already allows 'draft' to 'draft' transitions in workflow 'test'");
+ $workflow = new Workflow(['id' => 'test', 'type' => 'test_type'], 'workflow');
+ $workflow
+ ->addState('draft', 'Draft')
+ ->addState('archived', 'Archived')
+ ->addState('needs_review', 'Needs Review')
+ ->addTransition('create_new_draft', 'Create new draft', ['draft'], 'draft')
+ ->addTransition('needs_review', 'Needs review', ['needs_review'], 'draft');
+
+ $workflow->setTransitionFromStates('needs_review', ['draft']);
+ }
+
+ /**
* @covers ::deleteTransition
*/
public function testDeleteTransition() {