2017-06-25 15:40:07 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/*
|
|
|
|
* This file is part of the NelmioApiDocBundle package.
|
|
|
|
*
|
|
|
|
* (c) Nelmio
|
|
|
|
*
|
|
|
|
* For the full copyright and license information, please view the LICENSE
|
|
|
|
* file that was distributed with this source code.
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace Nelmio\ApiDocBundle\Tests\Functional;
|
|
|
|
|
|
|
|
class JMSFunctionalTest extends WebTestCase
|
|
|
|
{
|
|
|
|
public function testModelDocumentation()
|
|
|
|
{
|
|
|
|
$this->assertEquals([
|
|
|
|
'type' => 'object',
|
|
|
|
'properties' => [
|
2017-12-03 20:30:44 +02:00
|
|
|
'id' => [
|
|
|
|
'type' => 'integer',
|
|
|
|
'description' => "User id",
|
|
|
|
'readOnly' => true,
|
|
|
|
'title' => "userid",
|
|
|
|
'example' => 1,
|
|
|
|
],
|
|
|
|
'email' => [
|
|
|
|
'type' => 'string',
|
|
|
|
'readOnly' => false,
|
|
|
|
],
|
2017-06-25 15:40:07 +02:00
|
|
|
'roles' => [
|
|
|
|
'type' => 'array',
|
|
|
|
'items' => ['type' => 'string'],
|
|
|
|
],
|
2017-12-03 20:30:44 +02:00
|
|
|
'friendsNumber' => [
|
|
|
|
'type' => 'string',
|
|
|
|
],
|
2017-06-25 15:40:07 +02:00
|
|
|
'friends' => [
|
|
|
|
'type' => 'array',
|
|
|
|
'items' => [
|
|
|
|
'$ref' => '#/definitions/User',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
'best_friend' => [
|
|
|
|
'$ref' => '#/definitions/User',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
], $this->getModel('JMSUser')->toArray());
|
|
|
|
}
|
|
|
|
|
2017-12-07 14:00:40 +08:00
|
|
|
public function testModelComplexDocumentation()
|
|
|
|
{
|
|
|
|
$this->assertEquals([
|
|
|
|
'type' => 'object',
|
|
|
|
'properties' => [
|
|
|
|
'id' => ['type' => 'integer'],
|
|
|
|
'user' => ['$ref' => '#/definitions/JMSUser2'],
|
|
|
|
'name' => ['type' => 'string']
|
|
|
|
],
|
|
|
|
], $this->getModel('JMSComplex')->toArray());
|
|
|
|
|
|
|
|
$this->assertEquals([
|
|
|
|
'type' => 'object',
|
|
|
|
'properties' => [
|
|
|
|
'id' => [
|
|
|
|
'type' => 'integer',
|
|
|
|
'title' => 'userid',
|
|
|
|
'description' => 'User id',
|
|
|
|
'readOnly' => true,
|
|
|
|
'example' => '1',
|
|
|
|
],
|
|
|
|
],
|
|
|
|
], $this->getModel('JMSUser2')->toArray());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-06-25 15:40:07 +02:00
|
|
|
protected static function createKernel(array $options = array())
|
|
|
|
{
|
|
|
|
return new TestKernel(true);
|
|
|
|
}
|
|
|
|
}
|