mirror of
https://github.com/danog/endtoend-test-psl.git
synced 2024-12-11 16:49:40 +01:00
28 lines
618 B
PHP
28 lines
618 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Psl\Tests;
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
use Psl;
|
|
use Psl\Exception\InvariantViolationException;
|
|
|
|
final class InvariantTest extends TestCase
|
|
{
|
|
public function testInvariant(): void
|
|
{
|
|
$this->expectException(InvariantViolationException::class);
|
|
$this->expectExceptionMessage('Something went wrong!');
|
|
|
|
Psl\invariant(false, 'Something %s %s!', 'went', 'wrong');
|
|
}
|
|
|
|
public function testInvariantDoesNotThrowWhenTheFactIsTrue(): void
|
|
{
|
|
Psl\invariant(2 === (1 + 1), 'Unless?');
|
|
|
|
$this->addToAssertionCount(1);
|
|
}
|
|
}
|