Skip to content

Commit cb02b9f

Browse files
authored
Merge pull request #134 from symfony-cmf/sf-33
Added WebServerBundle support
2 parents 2f76914 + 66dd91d commit cb02b9f

File tree

4 files changed

+91
-51
lines changed

4 files changed

+91
-51
lines changed

resources/web/app.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony CMF package.
5+
*
6+
* (c) 2011-2017 Symfony CMF
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
use Symfony\Component\HttpFoundation\Request;
13+
use Symfony\Component\Debug\Debug;
14+
15+
require_once __DIR__.'/../../bootstrap/bootstrap.php';
16+
17+
Debug::enable();
18+
19+
$request = Request::createFromGlobals();
20+
$env = $request->query->get('env', 'phpcr');
21+
$request->query->remove('env');
22+
23+
$kernel = include __DIR__.'/../../bootstrap/kernel_bootstrap.php';
24+
$kernel->loadClassCache();
25+
$response = $kernel->handle($request);
26+
$response->send();
27+
$kernel->terminate($request, $response);

resources/web/app_test.php

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,5 @@
99
* file that was distributed with this source code.
1010
*/
1111

12-
use Symfony\Component\HttpFoundation\Request;
13-
14-
require_once __DIR__.'/../../bootstrap/bootstrap.php';
15-
16-
$request = Request::createFromGlobals();
17-
$env = $request->query->get('env', 'phpcr');
18-
$request->query->remove('env');
19-
20-
$kernel = include __DIR__.'/../../bootstrap/kernel_bootstrap.php';
21-
$kernel->loadClassCache();
22-
$response = $kernel->handle($request);
23-
$response->send();
24-
$kernel->terminate($request, $response);
12+
// This file exists for Symfony <3.3 support
13+
require_once __DIR__.'/app.php';

src/HttpKernel/TestKernel.php

Lines changed: 47 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,24 @@
1111

1212
namespace Symfony\Cmf\Component\Testing\HttpKernel;
1313

14-
use Symfony\Component\HttpKernel\Kernel;
14+
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
15+
use Doctrine\Bundle\PHPCRBundle\DoctrinePHPCRBundle;
16+
use FOS\JsRoutingBundle\FOSJsRoutingBundle;
17+
use Knp\Bundle\MenuBundle\KnpMenuBundle;
18+
use Sonata\AdminBundle\SonataAdminBundle;
19+
use Sonata\BlockBundle\SonataBlockBundle;
20+
use Sonata\CoreBundle\SonataCoreBundle;
21+
use Sonata\DoctrineORMAdminBundle\SonataDoctrineORMAdminBundle;
22+
use Sonata\DoctrinePHPCRAdminBundle\SonataDoctrinePHPCRAdminBundle;
23+
use Sonata\jQueryBundle\SonatajQueryBundle;
24+
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
25+
use Symfony\Bundle\MonologBundle\MonologBundle;
26+
use Symfony\Bundle\SecurityBundle\SecurityBundle;
27+
use Symfony\Bundle\TwigBundle\TwigBundle;
28+
use Symfony\Bundle\WebServerBundle\WebServerBundle;
29+
use Symfony\Cmf\Bundle\TreeBrowserBundle\CmfTreeBrowserBundle;
1530
use Symfony\Component\HttpKernel\Bundle\BundleInterface;
31+
use Symfony\Component\HttpKernel\Kernel;
1632

1733
/**
1834
* TestKernel base class for Symfony CMF Bundle
@@ -33,42 +49,43 @@ abstract class TestKernel extends Kernel
3349
*/
3450
public function __construct($env, $debug)
3551
{
36-
$this->registerBundleSet('default', array(
37-
'Symfony\Bundle\FrameworkBundle\FrameworkBundle',
38-
'Symfony\Bundle\SecurityBundle\SecurityBundle',
39-
'Symfony\Bundle\TwigBundle\TwigBundle',
40-
'Symfony\Bundle\MonologBundle\MonologBundle',
41-
));
52+
$defaultBundles = [
53+
FrameworkBundle::class,
54+
SecurityBundle::class,
55+
TwigBundle::class,
56+
MonologBundle::class,
57+
];
58+
59+
if (class_exists(WebServerBundle::class)) {
60+
$defaultBundles[] = WebServerBundle::class;
61+
}
4262

43-
$this->registerBundleSet('phpcr_odm', array(
44-
'Doctrine\Bundle\DoctrineBundle\DoctrineBundle',
45-
'Doctrine\Bundle\PHPCRBundle\DoctrinePHPCRBundle',
46-
));
63+
$this->registerBundleSet('default', $defaultBundles);
4764

48-
$this->registerBundleSet('doctrine_orm', array(
49-
'Doctrine\Bundle\DoctrineBundle\DoctrineBundle',
50-
));
65+
$this->registerBundleSet('phpcr_odm', [DoctrineBundle::class, DoctrinePHPCRBundle::class]);
66+
$this->registerBundleSet('doctrine_orm', [DoctrineBundle::class]);
5167

52-
$baseSonataBundles = array(
53-
'Sonata\BlockBundle\SonataBlockBundle',
54-
'Sonata\CoreBundle\SonataCoreBundle',
55-
'Sonata\AdminBundle\SonataAdminBundle',
56-
'Knp\Bundle\MenuBundle\KnpMenuBundle',
57-
'FOS\JsRoutingBundle\FOSJsRoutingBundle',
58-
);
68+
$baseSonataBundles = [
69+
SonataBlockBundle::class,
70+
SonataCoreBundle::class,
71+
SonataAdminBundle::class,
72+
KnpMenuBundle::class,
73+
FOSJsRoutingBundle::class,
74+
];
5975

60-
if (class_exists('Sonata\jQueryBundle\SonatajQueryBundle')) {
61-
$baseSonataBundles[] = 'Sonata\jQueryBundle\SonatajQueryBundle';
76+
if (class_exists(SonatajQueryBundle::class)) {
77+
$baseSonataBundles[] = SonatajQueryBundle::class;
6278
}
6379

64-
$this->registerBundleSet('sonata_admin_orm', array_merge(array(
65-
'Sonata\DoctrineORMAdminBundle\SonataDoctrineORMAdminBundle',
66-
), $baseSonataBundles));
80+
$this->registerBundleSet('sonata_admin_orm', array_merge(
81+
[SonataDoctrineORMAdminBundle::class],
82+
$baseSonataBundles
83+
));
6784

68-
$this->registerBundleSet('sonata_admin_phpcr', array_merge(array(
69-
'Sonata\DoctrinePHPCRAdminBundle\SonataDoctrinePHPCRAdminBundle',
70-
'Symfony\Cmf\Bundle\TreeBrowserBundle\CmfTreeBrowserBundle',
71-
), $baseSonataBundles));
85+
$this->registerBundleSet('sonata_admin_phpcr', array_merge([
86+
SonataDoctrinePHPCRAdminBundle::class,
87+
CmfTreeBrowserBundle::class,
88+
], $baseSonataBundles));
7289

7390
parent::__construct($env, $debug);
7491
$this->configure();

tests/HttpKernel/TestKernelTest.php

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,12 @@
1111

1212
namespace Symfony\Cmf\Component\Testing\Tests\HttpKernel;
1313

14+
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
15+
use Symfony\Bundle\SecurityBundle\SecurityBundle;
16+
use Symfony\Bundle\TwigBundle\TwigBundle;
17+
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
18+
use Doctrine\Bundle\PHPCRBundle\DoctrinePHPCRBundle;
19+
1420
class TestKernelTest extends \PHPUnit_Framework_TestCase
1521
{
1622
public function setUp()
@@ -26,20 +32,21 @@ public function setUp()
2632
/**
2733
* @dataProvider bundleSetProvider
2834
*/
29-
public function testBundleSetRequire(array $bundleSets, $count)
35+
public function testBundleSetRequire(array $bundleSets, array $expectedBundles)
3036
{
3137
$this->kernel->requireBundleSets($bundleSets);
32-
$bundles = $this->kernel->registerBundles();
33-
$this->assertCount($count, $bundles);
38+
$bundles = array_keys($this->kernel->registerBundles());
39+
40+
$this->assertArraySubset($expectedBundles, $bundles);
3441
}
3542

3643
public function bundleSetProvider()
3744
{
38-
return array(
39-
array(array('default', 'phpcr_odm'), 6),
40-
array(array('default', 'doctrine_orm'), 5),
41-
array(array('default', 'doctrine_orm', 'phpcr_odm'), 6),
42-
);
45+
return [
46+
[['default'], [FrameworkBundle::class, SecurityBundle::class, TwigBundle::class]],
47+
[['phpcr_odm'], [DoctrineBundle::class, DoctrinePHPCRBundle::class]],
48+
[['doctrine_orm'], [DoctrineBundle::class]],
49+
];
4350
}
4451

4552
public function testBundleAdd()

0 commit comments

Comments
 (0)