Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion EventListener/ViewResponseListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ public static function getSubscribedEvents(): array
{
return [
KernelEvents::CONTROLLER => 'onKernelController',
KernelEvents::VIEW => ['onKernelView', -128],
KernelEvents::VIEW => ['onKernelView', 30],
];
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,26 @@ public function cpostAction(Request $request)
}

/**
* @Get("/articles.{_format}", name="get_article", defaults={"_format": "html"})
* @Get("/articles.{_format}", name="get_articles", defaults={"_format": "html"})
*
* @View()
*/
#[Get(path: '/articles.{_format}', name: 'get_article', defaults: ['_format' => 'html'])]
#[Get(path: '/articles.{_format}', name: 'get_articles', defaults: ['_format' => 'html'])]
#[View]
public function cgetAction()
{
return $this->view();
}

/**
* @Get("/articles/{id}.{_format}", name="get_article", defaults={"_format": "html"})
*
* @View()
*/
#[Get(path: '/articles/{id}.{_format}', name: 'get_article', defaults: ['_format' => 'html'])]
#[View]
public function cgetSingleAction(int $id)
{
return ['id' => $id];
}
}
8 changes: 8 additions & 0 deletions Tests/Functional/ViewResponseListenerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,12 @@ public function testRedirect()
$this->assertSame('http://localhost/hello/Post%201', $client->getResponse()->headers->get('location'));
$this->assertStringNotContainsString('fooo', $client->getResponse()->getContent());
}

public function testControllerReturnsView()
{
$client = $this->createClient(['test_case' => 'ViewResponseListener']);
$client->request('GET', '/articles.json');

$this->assertTrue($client->getResponse()->isSuccessful());
}
}
1 change: 1 addition & 0 deletions Tests/Functional/app/ViewResponseListener/bundles.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

$bundles = [
new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new \Symfony\Bundle\TwigBundle\TwigBundle(),
new \FOS\RestBundle\FOSRestBundle(),
new \FOS\RestBundle\Tests\Functional\Bundle\TestBundle\TestBundle(),
];
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
xsi:noNamespaceSchemaLocation=".phpunit/phpunit.xsd"
>
<php>
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[self]=104&amp;max[indirect]=243"/>
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[self]=120&amp;max[indirect]=243"/>
<env name="SYMFONY_PHPUNIT_VERSION" value="9.6"/>
<ini name="error_reporting" value="-1"/>
<server name="SHELL_VERBOSITY" value="-1"/>
Expand Down