Skip to content

Commit 0f4c42d

Browse files
committed
[WIP] Integrating Testing Component
1 parent 6166945 commit 0f4c42d

25 files changed

+96
-121
lines changed

.gitignore

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
phpunit.xml
22
composer.lock
3-
/vendor
4-
Tests/Functional/config/parameters.yml
5-
Tests/Functional/app.sqlite
3+
vendor
4+
Tests/Resources/app/cache
5+
Tests/Resources/app/logs

.travis.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,8 @@ env:
1111
- SYMFONY_VERSION=dev-master
1212

1313
before_script:
14-
- composer self-update
1514
- composer require symfony/framework-bundle:${SYMFONY_VERSION} --prefer-source
16-
- cp ./Tests/Functional/config/parameters.yml.dist ./Tests/Functional/config/parameters.yml
17-
- php Tests/Functional/console doctrine:phpcr:init:dbal
18-
- php Tests/Functional/console doctrine:phpcr:repository:init
15+
- vendor/symfony-cmf/testing/bin/travis/phpcr_odm_doctrine_dbal.sh
1916

2017
script: phpunit --coverage-text
2118

Tests/Functional/Admin/RouteAdminTest.php

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,29 +7,25 @@
77
namespace Symfony\Cmf\Bundle\RoutingBundle\Tests\Functional\Admin;
88

99
use Symfony\Cmf\Bundle\RoutingBundle\Admin\RouteAdmin;
10-
use Symfony\Cmf\Bundle\RoutingBundle\Tests\Functional\BaseTestCase;
1110
use Symfony\Component\Routing\Route;
11+
use Symfony\Cmf\Component\Testing\Functional\BaseTestCase;
1212

1313
class RouteAdminTest extends BaseTestCase
1414
{
1515
/**
1616
* @var RouteAdmin
1717
*/
18-
private static $routeAdmin;
18+
private $routeAdmin;
1919

2020
/**
2121
* @var \PHPUnit_Framework_MockObject_MockObject
2222
*/
2323
private $errorElement;
2424

25-
public static function setupBeforeClass(array $options = array(), $routebase = null)
26-
{
27-
parent::setUpBeforeClass($options, $routebase);
28-
self::$routeAdmin = self::$kernel->getContainer()->get('cmf_routing.route_admin');
29-
}
30-
3125
protected function setUp()
3226
{
27+
$this->db('PHPCR')->createTestNode();
28+
$this->routeAdmin = $this->getContainer()->get('cmf_routing.route_admin');
3329
$this->errorElement = $this->getMockBuilder('Sonata\AdminBundle\Validator\ErrorElement')
3430
->disableOriginalConstructor()
3531
->getMock();
@@ -38,7 +34,7 @@ protected function setUp()
3834
public function testCorrectControllerPath()
3935
{
4036
$route = new Route('/', array('_controller' => 'FrameworkBundle:Redirect:redirect'));
41-
self::$routeAdmin->validate($this->errorElement, $route);
37+
$this->routeAdmin->validate($this->errorElement, $route);
4238
}
4339

4440
public function testControllerPathViolation()
@@ -55,7 +51,7 @@ public function testControllerPathViolation()
5551
$this->errorElement->expects($this->once())
5652
->method('end');
5753

58-
self::$routeAdmin->validate($this->errorElement, $route);
54+
$this->routeAdmin->validate($this->errorElement, $route);
5955
}
6056

6157
public function testTemplateViolation()
@@ -72,12 +68,12 @@ public function testTemplateViolation()
7268
$this->errorElement->expects($this->once())
7369
->method('end');
7470

75-
self::$routeAdmin->validate($this->errorElement, $route);
71+
$this->routeAdmin->validate($this->errorElement, $route);
7672
}
7773

7874
public function testCorrectTemplate()
7975
{
8076
$route = new Route('/', array('_template' => 'TwigBundle::layout.html.twig'));
81-
self::$routeAdmin->validate($this->errorElement, $route);
77+
$this->routeAdmin->validate($this->errorElement, $route);
8278
}
8379
}

Tests/Functional/AppKernel.php

Lines changed: 0 additions & 53 deletions
This file was deleted.

Tests/Functional/BaseTestCase.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
use Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\Route;
66

77
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
8+
use Symfony\Cmf\Component\Testing\Functional\BaseTestCase ;
89

9-
class BaseTestCase extends WebTestCase
10+
class BaseTestCase extends BaseTestCase
1011
{
1112
/**
1213
* @var \Doctrine\ODM\PHPCR\DocumentManager
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
parameters:
2+
phpcr_backend:
3+
#type: jackrabbit
4+
#url: http://localhost:8080/server/
5+
type: doctrinedbal
6+
connection: doctrine.dbal.default_connection
7+
phpcr_workspace: default
8+
phpcr_user: admin
9+
phpcr_pass: admin
10+
11+
database_driver: pdo_sqlite
12+
database_path: '%kernel.root_dir%/app.sqlite'
13+
14+
locale: en

Tests/Functional/console

Lines changed: 0 additions & 14 deletions
This file was deleted.

Tests/Resources/app/AppKernel.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php
2+
3+
use Symfony\Cmf\Component\Testing\HttpKernel\TestKernel;
4+
use Symfony\Component\Config\Loader\LoaderInterface;
5+
6+
class AppKernel extends TestKernel
7+
{
8+
public function configure()
9+
{
10+
$this->requireBundleSets(array(
11+
'default',
12+
'sonata_admin',
13+
'phpcr_odm',
14+
));
15+
16+
$this->addBundles(array(
17+
new \Symfony\Cmf\Bundle\RoutingBundle\CmfRoutingBundle(),
18+
));
19+
}
20+
21+
public function registerContainerConfiguration(LoaderInterface $loader)
22+
{
23+
$loader->load(__DIR__.'/config/config.php');
24+
}
25+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
cmf_routing:
2+
chain:
3+
routers_by_id:
4+
cmf_routing.dynamic_router: 20
5+
router.default: 100
6+
dynamic:
7+
enabled: true
8+
controllers_by_type:
9+
demo_alias: test.controller:aliasAction
10+
controllers_by_class:
11+
Symfony\Cmf\Bundle\RoutingBundle\Doctrine\Phpcr\RedirectRoute: cmf_routing.redirect_controller:redirectAction
12+
templates_by_class:
13+
Symfony\Cmf\Bundle\RoutingBundle\Tests\Functional\Testdoc\Content: TestBundle:Content:index.html.twig
14+
phpcr_provider:
15+
route_basepath: /test/routing
16+

Tests/Resources/app/config/config.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<?php
2+
3+
$loader->import(CMF_TEST_CONFIG_DIR.'/default.php');
4+
$loader->import(CMF_TEST_CONFIG_DIR.'/phpcr_odm.php');
5+
$loader->import(CMF_TEST_CONFIG_DIR.'/sonata_admin.php');
6+
$loader->import(__DIR__.'/cmf_routing.yml');

0 commit comments

Comments
 (0)