mirror of
https://github.com/pestphp/pest.git
synced 2026-03-06 15:57:21 +01:00
feat(toContainEqual): adds method name
This commit is contained in:
@ -197,18 +197,21 @@ final class Expectation
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Asserts that $needle equals an element of the value.
|
* Asserts that $needle equal an element of the value.
|
||||||
*
|
*
|
||||||
* @return self<TValue>
|
* @return self<TValue>
|
||||||
*/
|
*/
|
||||||
public function toContainEquals(mixed ...$needles): self
|
public function toContainEqual(mixed ...$needles): self
|
||||||
{
|
{
|
||||||
foreach ($needles as $needle) {
|
|
||||||
if (! is_iterable($this->value)) {
|
if (! is_iterable($this->value)) {
|
||||||
InvalidExpectationValue::expected('iterable');
|
InvalidExpectationValue::expected('iterable');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach ($needles as $needle) {
|
||||||
Assert::assertContainsEquals($needle, $this->value);
|
Assert::assertContainsEquals($needle, $this->value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -4,33 +4,33 @@ use PHPUnit\Framework\ExpectationFailedException;
|
|||||||
|
|
||||||
|
|
||||||
test('passes arrays', function () {
|
test('passes arrays', function () {
|
||||||
expect([1, 2, 42])->toContainEquals('42');
|
expect([1, 2, 42])->toContainEqual('42');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('passes arrays with multiple needles', function () {
|
test('passes arrays with multiple needles', function () {
|
||||||
expect([1, 2, 42])->toContainEquals('42', '2');
|
expect([1, 2, 42])->toContainEqual('42', '2');
|
||||||
});
|
});
|
||||||
|
|
||||||
test('failures', function () {
|
test('failures', function () {
|
||||||
expect([1, 2, 42])->toContainEquals('3');
|
expect([1, 2, 42])->toContainEqual('3');
|
||||||
})->throws(ExpectationFailedException::class);
|
})->throws(ExpectationFailedException::class);
|
||||||
|
|
||||||
test('failures with multiple needles (all failing)', function () {
|
test('failures with multiple needles (all failing)', function () {
|
||||||
expect([1, 2, 42])->toContainEquals('3', '4');
|
expect([1, 2, 42])->toContainEqual('3', '4');
|
||||||
})->throws(ExpectationFailedException::class);
|
})->throws(ExpectationFailedException::class);
|
||||||
|
|
||||||
test('failures with multiple needles (some failing)', function () {
|
test('failures with multiple needles (some failing)', function () {
|
||||||
expect([1, 2, 42])->toContainEquals('1', '3', '4');
|
expect([1, 2, 42])->toContainEqual('1', '3', '4');
|
||||||
})->throws(ExpectationFailedException::class);
|
})->throws(ExpectationFailedException::class);
|
||||||
|
|
||||||
test('not failures', function () {
|
test('not failures', function () {
|
||||||
expect([1, 2, 42])->not->toContainEquals('42');
|
expect([1, 2, 42])->not->toContainEqual('42');
|
||||||
})->throws(ExpectationFailedException::class);
|
})->throws(ExpectationFailedException::class);
|
||||||
|
|
||||||
test('not failures with multiple needles (all failing)', function () {
|
test('not failures with multiple needles (all failing)', function () {
|
||||||
expect([1, 2, 42])->not->toContainEquals('42', '2');
|
expect([1, 2, 42])->not->toContainEqual('42', '2');
|
||||||
})->throws(ExpectationFailedException::class);
|
})->throws(ExpectationFailedException::class);
|
||||||
|
|
||||||
test('not failures with multiple needles (some failing)', function () {
|
test('not failures with multiple needles (some failing)', function () {
|
||||||
expect([1, 2, 42])->not->toContainEquals('42', '1');
|
expect([1, 2, 42])->not->toContainEqual('42', '1');
|
||||||
})->throws(ExpectationFailedException::class);
|
})->throws(ExpectationFailedException::class);
|
||||||
Reference in New Issue
Block a user