Skip to content

Commit 142b6d0

Browse files
committed
add more tests
1 parent 80eb301 commit 142b6d0

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

tests/ArrayHelper/GetValueTest.php

+7
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,13 @@ public function testGetValueByMatcher(): void
102102

103103
$taggedPost = ArrayHelper::getValue($posts, fn ($post) => isset($post->tag));
104104
$this->assertEquals('hello test', $taggedPost->title);
105+
106+
$default = ArrayHelper::getValue([], fn ($post) => isset($post->tag), 'default');
107+
$this->assertEquals($default, 'default');
108+
109+
$this->expectException(InvalidArgumentException::class);
110+
$this->expectExceptionMessage('Matcher cannot be applied to an object');
111+
$taggedPost = ArrayHelper::getValue(new StaticObject(), fn ($post) => isset($post->tag));
105112
}
106113

107114
public function dataProviderGetValueByPathFromArray(): array

0 commit comments

Comments
 (0)