Skip to content

Commit

Permalink
add more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
akondas committed May 29, 2024
1 parent 9cd0934 commit 9cb1328
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/Collection/MapTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use Munus\Control\Option;
use Munus\Exception\NoSuchElementException;
use Munus\Exception\UnsupportedOperationException;
use Munus\Tests\Stub\Event;
use Munus\Tuple;
use PHPUnit\Framework\TestCase;

Expand Down Expand Up @@ -330,4 +331,23 @@ public function testMapArrayAccessOffsetUnset(): void

unset($map['a']);
}

public function testMapWithObjects(): void
{
$event1 = new Event('1', 'same');
$event2 = new Event('2', 'same');
$event3 = new Event('2', 'different');

$map = Map::empty();
$map = $map->put($event1, 'magic');

self::assertSame('magic', $map->get($event1)->getOrNull());
self::assertSame('magic', $map[$event1]);
self::assertSame('magic', $map->get($event2)->getOrNull());
self::assertSame('magic', $map[$event2]);
self::assertNull($map->get($event3)->getOrNull());

self::assertTrue(Set::of($event1)->equals($map->keys()));
self::assertTrue(Stream::of('magic')->equals($map->values()));
}
}

0 comments on commit 9cb1328

Please sign in to comment.