Skip to content

Commit

Permalink
[9.x] Remove deprecation warnings in test output (#45998)
Browse files Browse the repository at this point in the history
* Add return type

* Remove test warnings

* Re-adds removed code

---------

Co-authored-by: Nuno Maduro <[email protected]>
  • Loading branch information
driesvints and nunomaduro authored Feb 7, 2023
1 parent 1f60081 commit b32fa54
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 9 deletions.
10 changes: 8 additions & 2 deletions tests/Cache/CacheArrayStoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions tests/Database/DatabaseQueryBuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2024,15 +2024,15 @@ 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']);
}

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]);
}
Expand Down
5 changes: 3 additions & 2 deletions tests/Events/EventsDispatcherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Illuminate\Tests\Events;

use Error;
use Exception;
use Illuminate\Container\Container;
use Illuminate\Events\Dispatcher;
Expand Down Expand Up @@ -574,8 +575,8 @@ public function testInvokeIsCalled()
// 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()');
$this->expectException(Error::class);
$this->expectExceptionMessage('Call to undefined method '.TestListenerLean::class.'::__invoke()');
$d->dispatch('myEvent', 'somePayload');

unset($_SERVER['__event.test']);
Expand Down
4 changes: 2 additions & 2 deletions tests/Support/LotteryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Validation/ValidationValidatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1651,7 +1651,7 @@ public function prohibitedRulesData()
{
$emptyCountable = new class implements Countable
{
public function count()
public function count(): int
{
return 0;
}
Expand Down

0 comments on commit b32fa54

Please sign in to comment.