Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / core / modules / workflows / tests / src / Unit / WorkflowTest.php
index 8cf449367cdac702007f6a1573434fe40564cf98..dc77a3d2f622946821348d7caa48d4fccec039ef 100644 (file)
@@ -225,6 +225,16 @@ class WorkflowTest extends UnitTestCase {
     $workflow->getTypePlugin()->setStateWeight('draft', 10);
   }
 
+  /**
+   * @covers ::setStateWeight
+   */
+  public function testSetStateWeightNonNumericException() {
+    $this->setExpectedException(\InvalidArgumentException::class, "The weight 'foo' must be numeric for state 'Published'.");
+    $workflow = new Workflow(['id' => 'test', 'type' => 'test_type'], 'workflow');
+    $workflow->getTypePlugin()->addState('published', 'Published');
+    $workflow->getTypePlugin()->setStateWeight('published', 'foo');
+  }
+
   /**
    * @covers ::deleteState
    */
@@ -556,6 +566,17 @@ class WorkflowTest extends UnitTestCase {
     $workflow->getTypePlugin()->setTransitionWeight('draft-published', 10);
   }
 
+  /**
+   * @covers ::setTransitionWeight
+   */
+  public function testSetTransitionWeightNonNumericException() {
+    $this->setExpectedException(\InvalidArgumentException::class, "The weight 'foo' must be numeric for transition 'Publish'.");
+    $workflow = new Workflow(['id' => 'test', 'type' => 'test_type'], 'workflow');
+    $workflow->getTypePlugin()->addState('published', 'Published');
+    $workflow->getTypePlugin()->addTransition('publish', 'Publish', [], 'published');
+    $workflow->getTypePlugin()->setTransitionWeight('publish', 'foo');
+  }
+
   /**
    * @covers ::setTransitionFromStates
    */