8000 Merge branch '3.4' · hhamon/symfony@4cd4cb4 · GitHub
[go: up one dir, main page]

Skip to content

Commit 4cd4cb4

Browse files
committed
Merge branch '3.4'
* 3.4: fixed tests swiftmailer bridge is gone respect the API in FirewallContext map [TwigBundle] add back exception check Dont call count on non countable object Fix undefined variable $filesystem
2 parents 44509eb + e891d55 commit 4cd4cb4

File tree

5 files changed

+37
-13
lines changed

5 files changed

+37
-13
lines changed

src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
158158
// remove the assets of the bundles that no longer exist
159159
foreach (new \FilesystemIterator($bundlesDir) as $dir) {
160160
if (!in_array($dir, $validAssetDirs)) {
161-
$filesystem->remove($dir);
161+
$this->filesystem->remove($dir);
162162
}
163163
}
164164

src/Symfony/Bundle/SecurityBundle/Tests/Security/FirewallMapTest.php

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,15 @@
1212
namespace Symfony\Bundle\SecurityBundle\Tests\Security;
1313

1414
use PHPUnit\Framework\TestCase;
15+
use Symfony\Bundle\SecurityBundle\Security\FirewallConfig;
1516
use Symfony\Bundle\SecurityBundle\Security\FirewallContext;
1617
use Symfony\Bundle\SecurityBundle\Security\FirewallMap;
1718
use Symfony\Component\DependencyInjection\Container;
1819
use Symfony\Component\HttpFoundation\Request;
1920
use Symfony\Component\HttpFoundation\RequestMatcherInterface;
21+
use Symfony\Component\Security\Core\User\UserCheckerInterface;
22+
use Symfony\Component\Security\Http\Firewall\ExceptionListener;
23+
use Symfony\Component\Security\Http\Firewall\ListenerInterface;
2024

2125
class FirewallMapTest extends TestCase
2226
{
@@ -58,9 +62,15 @@ public function testGetListeners()
5862
$request = new Request();
5963

6064
$firewallContext = $this->getMockBuilder(FirewallContext::class)->disableOriginalConstructor()->getMock();
61-
$firewallContext->expects($this->once())->method('getConfig')->willReturn('CONFIG');
62-
$firewallContext->expects($this->once())->method('getListeners')->willReturn('LISTENERS');
63-
$firewallContext->expects($this->once())->method('getExceptionListener')->willReturn('EXCEPTION LISTENER');
65+
66+
$firewallConfig = new FirewallConfig('main', $this->getMockBuilder(UserCheckerInterface::class)->getMock());
67+
$firewallContext->expects($this->once())->method('getConfig')->willReturn($firewallConfig);
68+
69+
$listener = $this->getMockBuilder(ListenerInterface::class)->getMock();
70+
$firewallContext->expects($this->once())->method('getListeners')->willReturn(array($listener));
71+
72+
$exceptionListener = $this->getMockBuilder(ExceptionListener::class)->disableOriginalConstructor()->getMock();
73+
$firewallContext->expects($this->once())->method('getExceptionListener')->willReturn($exceptionListener);
6474

6575
$matcher = $this->getMockBuilder(RequestMatcherInterface::class)->getMock();
6676
$matcher->expects($this->once())
@@ -73,8 +83,8 @@ public function testGetListeners()
7383

7484
$firewallMap = new FirewallMap($container, array('security.firewall.map.context.foo' => $matcher));
7585

76-
$this->assertEquals(array('LISTENERS', 'EXCEPTION LISTENER'), $firewallMap->getListeners($request));
77-
$this->assertEquals('CONFIG', $firewallMap->getFirewallConfig($request));
86+
$this->assertEquals(array(array($listener), $exceptionListener), $firewallMap->getListeners($request));
87+
$this->assertEquals($firewallConfig, $firewallMap->getFirewallConfig($request));
7888
$this->assertEquals('security.firewall.map.context.foo', $request->attributes->get(self::ATTRIBUTE_FIREWALL_CONTEXT));
7989
}
8090
}

src/Symfony/Bundle/TwigBundle/Controller/ExceptionController.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ protected function findTemplate(Request $request, $format, $code, $showException
123123
// default to a generic HTML exception
124124
$request->setRequestFormat('html');
125125

126-
return sprintf('@Twig/Exception/%s.html.twig', $name);
126+
return sprintf('@Twig/Exception/%s.html.twig', $showException ? 'exception_full' : $name);
127127
}
128128

129129
// to be removed when the minimum required version of Twig is >= 3.0

src/Symfony/Bundle/TwigBundle/Tests/Controller/ExceptionControllerTest.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,20 @@ public function testFallbackToHtmlIfNoTemplateForRequestedFormat()
4848
$this->assertEquals('html', $request->getRequestFormat());
4949
}
5050

51+
public function testFallbackToHtmlWithFullExceptionIfNoTemplateForRequestedFormatAndExceptionsShouldBeShown()
52+
{
53+
$twig = $this->createTwigEnv(array('@Twig/Exception/exception_full.html.twig' => '<html></html>'));
54+
55+
$request = $this->createRequest('txt');
56+
$request->attributes->set('showException', true);
57+
$exception = FlattenException::create(new \Exception());
58+
$controller = new ExceptionController($twig, false);
59+
60+
$controller->showAction($request, $exception);
61+
62+
$this->assertEquals('html', $request->getRequestFormat());
63+
}
64+
5165
public function testResponseHasRequestedMimeType()
5266
{
5367
$twig = $this->createTwigEnv(array('@Twig/Exception/error.json.twig' => '{}'));

src/Symfony/Component/Translation/Dumper/IcuResFileDumper.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public function formatCatalogue(MessageCatalogue $messages, $domain, array $opti
5252

5353
$resOffset = $this->getPosition($data);
5454

55-
$data .= pack('v', count($messages))
55+
$data .= pack('v', count($messages->all($domain)))
5656
.$indexes
5757
.$this->writePadding($data)
5858
.$resources
@@ -63,11 +63,11 @@ public function formatCatalogue(MessageCatalogue $messages, $domain, array $opti
6363
$root = pack('V7',
6464
$resOffset + (2 << 28), // Resource Offset + Resource Type
6565
6, // Index length
66-
$keyTop, // Index keys top
67-
$bundleTop, // Index resources top
68-
$bundleTop, // Index bundle top
69-
count($messages), // Index max table length
70-
0 // Index attributes
66+
$keyTop, // Index keys top
67+
$bundleTop, // Index resources top
68+
$bundleTop, // Index bundle top
69+
count($messages->all($domain)), // Index max table length
70+
0 // Index attributes
7171
);
7272

7373
$header = pack('vC2v4C12@32',

0 commit comments

Comments
 (0)
0