ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
LinearWorkflowTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21require_once(__DIR__ . "/../../../../../../../vendor/composer/vendor/autoload.php");
22require_once(__DIR__ . "/../../../Base.php");
23
25
27{
28 protected string $title;
29 protected array $steps;
30 protected Workflow\Linear $wf;
31
32 protected function buildFactory(): Workflow\Factory
33 {
35 }
36
37 public function setUp(): void
38 {
39 $f = $this->buildFactory();
40 $this->title = 'title';
41 $this->steps = [
42 $f->step(''),
43 $f->step('')
44 ];
45 $this->wf = $f->linear($this->title, $this->steps);
46 }
47
48 public function testImplementsFactoryInterface(): void
49 {
50 $this->assertInstanceOf(Workflow\Workflow::class, $this->wf);
51 }
52
53 public function testConstructorParams(): void
54 {
55 $this->assertEquals($this->title, $this->wf->getTitle());
56 $this->assertEquals($this->steps, $this->wf->getSteps());
57 $this->assertEquals(0, $this->wf->getActive());
58 }
59
60 public function testConstructor(): void
61 {
62 $this->assertEquals($this->title, $this->wf->getTitle());
63 $this->assertEquals($this->steps, $this->wf->getSteps());
64 $this->assertEquals(0, $this->wf->getActive());
65 }
66
67 public function testAmountOfSteps(): void
68 {
69 $this->assertEquals(count($this->steps), $this->wf->getAmountOfSteps());
70 }
71
72 public function testActive(): void
73 {
74 $wf = $this->wf->withActive(1);
75 $this->assertEquals(1, $wf->getActive());
76 }
77
78 public function testWithActiveThrows(): void
79 {
80 $raised = false;
81 try {
82 $this->wf->withActive(-1);
83 $this->assertFalse("This should not happen.");
84 } catch (InvalidArgumentException $e) {
85 $raised = true;
86 }
87 $this->assertTrue($raised);
88
89 $raised = false;
90 try {
91 $this->wf->withActive(2);
92 $this->assertFalse("This should not happen.");
93 } catch (InvalidArgumentException $e) {
94 $raised = true;
95 }
96 $this->assertTrue($raised);
97 }
98}
Provides common functionality for UI tests.
Definition: Base.php:337
This is the interface for a workflow factory.
Definition: Factory.php:29
withActive(int $active)
The step at this position is set to active.
getActive()
This is the index of the active step.