From 5f20ebfa225a7a190e1e0bfa65d4d75aa65837fd Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Tue, 7 Feb 2023 13:30:42 +0100 Subject: [PATCH 1/3] Add return type --- tests/Validation/ValidationValidatorTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Validation/ValidationValidatorTest.php b/tests/Validation/ValidationValidatorTest.php index d53b2899bc67..b199ac52ee5c 100755 --- a/tests/Validation/ValidationValidatorTest.php +++ b/tests/Validation/ValidationValidatorTest.php @@ -1651,7 +1651,7 @@ public function prohibitedRulesData() { $emptyCountable = new class implements Countable { - public function count() + public function count(): int { return 0; } From 381afac18c087f93507f2f6721a3ff24c0c5e542 Mon Sep 17 00:00:00 2001 From: Dries Vints Date: Tue, 7 Feb 2023 13:59:10 +0100 Subject: [PATCH 2/3] Remove test warnings --- tests/Cache/CacheArrayStoreTest.php | 10 ++++++++-- tests/Database/DatabaseQueryBuilderTest.php | 4 ++-- tests/Events/EventsDispatcherTest.php | 7 ------- tests/Support/LotteryTest.php | 4 ++-- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/tests/Cache/CacheArrayStoreTest.php b/tests/Cache/CacheArrayStoreTest.php index 2fcd5a4d57c3..db7e6e84e58a 100755 --- a/tests/Cache/CacheArrayStoreTest.php +++ b/tests/Cache/CacheArrayStoreTest.php @@ -248,7 +248,10 @@ public function testValuesAreNotStoredByReference() $store->put('object', $object, 10); $object->bar = true; - $this->assertObjectNotHasAttribute('bar', $store->get('object')); + $retrievedObject = $store->get('object'); + + $this->assertTrue($retrievedObject->foo); + $this->assertFalse(property_exists($retrievedObject, 'bar')); } public function testValuesAreStoredByReferenceIfSerializationIsDisabled() @@ -260,7 +263,10 @@ public function testValuesAreStoredByReferenceIfSerializationIsDisabled() $store->put('object', $object, 10); $object->bar = true; - $this->assertObjectHasAttribute('bar', $store->get('object')); + $retrievedObject = $store->get('object'); + + $this->assertTrue($retrievedObject->foo); + $this->assertTrue($retrievedObject->bar); } public function testReleasingLockAfterAlreadyForceReleasedByAnotherOwnerFails() diff --git a/tests/Database/DatabaseQueryBuilderTest.php b/tests/Database/DatabaseQueryBuilderTest.php index da9af8d363b0..a8e9378ab26e 100755 --- a/tests/Database/DatabaseQueryBuilderTest.php +++ b/tests/Database/DatabaseQueryBuilderTest.php @@ -2024,7 +2024,7 @@ public function testWhereNot() public function testIncrementManyArgumentValidation1() { $this->expectException(InvalidArgumentException::class); - $this->expectErrorMessage('Non-numeric value passed as increment amount for column: \'col\'.'); + $this->expectExceptionMessage('Non-numeric value passed as increment amount for column: \'col\'.'); $builder = $this->getBuilder(); $builder->from('users')->incrementEach(['col' => 'a']); } @@ -2032,7 +2032,7 @@ public function testIncrementManyArgumentValidation1() public function testIncrementManyArgumentValidation2() { $this->expectException(InvalidArgumentException::class); - $this->expectErrorMessage('Non-associative array passed to incrementEach method.'); + $this->expectExceptionMessage('Non-associative array passed to incrementEach method.'); $builder = $this->getBuilder(); $builder->from('users')->incrementEach([11 => 11]); } diff --git a/tests/Events/EventsDispatcherTest.php b/tests/Events/EventsDispatcherTest.php index 22670f370f46..b7939cf6e08b 100755 --- a/tests/Events/EventsDispatcherTest.php +++ b/tests/Events/EventsDispatcherTest.php @@ -571,13 +571,6 @@ public function testInvokeIsCalled() $d->dispatch('myEvent', 'somePayload'); $this->assertEquals(['__construct', '__invoke_somePayload'], $_SERVER['__event.test']); - // It throws an "Error" when there is no method to be called. - $d = new Dispatcher; - $d->listen('myEvent', TestListenerLean::class); - $this->expectError(); - $this->expectErrorMessage('Call to undefined method '.TestListenerLean::class.'::__invoke()'); - $d->dispatch('myEvent', 'somePayload'); - unset($_SERVER['__event.test']); } } diff --git a/tests/Support/LotteryTest.php b/tests/Support/LotteryTest.php index a4dbe451fcdb..7dc3a31d856f 100644 --- a/tests/Support/LotteryTest.php +++ b/tests/Support/LotteryTest.php @@ -142,14 +142,14 @@ public function testItCanHandleMissingSequenceItems() $this->assertSame('winner', $result); $this->expectException(RuntimeException::class); - $this->expectErrorMessage('Missing key in sequence.'); + $this->expectExceptionMessage('Missing key in sequence.'); Lottery::odds(1, 10000)->winner(fn () => 'winner')->loser(fn () => 'loser')->choose(); } public function testItThrowsForFloatsOverOne() { $this->expectException(RuntimeException::class); - $this->expectErrorMessage('Float must not be greater than 1.'); + $this->expectExceptionMessage('Float must not be greater than 1.'); new Lottery(1.1); } From 678bd8306301b76daff7ecb1efaf4d71c0226617 Mon Sep 17 00:00:00 2001 From: Nuno Maduro Date: Tue, 7 Feb 2023 14:14:20 +0000 Subject: [PATCH 3/3] Re-adds removed code --- tests/Events/EventsDispatcherTest.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/Events/EventsDispatcherTest.php b/tests/Events/EventsDispatcherTest.php index b7939cf6e08b..517c47f9e8f2 100755 --- a/tests/Events/EventsDispatcherTest.php +++ b/tests/Events/EventsDispatcherTest.php @@ -2,6 +2,7 @@ namespace Illuminate\Tests\Events; +use Error; use Exception; use Illuminate\Container\Container; use Illuminate\Events\Dispatcher; @@ -571,6 +572,13 @@ public function testInvokeIsCalled() $d->dispatch('myEvent', 'somePayload'); $this->assertEquals(['__construct', '__invoke_somePayload'], $_SERVER['__event.test']); + // It throws an "Error" when there is no method to be called. + $d = new Dispatcher; + $d->listen('myEvent', TestListenerLean::class); + $this->expectException(Error::class); + $this->expectExceptionMessage('Call to undefined method '.TestListenerLean::class.'::__invoke()'); + $d->dispatch('myEvent', 'somePayload'); + unset($_SERVER['__event.test']); } }