mirror of
https://github.com/pestphp/pest.git
synced 2026-07-22 01:20:03 +02:00
50 lines
1.5 KiB
PHP
50 lines
1.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
use PHPUnit\Framework\ExpectationFailedException;
|
|
|
|
test('passes strings', function (): void {
|
|
expect('Nuno')->toContain('Nu');
|
|
});
|
|
|
|
test('passes strings with multiple needles', function (): void {
|
|
expect('Nuno')->toContain('Nu', 'no');
|
|
});
|
|
|
|
test('passes arrays', function (): void {
|
|
expect([1, 2, 42])->toContain(42);
|
|
});
|
|
|
|
test('passes arrays with multiple needles', function (): void {
|
|
expect([1, 2, 42])->toContain(42, 2);
|
|
});
|
|
|
|
test('passes with array needles', function (): void {
|
|
expect([[1, 2, 3], 2, 42])->toContain(42, [1, 2, 3]);
|
|
});
|
|
|
|
test('failures', function (): void {
|
|
expect([1, 2, 42])->toContain(3);
|
|
})->throws(ExpectationFailedException::class);
|
|
|
|
test('failures with multiple needles (all failing)', function (): void {
|
|
expect([1, 2, 42])->toContain(3, 4);
|
|
})->throws(ExpectationFailedException::class);
|
|
|
|
test('failures with multiple needles (some failing)', function (): void {
|
|
expect([1, 2, 42])->toContain(1, 3, 4);
|
|
})->throws(ExpectationFailedException::class);
|
|
|
|
test('not failures', function (): void {
|
|
expect([1, 2, 42])->not->toContain(42);
|
|
})->throws(ExpectationFailedException::class);
|
|
|
|
test('not failures with multiple needles (all failing)', function (): void {
|
|
expect([1, 2, 42])->not->toContain(42, 2);
|
|
})->throws(ExpectationFailedException::class);
|
|
|
|
test('not failures with multiple needles (some failing)', function (): void {
|
|
expect([1, 2, 42])->not->toContain(42, 1);
|
|
})->throws(ExpectationFailedException::class);
|