Merge branch '2.x' into 3.x

This commit is contained in:
Nuno Maduro
2024-06-10 23:04:34 +01:00
7 changed files with 48 additions and 9 deletions

View File

@ -467,6 +467,18 @@ final class Expectation
return $this;
}
/**
* Asserts that the value is a list.
*
* @return self<TValue>
*/
public function toBeList(string $message = ''): self
{
Assert::assertIsList($this->value, $message);
return $this;
}
/**
* Asserts that the value is of type bool.
*

View File

@ -6,7 +6,7 @@ namespace Pest;
function version(): string
{
return '3.0.0-dev-0007';
return '3.0.0-dev-0008';
}
function testDirectory(string $file = ''): string

View File

@ -6,5 +6,5 @@ use Illuminate\Foundation\Testing\TestCase as BaseTestCase;
abstract class TestCase extends BaseTestCase
{
use CreatesApplication;
//
}

View File

@ -1,5 +1,5 @@
Pest Testing Framework 3.0.0-dev-0007.
Pest Testing Framework 3.0.0-dev-0008.
USAGE: pest <file> [options]

View File

@ -1,3 +1,3 @@
Pest Testing Framework 3.0.0-dev-0007.
Pest Testing Framework 3.0.0-dev-0008.

View File

@ -523,6 +523,12 @@
✓ passes with strings
✓ failures
✓ failures with custom message
✓ not failures
PASS Tests\Features\Expect\toBeList
✓ pass
✓ failures
✓ failures with custom message
✓ not failures
PASS Tests\Features\Expect\toBeLowercase

View File

@ -0,0 +1,21 @@
<?php
use PHPUnit\Framework\ExpectationFailedException;
test('pass', function () {
expect([1, 2, 3])->toBeList();
expect(['a' => 1, 'b' => 2, 'c' => 3])->not->toBeList();
expect('1, 2, 3')->not->toBeList();
});
test('failures', function () {
expect(null)->toBeList();
})->throws(ExpectationFailedException::class);
test('failures with custom message', function () {
expect(null)->toBeList('oh no!');
})->throws(ExpectationFailedException::class, 'oh no!');
test('not failures', function () {
expect(['a', 'b', 'c'])->not->toBeList();
})->throws(ExpectationFailedException::class);