Skip to content

Commit 7161d6d

Browse files
committed
Requested changes
1 parent 94451c8 commit 7161d6d

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

tests/unit/Option/NoneTest.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Psl\Comparison\Order;
1111
use Psl\Option;
1212
use Psl\Option\Exception\NoneException;
13+
use Psl\Ref;
1314

1415
final class NoneTest extends TestCase
1516
{
@@ -86,14 +87,15 @@ public function testContains(): void
8687

8788
public function testApply(): void
8889
{
89-
$i = 1;
90+
$spy = new Ref(1);
9091

9192
$option = Option\none();
92-
$option->apply(static function (int $value) use (&$i) {
93-
$i += $value;
93+
$option->apply(static function (int $value) use ($spy) {
94+
$spy->value += $value;
9495
});
9596

96-
static::assertSame(1, $i);
97+
static::assertSame(1, $spy->value);
98+
static::assertTrue($option->isNone());
9799
}
98100

99101
public function testMap(): void

tests/unit/Option/SomeTest.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
use Psl\Comparison\Equable;
1010
use Psl\Comparison\Order;
1111
use Psl\Option;
12+
use Psl\Ref;
1213
use Psl\Tests\Fixture;
1314
use Psl\Type;
1415

@@ -85,14 +86,15 @@ public function testContains(): void
8586

8687
public function testApply(): void
8788
{
88-
$i = 1;
89+
$spy = new Ref(1);
8990

9091
$option = Option\some(2);
91-
$option->apply(static function (int $value) use (&$i) {
92-
$i += $value;
92+
$option->apply(static function (int $value) use ($spy) {
93+
$spy->value += $value;
9394
});
9495

95-
static::assertSame(3, $i);
96+
static::assertSame(3, $spy->value);
97+
static::assertSame(2, $option->unwrap());
9698
}
9799

98100
public function testMap(): void

0 commit comments

Comments
 (0)