Skip to content

Commit

Permalink
Asserts
Browse files Browse the repository at this point in the history
  • Loading branch information
SergeyBel committed Feb 4, 2023
1 parent 94aa823 commit ca7f8f3
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/BaseTest/Asserts.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,35 @@ public function assertNull(mixed $value): void
$this->wrap(fn () => Assert::null($value));
}

public function assertInstanceOf(mixed $value, string $class): void
{
$this->wrap(fn () => Assert::isInstanceOf($value, $class));
}

/**
* @param array<mixed> $data
* @throws PhpInvariantAssertException
*/
public function assertArrayHasKey(int | string $key, array $data): void
{
if (!array_key_exists($key, $data)) {
throw new PhpInvariantAssertException('key '. $key. 'not found in array');
}
}

/**
* @param array<mixed> $data
* @throws PhpInvariantAssertException
*/
public function assertInArray(mixed $value, array $data): void
{
if (!in_array($value, $data)) {
throw new PhpInvariantAssertException('value '. $value. 'not found in array');
}
}



/**
* @throws PhpInvariantAssertException
*/
Expand Down

0 comments on commit ca7f8f3

Please sign in to comment.