Tests working with result object.
More...
◆ setUp()
◆ tearDown()
◆ testError()
ResultTest::testError |
( |
| ) |
|
Definition at line 52 of file ResultTest.php.
References $result.
54 $result = $this->f->error(
"Something went wrong");
55 $this->assertEquals(
"Something went wrong",
$result->error());
◆ testExceptCallableNull()
ResultTest::testExceptCallableNull |
( |
| ) |
|
Definition at line 185 of file ResultTest.php.
References $result.
187 $result = $this->f->error(
"Something went wrong");
188 $exception =
"Something else went wrong";
190 $new_result =
$result->except(
function ($v) {
194 $this->assertInstanceOf(Data\Result::class, $new_result);
195 $this->assertEquals(
$result, $new_result);
◆ testExceptError()
ResultTest::testExceptError |
( |
| ) |
|
Definition at line 170 of file ResultTest.php.
References $result, and $ret.
172 $result = $this->f->error(
"Something went wrong");
173 $exception =
"Something else went wrong";
175 $new_result =
$result->except(
function ($v) use ($exception) {
176 $ret = $this->f->error($exception);
180 $this->assertInstanceOf(Data\Result::class, $new_result);
181 $this->assertNotEquals(
$result, $new_result);
182 $this->assertEquals(
"Something else went wrong", $new_result->error());
◆ testExceptNoResult()
ResultTest::testExceptNoResult |
( |
| ) |
|
Definition at line 212 of file ResultTest.php.
References $result.
214 $result = $this->f->error(
"Something went wrong");
217 $new_result =
$result->except(
function ($v) {
218 return "New error text";
226 $this->assertTrue($raised);
◆ testExceptOk()
ResultTest::testExceptOk |
( |
| ) |
|
Definition at line 198 of file ResultTest.php.
References $result, and $ret.
201 $exception =
"Something else went wrong";
203 $new_result =
$result->except(
function ($v) use ($exception) {
204 $ret = $this->f->error($exception);
208 $this->assertInstanceOf(Data\Result::class, $new_result);
209 $this->assertEquals(
$result, $new_result);
◆ testIsError()
ResultTest::testIsError |
( |
| ) |
|
◆ testIsOk()
◆ testMapError()
ResultTest::testMapError |
( |
| ) |
|
Definition at line 104 of file ResultTest.php.
References $result.
106 $result = $this->f->error(
"Something went wrong");
108 $new_result =
$result->map(
function ($v) use ($multiplicator) {
109 return $v * $multiplicator;
112 $this->assertEquals(
$result, $new_result);
◆ testMapOk()
ResultTest::testMapOk |
( |
| ) |
|
Definition at line 91 of file ResultTest.php.
References $result.
95 $new_result =
$result->map(
function ($v) use ($multiplicator) {
96 return $v * $multiplicator;
99 $this->assertInstanceOf(Data\Result::class, $new_result);
100 $this->assertNotEquals(
$result, $new_result);
101 $this->assertEquals(9, $new_result->value());
◆ testNoError()
ResultTest::testNoError |
( |
| ) |
|
◆ testNoValue()
ResultTest::testNoValue |
( |
| ) |
|
Definition at line 31 of file ResultTest.php.
References $result.
33 $result = $this->f->error(
"Something went wrong");
42 $this->assertTrue($raised);
◆ testThenCallableNull()
ResultTest::testThenCallableNull |
( |
| ) |
|
Definition at line 129 of file ResultTest.php.
References $result.
132 $new_result =
$result->then(
function ($v) {
136 $this->assertInstanceOf(Data\Result::class, $new_result);
137 $this->assertEquals(
$result, $new_result);
◆ testThenError()
ResultTest::testThenError |
( |
| ) |
|
Definition at line 140 of file ResultTest.php.
References $result, and $ret.
142 $result = $this->f->error(
"Something went wrong");
144 $new_result =
$result->then(
function ($v) use ($multiplicator) {
145 $ret = $this->f->ok(($v * $multiplicator));
149 $this->assertInstanceOf(Data\Result::class, $new_result);
150 $this->assertEquals(
$result, $new_result);
◆ testThenNoResult()
ResultTest::testThenNoResult |
( |
| ) |
|
◆ testThenOk()
ResultTest::testThenOk |
( |
| ) |
|
Definition at line 115 of file ResultTest.php.
References $result, and $ret.
119 $new_result =
$result->then(
function ($v) use ($multiplicator) {
120 $ret = $this->f->ok(($v * $multiplicator));
124 $this->assertInstanceOf(Data\Result::class, $new_result);
125 $this->assertNotEquals(
$result, $new_result);
126 $this->assertEquals(9, $new_result->value());
◆ testValue()
ResultTest::testValue |
( |
| ) |
|
◆ testValueOr()
ResultTest::testValueOr |
( |
| ) |
|
◆ testValueOrDefault()
ResultTest::testValueOrDefault |
( |
| ) |
|
The documentation for this class was generated from the following file: