Skip to content

Commit

Permalink
Added unserialization test
Browse files Browse the repository at this point in the history
  • Loading branch information
sorinsarca committed Jan 7, 2025
1 parent 3181c5c commit 8c8243b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
10 changes: 10 additions & 0 deletions tests/PHP80/UnserializeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,16 @@ public function testSumSecurityWrongSecret()
$f = $this->u("sum.security", "other-secret");
}

public function testAnonymousClassComplex()
{
$u = $this->u("anon.complex");
$this->assertInstanceOf(Objects\Entity::class, $u[0]);
$this->assertInstanceOf(Objects\Entity::class, $u[1]);

$this->assertNull($u[0]->parent);
$this->assertEquals($u[0], $u[1]->parent);
}

private function u(string $name, SecurityProviderInterface|string|null $security = null): mixed
{
$data = file_get_contents(__DIR__ . "/v4/{$name}.bin");
Expand Down
6 changes: 6 additions & 0 deletions tests/PHP80/v4/anon.complex.bin
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
a:2:{i:0;O:16:"Opis\Closure\Box":2:{i:0;i:4;i:1;a:2:{i:0;a:4:{s:3:"key";s:32:"3f8961a5672a610d4e034a9932cf59d8";s:6:"header";s:34:"namespace Opis\Closure\Test\PHP80;";s:4:"body";s:205:"class opisanonymous@classname extends Objects\Entity {
public function __construct(?Objects\Entity $parent)
{
$this->parent = $parent;
}
}";s:2:"ns";s:23:"Opis\Closure\Test\PHP80";}i:1;a:2:{i:0;N;i:1;a:0:{}}}}i:1;O:16:"Opis\Closure\Box":2:{i:0;i:4;i:1;a:2:{i:0;R:5;i:1;a:2:{i:0;r:2;i:1;a:0:{}}}}}

0 comments on commit 8c8243b

Please sign in to comment.