8000 [FrameworkBundle] Add test showcasing issue #27212 by Majkl578 · Pull Request #27213 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[FrameworkBundle] Add test showcasing issue #27212 #27213

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
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
Add failing test for #27212
  • Loading branch information
Michael Moravec committed May 9, 2018
commit f2070b58f4e79d19904a3243f2bde331b229059e
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\Controller;

use Symfony\Component\DependencyInjection\ContainerAwareInterface;
use Symfony\Component\DependencyInjection\ContainerAwareTrait;

class NoKernelResponseInvocationOnExceptionController implements ContainerAwareInterface
{
use ContainerAwareTrait;

public function indexAction()
{
throw new \RuntimeException();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,7 @@ fragment_inlined:
array_controller:
path: /array_controller
defaults: { _controller: [ArrayController, someAction] }

no_kernel_response_invocation:
path: /no_kernel_response_invocation
defaults: { _controller: TestBundle:NoKernelResponseInvocationOnException:index }
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

declare(strict_types=1);

namespace Symfony\Bundle\FrameworkBundle\Tests\Functional;

use Symfony\Component\HttpKernel\KernelEvents;

class NoKernelResponseInvocationOnExceptionTest extends WebTestCase
{
public function testContainerCompilationInDebug()
{
$client = $this->createClient(
array('test_case' => 'NoKernelResponseInvocationOnException', 'root_config' => 'config.yml')
);

$dispatcher = $client->getContainer()->get('event_dispatcher');

$propagated = false;
$invocationCount = 0;
$dispatcher->addListener(KernelEvents::RESPONSE, function () use (&$invocationCount) : void {
$invocationCount++;
});

try {
$client->request('GET', 'https://localhost/no_kernel_response_invocation');
} catch (\RuntimeException $e) {
$propagated = true;
}

$this->assertTrue($propagated, 'Exception should not be caught.');
$this->assertSame(0, $invocationCount, 'Exception should not be converted into response.');
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?php

/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

use Symfony\Bundle\FrameworkBundle\Tests\Functional\Bundle\TestBundle\TestBundle;
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;

return array(
new FrameworkBundle(),
new TestBundle(),
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
imports:
- { resource: ../config/default.yml }
- { resource: ./../config/default.yml }

framework:
templating:
enabled: false
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
_sessiontest_bundle:
resource: '@TestBundle/Resources/config/routing.yml'
0