mirror of
https://github.com/pestphp/pest.git
synced 2026-03-10 09:47:23 +01:00
feat(expect): updates test suite to use expectation api
This commit is contained in:
15
tests/Expect/toBeTrue.php
Normal file
15
tests/Expect/toBeTrue.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
|
||||
test('strict comparisons', function () {
|
||||
expect(true)->toBeTrue();
|
||||
});
|
||||
|
||||
test('failures', function () {
|
||||
expect('')->toBeTrue();
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('not failures', function () {
|
||||
expect(false)->not->toBe(false);
|
||||
})->throws(ExpectationFailedException::class);
|
||||
@ -1,17 +0,0 @@
|
||||
<?php
|
||||
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
|
||||
test('pass', function () {
|
||||
expect([1, 2, 3])->toContainOnly('int');
|
||||
expect(['hello', 'world'])->toContainOnly('string');
|
||||
});
|
||||
|
||||
test('failures', function () {
|
||||
expect([1, 2, '3'])->toContainOnly('string');
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('not failures', function () {
|
||||
expect([1, 2, 3])->not->toContainOnly('int');
|
||||
expect(['hello', 'world'])->not->toContainOnly('string');
|
||||
})->throws(ExpectationFailedException::class);
|
||||
@ -1,23 +0,0 @@
|
||||
<?php
|
||||
|
||||
use Pest\Actions\AddsTests;
|
||||
use Pest\Expectation;
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
|
||||
test('pass', function () {
|
||||
$expected = [new Expectation('whatever')];
|
||||
|
||||
expect($expected)->toContainOnlyInstancesOf(Expectation::class);
|
||||
});
|
||||
|
||||
test('failures', function () {
|
||||
$expected = [new Expectation('whatever')];
|
||||
|
||||
expect($expected)->toContainOnlyInstancesOf(AddsTests::class);
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('not failures', function () {
|
||||
$expected = [new Expectation('whatever')];
|
||||
|
||||
expect($expected)->not->toContainOnlyInstancesOf(Expectation::class);
|
||||
})->throws(ExpectationFailedException::class);
|
||||
@ -1,16 +0,0 @@
|
||||
<?php
|
||||
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
|
||||
test('is case sensitive', function () {
|
||||
expect('hello world')->toContainString('world');
|
||||
expect('hello world')->not->toContainString('World');
|
||||
});
|
||||
|
||||
test('failures', function () {
|
||||
expect('hello world')->toContainString('Hello');
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('not failures', function () {
|
||||
expect('hello world')->not->toContainString('hello');
|
||||
})->throws(ExpectationFailedException::class);
|
||||
@ -1,17 +0,0 @@
|
||||
<?php
|
||||
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
|
||||
test('ignore difference in casing', function () {
|
||||
expect('hello world')->toContainStringIgnoringCase('world');
|
||||
expect('hello world')->toContainStringIgnoringCase('World');
|
||||
});
|
||||
|
||||
test('failures', function () {
|
||||
expect('hello world')->toContainStringIgnoringCase('hi');
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('not failures', function () {
|
||||
expect('hello world')->not->toContainStringIgnoringCase('Hello');
|
||||
expect('hello world')->not->toContainStringIgnoringCase('hello');
|
||||
})->throws(ExpectationFailedException::class);
|
||||
@ -3,13 +3,13 @@
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
|
||||
test('pass', function () {
|
||||
expect([1, 2, 3])->toCount(3);
|
||||
expect([1, 2, 3])->toHaveCount(3);
|
||||
});
|
||||
|
||||
test('failures', function () {
|
||||
expect([1, 2, 3])->toCount(4);
|
||||
expect([1, 2, 3])->toHaveCount(4);
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('not failures', function () {
|
||||
expect([1, 2, 3])->not->toCount(3);
|
||||
expect([1, 2, 3])->not->toHaveCount(3);
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
@ -3,13 +3,13 @@
|
||||
use PHPUnit\Framework\ExpectationFailedException;
|
||||
|
||||
test('pass', function () {
|
||||
expect(1.0)->toEqualWithDelta(1.3, .4);
|
||||
expect(1.0)->toBeEqualWithDelta(1.3, .4);
|
||||
});
|
||||
|
||||
test('failures', function () {
|
||||
expect(1.0)->toEqualWithDelta(1.5, .1);
|
||||
expect(1.0)->toBeEqualWithDelta(1.5, .1);
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
test('not failures', function () {
|
||||
expect(1.0)->not->toEqualWithDelta(1.6, .7);
|
||||
expect(1.0)->not->toBeEqualWithDelta(1.6, .7);
|
||||
})->throws(ExpectationFailedException::class);
|
||||
|
||||
Reference in New Issue
Block a user