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()
|
|
|
|
{
|
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
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testParser()
|
|
|
|
{
|
|
|
|
$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
|
|
|
|
2015-04-28 23:29:18 +02:00
|
|
|
$item = array('class' => DunglasApiParser::OUT_PREFIX.':Nelmio\ApiDocBundle\Tests\Fixtures\Model\Popo');
|
2015-03-15 23:48:57 +01:00
|
|
|
|
|
|
|
$expected = array (
|
|
|
|
'foo' =>
|
|
|
|
array (
|
|
|
|
'required' => false,
|
|
|
|
'description' => '',
|
|
|
|
'readonly' => false,
|
2015-04-28 23:29:18 +02:00
|
|
|
'dataType' => DataTypes::STRING,
|
2015-03-15 23:48:57 +01:00
|
|
|
),
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->assertTrue($parser->supports($item));
|
|
|
|
$this->assertEquals($expected, $parser->parse($item));
|
|
|
|
}
|
|
|
|
}
|