NelmioApiDocBundle/Tests/Parser/DunglasApiParserTest.php
2024-10-01 15:54:04 +03:00

52 lines
1.3 KiB
PHP

<?php
/*
* This file is part of the NelmioApiDocBundle.
*
* (c) Nelmio <hello@nelm.io>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace NelmioApiDocBundle\Tests\Parser;
use Nelmio\ApiDocBundle\DataTypes;
use Nelmio\ApiDocBundle\Parser\DunglasApiParser;
use Nelmio\ApiDocBundle\Tests\WebTestCase;
/**
* @author Kévin Dunglas <dunglas@gmail.com>
*/
class DunglasApiParserTest extends WebTestCase
{
protected function setUp(): void
{
if (!class_exists('Dunglas\ApiBundle\DunglasApiBundle')) {
$this->markTestSkipped(
'DunglasApiBundle is not available.'
);
}
}
public function testParser(): void
{
$container = $this->getContainer();
$parser = $container->get('nelmio_api_doc.parser.dunglas_api_parser');
$item = ['class' => DunglasApiParser::OUT_PREFIX . ':Nelmio\ApiDocBundle\Tests\Fixtures\Model\Popo'];
$expected = [
'foo' => [
'required' => false,
'description' => '',
'readonly' => false,
'dataType' => DataTypes::STRING,
],
];
$this->assertTrue($parser->supports($item));
$this->assertEquals($expected, $parser->parse($item));
}
}