diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 4e1381e8..f6a94d92 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -8,14 +8,9 @@ jobs: strategy: matrix: os: [ubuntu-latest] # (macos-latest, windows-latest) 2.x-dev is under development - php: ['8.1'] + php: ['8.1', '8.2'] dependency-version: [prefer-lowest, prefer-stable] parallel: ['', '--parallel'] - exclude: - - php: 8.1 - os: macos-latest - - php: 8.1 - os: windows-latest name: PHP ${{ matrix.php }} - ${{ matrix.os }} - ${{ matrix.dependency-version }} - ${{ matrix.parallel }} diff --git a/src/Factories/TestCaseFactory.php b/src/Factories/TestCaseFactory.php index 77f71cf0..938b0d2b 100644 --- a/src/Factories/TestCaseFactory.php +++ b/src/Factories/TestCaseFactory.php @@ -186,7 +186,7 @@ final class TestCaseFactory use Pest\TestSuite as __PestTestSuite; $classAttributesCode - #[AllowDynamicProperties] + #[\AllowDynamicProperties] final class $className extends $baseClass implements $hasPrintableTestCaseClassFQN { $traitsCode diff --git a/src/Mixins/Expectation.php b/src/Mixins/Expectation.php index ace37cf9..d1020cae 100644 --- a/src/Mixins/Expectation.php +++ b/src/Mixins/Expectation.php @@ -714,7 +714,7 @@ final class Expectation * * @return Expectation */ - public function toMatchArray(iterable|object $array): Expectation + public function toMatchArray(iterable $array): Expectation { if (is_object($this->value) && method_exists($this->value, 'toArray')) { $valueAsArray = $this->value->toArray(); @@ -743,11 +743,11 @@ final class Expectation * Asserts that the value object matches a subset * of the properties of an given object. * - * @param iterable|object $object + * @param iterable $object * * @return Expectation */ - public function toMatchObject(iterable|object $object): Expectation + public function toMatchObject(iterable $object): Expectation { foreach ((array) $object as $property => $value) { if (!is_object($this->value) && !is_string($this->value)) { diff --git a/tests/Features/Expect/toMatchObject.php b/tests/Features/Expect/toMatchObject.php index fd2c358b..a4394e4c 100644 --- a/tests/Features/Expect/toMatchObject.php +++ b/tests/Features/Expect/toMatchObject.php @@ -17,6 +17,16 @@ test('pass', function () { ]); }); +test('pass with class', function () { + expect(new class() { + public $name = 'Nuno'; + public $email = 'enunomaduro@gmail.com'; + })->toMatchObject([ + 'name' => 'Nuno', + 'email' => 'enunomaduro@gmail.com', + ]); +}); + test('failures', function () { expect($this->user)->toMatchObject([ 'name' => 'Not the same name',