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',
|
2017-12-17 10:44:07 +01:00
|
|
|
'description' => 'User id',
|
2017-12-03 20:30:44 +02:00
|
|
|
'readOnly' => true,
|
2017-12-17 10:44:07 +01:00
|
|
|
'title' => 'userid',
|
2017-12-03 20:30:44 +02:00
|
|
|
'example' => 1,
|
|
|
|
],
|
2017-12-17 17:58:41 +02:00
|
|
|
'daysOnline' => [
|
|
|
|
'type' => 'integer',
|
|
|
|
'default' => 0,
|
|
|
|
],
|
2017-12-03 20:30:44 +02:00
|
|
|
'email' => [
|
|
|
|
'type' => 'string',
|
|
|
|
'readOnly' => false,
|
|
|
|
],
|
2017-06-25 15:40:07 +02:00
|
|
|
'roles' => [
|
|
|
|
'type' => 'array',
|
2017-12-17 10:44:07 +01:00
|
|
|
'title' => 'roles',
|
2017-12-15 17:39:18 +01:00
|
|
|
'example' => '["ADMIN","SUPERUSER"]',
|
2017-06-25 15:40:07 +02:00
|
|
|
'items' => ['type' => 'string'],
|
2017-12-17 17:58:41 +02:00
|
|
|
'default' => ['user'],
|
|
|
|
'description' => 'Roles list',
|
2017-06-25 15:40:07 +02:00
|
|
|
],
|
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',
|
|
|
|
],
|
2017-12-17 17:58:41 +02:00
|
|
|
'status' => [
|
|
|
|
'type' => 'string',
|
2017-12-19 08:56:00 +01:00
|
|
|
'title' => 'Whether this user is enabled or disabled.',
|
|
|
|
'description' => 'Only enabled users may be used in actions.',
|
2017-12-18 21:07:44 +01:00
|
|
|
'enum' => ['disabled', 'enabled'],
|
2017-12-17 17:58:41 +02:00
|
|
|
],
|
2018-01-11 12:26:59 +01:00
|
|
|
'updated_at' => [
|
|
|
|
'type' => 'date',
|
|
|
|
],
|
2017-06-25 15:40:07 +02:00
|
|
|
],
|
|
|
|
], $this->getModel('JMSUser')->toArray());
|
|
|
|
}
|
|
|
|
|
2017-12-07 14:00:40 +08:00
|
|
|
public function testModelComplexDocumentation()
|
|
|
|
{
|
|
|
|
$this->assertEquals([
|
|
|
|
'type' => 'object',
|
|
|
|
'properties' => [
|
2017-12-21 17:17:36 +01:00
|
|
|
'id' => ['type' => 'integer'],
|
2017-12-07 14:00:40 +08:00
|
|
|
'user' => ['$ref' => '#/definitions/JMSUser2'],
|
2018-01-04 11:34:23 +01:00
|
|
|
'name' => ['type' => 'string'],
|
2017-12-07 14:00:40 +08:00
|
|
|
],
|
|
|
|
], $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-12-21 17:17:36 +01:00
|
|
|
}
|
2017-12-07 14:00:40 +08:00
|
|
|
|
2017-12-09 21:31:56 +08:00
|
|
|
public function testYamlConfig()
|
|
|
|
{
|
|
|
|
$this->assertEquals([
|
|
|
|
'type' => 'object',
|
|
|
|
'properties' => [
|
|
|
|
'id' => [
|
|
|
|
'type' => 'integer',
|
|
|
|
],
|
|
|
|
'email' => [
|
2017-12-17 10:44:07 +01:00
|
|
|
'type' => 'string',
|
2017-12-09 21:31:56 +08:00
|
|
|
],
|
|
|
|
],
|
|
|
|
], $this->getModel('VirtualProperty')->toArray());
|
|
|
|
}
|
|
|
|
|
2017-12-22 17:42:18 +00:00
|
|
|
protected static function createKernel(array $options = [])
|
2017-06-25 15:40:07 +02:00
|
|
|
{
|
|
|
|
return new TestKernel(true);
|
|
|
|
}
|
|
|
|
}
|