Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / workflows / tests / src / Unit / TransitionTest.php
1 <?php
2
3 namespace Drupal\Tests\workflows\Unit;
4
5 use Drupal\Tests\UnitTestCase;
6 use Drupal\workflow_type_test\Plugin\WorkflowType\TestType;
7 use Drupal\workflows\Transition;
8 use Drupal\workflows\WorkflowTypeInterface;
9
10 /**
11  * @coversDefaultClass \Drupal\workflows\Transition
12  *
13  * @group workflows
14  */
15 class TransitionTest extends UnitTestCase {
16
17   /**
18    * @covers ::__construct
19    * @covers ::id
20    * @covers ::label
21    */
22   public function testGetters() {
23     $state = new Transition(
24       $this->prophesize(WorkflowTypeInterface::class)->reveal(),
25       'draft_published',
26       'Publish',
27       ['draft'],
28       'published'
29     );
30     $this->assertEquals('draft_published', $state->id());
31     $this->assertEquals('Publish', $state->label());
32   }
33
34   /**
35    * @covers ::from
36    * @covers ::to
37    */
38   public function testFromAndTo() {
39     $workflow = new TestType([], '', []);
40     $workflow
41       ->addState('draft', 'Draft')
42       ->addState('published', 'Published')
43       ->addTransition('publish', 'Publish', ['draft'], 'published');
44     $state = $workflow->getState('draft');
45     $transition = $state->getTransitionTo('published');
46     $this->assertEquals($state, $transition->from()['draft']);
47     $this->assertEquals($workflow->getState('published'), $transition->to());
48   }
49
50 }