-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Using Accessable::has() with object or array is deprecated
- Loading branch information
Showing
7 changed files
with
133 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
// SPDX-FileCopyrightText: 2015-2023 Artur Weigandt https://wlabs.de/kontakt | ||
// | ||
// SPDX-License-Identifier: GPL-3.0-or-later | ||
|
||
namespace Art4\JsonApiClient\Tests\Unit\Helper; | ||
|
||
use Art4\JsonApiClient\Helper\AccessableTrait; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class AccessableTraitTest extends TestCase | ||
{ | ||
public function testHasWithObjectAsKeyTriggersException(): void | ||
{ | ||
$resource = $this->getMockForTrait(AccessableTrait::class); | ||
|
||
// PHPUnit 10 compatible way to test trigger_error(). | ||
set_error_handler( | ||
function ($errno, $errstr): bool { | ||
$this->assertStringEndsWith( | ||
'::has(): Providing Argument #1 ($key) as object is deprecated since 1.2.0, please provide as int|string|Art4\JsonApiClient\Helper\AccessKey instead.', | ||
$errstr | ||
); | ||
|
||
restore_error_handler(); | ||
return true; | ||
}, | ||
E_USER_DEPRECATED | ||
); | ||
|
||
$resource->has(new \stdClass()); | ||
Check failure on line 34 in tests/Unit/Helper/AccessableTraitTest.php
|
||
} | ||
|
||
public function testHasWithArrayAsKeyTriggersException(): void | ||
{ | ||
$resource = $this->getMockForTrait(AccessableTrait::class); | ||
|
||
// PHPUnit 10 compatible way to test trigger_error(). | ||
set_error_handler( | ||
function ($errno, $errstr): bool { | ||
$this->assertStringEndsWith( | ||
'::has(): Providing Argument #1 ($key) as array is deprecated since 1.2.0, please provide as int|string|Art4\JsonApiClient\Helper\AccessKey instead.', | ||
$errstr | ||
); | ||
|
||
restore_error_handler(); | ||
return true; | ||
}, | ||
E_USER_DEPRECATED | ||
); | ||
|
||
$resource->has([]); | ||
Check failure on line 55 in tests/Unit/Helper/AccessableTraitTest.php
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters