Guilhem Niot 6d995a6e03
Add php 8 support (#1745)
* Add php 8 support

* Ignore platform reqs

* Change php constraint

* Use vendor/bin/simple-phpunit directly

* Remove willdurand/hateoas-bundle when testing php8

* Merge 3.x

* Move to github actions

* Fix the tests

* Change ./phpunit permissions

* Update deprecations policy
2020-12-10 21:59:36 +01:00

54 lines
1.7 KiB
PHP

<?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 FOSRestTest extends WebTestCase
{
protected function setUp(): void
{
parent::setUp();
static::createClient([], ['HTTP_HOST' => 'api.example.com']);
}
public function testFOSRestAction()
{
$operation = $this->getOperation('/api/fosrest', 'post');
$parameters = $operation->getParameters();
$this->assertTrue($parameters->has('foo', 'query'));
$this->assertTrue($parameters->has('body', 'body'));
$body = $parameters->get('body', 'body')->getSchema()->getProperties();
$this->assertTrue($body->has('bar'));
$this->assertTrue($body->has('baz'));
$fooParameter = $parameters->get('foo', 'query');
$this->assertNotNull($fooParameter->getPattern());
$this->assertEquals('\d+', $fooParameter->getPattern());
$this->assertNull($fooParameter->getFormat());
$barParameter = $body->get('bar');
$this->assertNotNull($barParameter->getPattern());
$this->assertEquals('\d+', $barParameter->getPattern());
$this->assertNull($barParameter->getFormat());
$bazParameter = $body->get('baz');
$this->assertNotNull($bazParameter->getFormat());
$this->assertEquals('IsTrue', $bazParameter->getFormat());
$this->assertNull($bazParameter->getPattern());
// The _format path attribute should be removed
$this->assertFalse($parameters->has('_format', 'path'));
}
}