-
-
Notifications
You must be signed in to change notification settings - Fork 82
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: nullabe arrays of decoded ids were retrieved as [null] (#211)
* fix: nullabe arrays of decoded ids were retrieved as [null] * test: add covers attribute --------- Co-authored-by: Mohammad Alavi <[email protected]>
- Loading branch information
1 parent
63d5b5d
commit d6658de
Showing
2 changed files
with
41 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace Apiato\Core\Tests\Unit\Traits; | ||
|
||
use Apiato\Core\Tests\Unit\UnitTestCase; | ||
use Apiato\Core\Traits\HashIdTrait; | ||
use PHPUnit\Framework\Attributes\CoversClass; | ||
use ReflectionClass; | ||
|
||
#[CoversClass(HashIdTrait::class)] | ||
class HashIdTraitTest extends UnitTestCase | ||
{ | ||
private $trait; | ||
|
||
public function setUp(): void | ||
{ | ||
parent::setUp(); | ||
|
||
$this->trait = new class { | ||
use HashIdTrait; | ||
}; | ||
} | ||
|
||
public function testProcessFieldShouldNotWrapANullInAnArray(): void | ||
{ | ||
$data = null; | ||
$keysTodo = ['*']; | ||
$currentFieldName = null; | ||
$reflection = new ReflectionClass($this->trait); | ||
$method = $reflection->getMethod('processField'); | ||
|
||
$result = $method->invoke($this->trait, $data, $keysTodo, $currentFieldName); | ||
|
||
$this->assertNull($result); | ||
} | ||
} |