Skip to content

Commit

Permalink
Merge pull request #9 from bwaidelich/task/tweak-tests
Browse files Browse the repository at this point in the history
TASK: Tweak tests
  • Loading branch information
bwaidelich authored Sep 5, 2023
2 parents 7e44e36 + b73c605 commit d462101
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/Integration/EventStoreTestBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
* @phpstan-type EventShape array{id?: string, type?: string, data?: string, tags?: array<string>}
* @phpstan-type EventEnvelopeShape array{id?: string, type?: string, data?: string, tags?: array<string>, sequenceNumber?: int}
*/
#[CoversClass(Tag::class)]
#[CoversClass(Tags::class)]
#[CoversClass(EventData::class)]
#[CoversClass(ConditionalAppendFailed::class)]
Expand All @@ -47,6 +48,12 @@
#[CoversClass(Events::class)]
#[CoversClass(SequenceNumber::class)]
#[CoversClass(StreamQuery::class)]
#[CoversClass(AppendCondition::class)]
#[CoversClass(EventMetadata::class)]
#[CoversClass(Criteria::class)]
#[CoversClass(TagsCriterion::class)]
#[CoversClass(EventTypesCriterion::class)]
#[CoversClass(EventTypesAndTagsCriterion::class)]
abstract class EventStoreTestBase extends TestCase
{

Expand Down
17 changes: 17 additions & 0 deletions tests/Unit/Types/TagsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,23 @@ public function test_fromJson_sorts_values_and_removes_duplicates(): void
self::assertTagsMatch(['bar:foos', 'foo:bar', 'foo:baz'], $tags);
}

public function test_single_fails_if_key_is_invalid(): void
{
$this->expectException(InvalidArgumentException::class);
Tags::single('invälid', 'some-value');
}

public function test_single_fails_if_value_is_invalid(): void
{
$this->expectException(InvalidArgumentException::class);
Tags::single('some-key', 'invälid');
}

public function test_single_returns_instance_with_single_tag(): void
{
self::assertTagsMatch(['foo:bar'], Tags::single('foo', 'bar'));
}

public function test_intersects_allows_checking_single_tags(): void
{
$ids = Tags::fromArray(['foo:bar', 'baz:foos']);
Expand Down

0 comments on commit d462101

Please sign in to comment.