Добавил проверку на доп поля респонса

master
Rinsvent 3 years ago
parent 8f266d18eb
commit ab6b26abdd
  1. 27
      tests/unit/Listener/FillTest.php

@ -2,20 +2,7 @@
namespace Rinsvent\RequestBundle\Tests\Listener; namespace Rinsvent\RequestBundle\Tests\Listener;
use Rinsvent\RequestBundle\Tests\unit\Listener\fixtures\FillTest\Controller;
use Rinsvent\RequestBundle\Tests\unit\Listener\fixtures\FillTest\HelloRequest;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Controller\ArgumentResolver;
use Symfony\Component\HttpKernel\Controller\ControllerResolver;
use Symfony\Component\HttpKernel\EventListener\RouterListener;
use Symfony\Component\HttpKernel\HttpKernel;
use Symfony\Component\Routing\Matcher\UrlMatcher;
use Symfony\Component\Routing\RequestContext;
use Symfony\Component\Routing\Route;
use Symfony\Component\Routing\RouteCollection;
use Rinsvent\RequestBundle\EventListener\RequestListener; use Rinsvent\RequestBundle\EventListener\RequestListener;
@ -42,6 +29,20 @@ class FillTest extends \Codeception\Test\Unit
]); ]);
$response = $this->tester->send($request); $response = $this->tester->send($request);
$this->assertEquals(200, $response->getStatusCode());
$this->assertEquals('Surname', $request->get(RequestListener::REQUEST_DATA)->surname); $this->assertEquals('Surname', $request->get(RequestListener::REQUEST_DATA)->surname);
$this->assertEquals('Hello igor', $response->getContent());
}
public function testFailRequestData()
{
$request = Request::create('/hello/igor', 'GET', [
'surname' => ''
]);
$response = $this->tester->send($request);
$this->assertEquals(400, $response->getStatusCode());
$this->assertEquals('{"errors":[{"message":"This value should not be blank.","path":"surname"}]}', $response->getContent());
} }
} }

Loading…
Cancel
Save