ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
SeriesTest.php
Go to the documentation of this file.
1<?php
2/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
3
9
16
17require_once('./libs/composer/vendor/autoload.php');
18
19class SeriesTest extends TestCase
20{
21 public function testSeriesTransformation()
22 {
23 $series = new Series(array(new StringTransformation()));
24
25 $result = $series->transform('hello');
26
27 $this->assertEquals('hello', $result);
28 }
29
30 public function testSeriesApplyTo()
31 {
32 $series = new Series(array(
35 ));
36
37 $result = $series->applyTo(new Ok('hello'));
38
39 $this->assertEquals('hello', $result->value());
40 }
41
43 {
44 $this->expectNotToPerformAssertions();
45
46 $series = new Series(array(
49 ));
50
51 try {
52 $result = $series->transform(42.0);
53 } catch (ConstraintViolationException $exception) {
54 return;
55 }
56
57 $this->fail();
58 }
59
60
64 public function testSeriesApply()
65 {
66 $series = new Series(array(
69 ));
70
71 $result = $series->applyTo(new Ok(42.0));
72
73 $this->assertTrue($result->isError());
74 }
75
77 {
78 $this->expectNotToPerformAssertions();
79
80 try {
81 $parallel = new Series(
82 array(
84 'this is invalid'
85 )
86 );
87 } catch (ConstraintViolationException $exception) {
88 return;
89 }
90
91 $this->fail();
92 }
93}
$result
An exception for terminatinating execution or to throw for unit testing.
A result encapsulates a value or an error and simplifies the handling of those.
Definition: Ok.php:14