mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 07:47:22 +01:00
feat(expect): fixes to contain with strings
This commit is contained in:
@ -147,7 +147,7 @@ final class Expectation
|
|||||||
*/
|
*/
|
||||||
public function toContain($value): Expectation
|
public function toContain($value): Expectation
|
||||||
{
|
{
|
||||||
if (is_string($value)) {
|
if (is_string($this->value)) {
|
||||||
Assert::assertStringContainsString($value, $this->value);
|
Assert::assertStringContainsString($value, $this->value);
|
||||||
} else {
|
} else {
|
||||||
Assert::assertContains($value, $this->value);
|
Assert::assertContains($value, $this->value);
|
||||||
|
|||||||
@ -119,7 +119,8 @@
|
|||||||
✓ not failures
|
✓ not failures
|
||||||
|
|
||||||
PASS Tests\Expect\toContain
|
PASS Tests\Expect\toContain
|
||||||
✓ passes
|
✓ passes strings
|
||||||
|
✓ passes arrays
|
||||||
✓ failures
|
✓ failures
|
||||||
✓ not failures
|
✓ not failures
|
||||||
|
|
||||||
@ -308,5 +309,5 @@
|
|||||||
WARN Tests\Visual\Success
|
WARN Tests\Visual\Success
|
||||||
- visual snapshot of test suite on success
|
- visual snapshot of test suite on success
|
||||||
|
|
||||||
Tests: 6 skipped, 181 passed
|
Tests: 6 skipped, 182 passed
|
||||||
Time: 5.70s
|
Time: 5.72s
|
||||||
|
|||||||
@ -2,10 +2,14 @@
|
|||||||
|
|
||||||
use PHPUnit\Framework\ExpectationFailedException;
|
use PHPUnit\Framework\ExpectationFailedException;
|
||||||
|
|
||||||
test('passes', function () {
|
test('passes strings', function () {
|
||||||
expect([1, 2, 42])->toContain(42);
|
expect([1, 2, 42])->toContain(42);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('passes arrays', function () {
|
||||||
|
expect('Nuno')->toContain('Nu');
|
||||||
|
});
|
||||||
|
|
||||||
test('failures', function () {
|
test('failures', function () {
|
||||||
expect([1, 2, 42])->toContain(3);
|
expect([1, 2, 42])->toContain(3);
|
||||||
})->throws(ExpectationFailedException::class);
|
})->throws(ExpectationFailedException::class);
|
||||||
|
|||||||
Reference in New Issue
Block a user