NelmioApiDocBundle/Tests/Parser/DunglasApiParserTest.php

52 lines
1.3 KiB
PHP
Raw Normal View History

2015-03-15 23:48:57 +01:00
<?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;
2015-04-28 23:29:18 +02:00
use Nelmio\ApiDocBundle\DataTypes;
use Nelmio\ApiDocBundle\Parser\DunglasApiParser;
2015-03-15 23:48:57 +01:00
use Nelmio\ApiDocBundle\Tests\WebTestCase;
/**
* @author Kévin Dunglas <dunglas@gmail.com>
*/
2015-04-28 23:29:18 +02:00
class DunglasApiParserTest extends WebTestCase
2015-03-15 23:48:57 +01:00
{
protected function setUp(): void
2015-03-15 23:48:57 +01:00
{
2015-04-28 23:29:18 +02:00
if (!class_exists('Dunglas\ApiBundle\DunglasApiBundle')) {
2015-03-15 23:48:57 +01:00
$this->markTestSkipped(
2015-04-28 23:29:18 +02:00
'DunglasApiBundle is not available.'
2015-03-15 23:48:57 +01:00
);
}
}
2024-10-01 15:54:04 +03:00
public function testParser(): void
2015-03-15 23:48:57 +01:00
{
$container = $this->getContainer();
2015-04-28 23:29:18 +02:00
$parser = $container->get('nelmio_api_doc.parser.dunglas_api_parser');
2015-03-15 23:48:57 +01:00
2024-10-01 15:54:04 +03:00
$item = ['class' => DunglasApiParser::OUT_PREFIX . ':Nelmio\ApiDocBundle\Tests\Fixtures\Model\Popo'];
$expected = [
'foo' => [
'required' => false,
'description' => '',
'readonly' => false,
'dataType' => DataTypes::STRING,
],
];
2015-03-15 23:48:57 +01:00
$this->assertTrue($parser->supports($item));
$this->assertEquals($expected, $parser->parse($item));
}
}