Skip to content

Commit

Permalink
add array in array test
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskapp committed Feb 15, 2025
1 parent f155f88 commit 3280854
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/Parser/Popo/ArrayInArray.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

namespace PSX\Schema\Tests\Parser\Popo;

class ArrayInArray
{
/**
* @var array<array<float>>
*/
public array $items;
}
20 changes: 20 additions & 0 deletions tests/Parser/PopoTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,12 @@
namespace PSX\Schema\Tests\Parser;

use PSX\Schema\Parser;
use PSX\Schema\Tests\Parser\Popo\ArrayInArray;
use PSX\Schema\Tests\Parser\Popo\Form_Container;
use PSX\Schema\Tests\Parser\Popo\Form_Element;
use PSX\Schema\Type\ArrayPropertyType;
use PSX\Schema\Type\NumberPropertyType;
use PSX\Schema\Type\StructDefinitionType;

/**
* PopoTest
Expand All @@ -48,4 +52,20 @@ public function testDiscriminator()

$this->assertDiscriminator($schema);
}

public function testArrayInArray()
{
$parser = new Parser\Popo();
$schema = $parser->parse(ArrayInArray::class);

$object = $schema->getDefinitions()->getType($schema->getRoot());
$this->assertInstanceOf(StructDefinitionType::class, $object);

$items = $object->getProperty('items');
$this->assertInstanceOf(ArrayPropertyType::class, $items);

$array = $items->getSchema();
$this->assertInstanceOf(ArrayPropertyType::class, $array);
$this->assertInstanceOf(NumberPropertyType::class, $array->getSchema());
}
}

0 comments on commit 3280854

Please sign in to comment.