Skip to content
This repository was archived by the owner on Sep 16, 2021. It is now read-only.

Commit 570d30f

Browse files
committed
Integrated testing component
1 parent e171967 commit 570d30f

File tree

10 files changed

+93
-39
lines changed

10 files changed

+93
-39
lines changed

.gitignore

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
vendor
22
composer.lock
33
composer.phar
4-
Tests/Functional/config/parameters.yml
5-
Tests/Functional/app.sqlite
4+
Tests/Resources/app/cache

.travis.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,9 @@ env:
1111
- SYMFONY_VERSION=dev-master
1212

1313
before_script:
14-
- composer require symfony/routing:${SYMFONY_VERSION} --no-update
14+
- composer require symfony/framework-bundle:${SYMFONY_VERSION} --no-update
1515
- composer install --dev
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:register-system-node-types
16+
- vendor/symfony-cmf/testing/bin/travis/phpcr_odm_doctrine_dbal.sh
1917

2018
script: phpunit --coverage-text
2119

Tests/Functional/PHPCR/PHPCRBrowserTest.php

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
namespace Symfony\Cmf\Bundle\TreeBrowserBundle\Tests\Functional\PHPCR;
44

5-
use Symfony\Cmf\Bundle\TreeBrowserBundle\Tests\Functional\BaseTestCase;
5+
6+
use Symfony\Cmf\Component\Testing\Functional\BaseTestCase;
67

78
/**
89
* Functional test for PHPCRBrowser
@@ -19,10 +20,13 @@ public function testGetChildrenListFromRoot()
1920
$client = $this->createClient();
2021

2122
$client->request('GET', '/_cmf_tree/phpcr_tree/children');
23+
$response = $client->getResponse();
24+
25+
$this->assertEquals(200, $response->getStatusCode());
2226

2327
$this->assertEquals(
24-
$client->getResponse()->getContent(),
25-
'[{"data":"cms","attr":{"id":"\/cms","url_safe_id":"cms","rel":"node"},"state":"closed","children":[{"data":"content","attr":{"id":"\/cms\/content","url_safe_id":"cms\/content","rel":"node"},"state":"closed"}]},{"data":"menus","attr":{"id":"\/menus","url_safe_id":"menus","rel":"node"},"state":"closed","children":[{"data":"test","attr":{"id":"\/menus\/test","url_safe_id":"menus\/test","rel":"node"},"state":null}]}]'
28+
'[{"data":"cms","attr":{"id":"\/cms","url_safe_id":"cms","rel":"node"},"state":"closed","children":[{"data":"content","attr":{"id":"\/cms\/content","url_safe_id":"cms\/content","rel":"node"},"state":"closed"}]},{"data":"menus","attr":{"id":"\/menus","url_safe_id":"menus","rel":"node"},"state":"closed","children":[{"data":"test","attr":{"id":"\/menus\/test","url_safe_id":"menus\/test","rel":"node"},"state":null}]}]',
29+
$client->getResponse()->getContent()
2630
);
2731
}
2832

@@ -33,20 +37,19 @@ public function testGetChildrenListFromInnerNode()
3337
$client = $this->createClient();
3438

3539
$crawler = $client->request('GET', '/_cmf_tree/phpcr_tree/children?root=%2Fcms%2Fcontent');
40+
$response = $client->getResponse();
41+
42+
$this->assertEquals(200, $response->getStatusCode());
3643

3744
$this->assertEquals(
38-
$client->getResponse()->getContent(),
39-
'[{"data":"static","attr":{"id":"\/cms\/content\/static","url_safe_id":"cms\/content\/static","rel":"node"},"state":"closed","children":[{"data":"test","attr":{"id":"\/cms\/content\/static\/test","url_safe_id":"cms\/content\/static\/test","rel":"node"},"state":null}]}]'
45+
'[{"data":"static","attr":{"id":"\/cms\/content\/static","url_safe_id":"cms\/content\/static","rel":"node"},"state":"closed","children":[{"data":"test","attr":{"id":"\/cms\/content\/static\/test","url_safe_id":"cms\/content\/static\/test","rel":"node"},"state":null}]}]',
46+
$client->getResponse()->getContent()
4047
);
4148
}
4249

4350
protected function loadFixtures()
4451
{
45-
self::$kernel = self::createKernel();
46-
self::$kernel->init();
47-
self::$kernel->boot();
48-
49-
$session = self::$kernel->getContainer()->get('doctrine_phpcr.session');
52+
$session = $this->getContainer()->get('doctrine_phpcr.session');
5053
if ($session->nodeExists("/cms")) {
5154
$session->getNode("/cms")->remove();
5255
}
@@ -65,4 +68,4 @@ protected function loadFixtures()
6568
$session->save();
6669
}
6770

68-
}
71+
}

Tests/Resources/app/AppKernel.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
use Symfony\Cmf\Component\Testing\HttpKernel\TestKernel;
4+
use Symfony\Component\Config\Loader\LoaderInterface;
5+
class AppKernel extends TestKernel
6+
{
7+
public function configure()
8+
{
9+
$this->requireBundleSets(array(
10+
'default', 'phpcr_odm'
11+
));
12+
13+
$this->addBundles(array(
14+
new \Symfony\Cmf\Bundle\TreeBrowserBundle\CmfTreeBrowserBundle(),
15+
));
16+
}
17+
18+
public function registerContainerConfiguration(LoaderInterface $loader)
19+
{
20+
$loader->load(__DIR__.'/config/config.php');
21+
}
22+
}
23+

Tests/Resources/app/config/cmf_tree_browser.yml

Whitespace-only changes.

Tests/Resources/app/config/config.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<?php
2+
3+
$loader->import(CMF_TEST_CONFIG_DIR.'/default.php');
4+
$loader->import(__DIR__.'/cmf_tree_browser.yml');
5+
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
use Symfony\Component\Routing\RouteCollection;
4+
5+
$collection = new RouteCollection();
6+
$collection->addCollection(
7+
$loader->import('routing.yml'
8+
));
9+
10+
return $collection;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
symfony_route:
2+
pattern: /symfony_route_test
3+
defaults: { _controller: Test:controller }
4+
5+
cmf_tree:
6+
resource: .
7+
type: 'cmf_tree'

composer.json

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,7 @@
1818
"friendsofsymfony/jsrouting-bundle": "dev-master"
1919
},
2020
"require-dev": {
21-
"symfony/class-loader": "~2.1",
22-
"symfony/browser-kit": "~2.1",
23-
"doctrine/doctrine-bundle": "1.*",
24-
"symfony/yaml": "~2.1",
25-
"symfony/finder": "~2.1",
26-
"jackalope/jackalope-doctrine-dbal": "1.0.*",
27-
"doctrine/phpcr-odm": "1.0.*",
28-
"doctrine/phpcr-bundle": "1.0.*"
21+
"symfony-cmf/testing": "dev-master"
2922
},
3023
"suggest": {
3124
"doctrine/phpcr-bundle": "1.0.*",

phpunit.xml.dist

Lines changed: 30 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,32 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<phpunit bootstrap="./Tests/bootstrap.php">
3-
<testsuites>
4-
<testsuite name="TreeBrowserBundle Test Suite">
5-
<directory suffix="Test.php">./Tests</directory>
6-
</testsuite>
7-
</testsuites>
8-
<filter>
9-
<whitelist>
10-
<directory>./</directory>
11-
<exclude>
12-
<directory>./Tests</directory>
13-
</exclude>
14-
</whitelist>
15-
</filter>
2+
3+
<!-- http://www.phpunit.de/manual/current/en/appendixes.configuration.html -->
4+
<phpunit
5+
colors="true"
6+
bootstrap="vendor/symfony-cmf/testing/bootstrap/bootstrap.php"
7+
>
8+
9+
<testsuites>
10+
<testsuite name="Symfony CmfTreeBrowserBundle Test Suite">
11+
<directory>./Tests</directory>
12+
</testsuite>
13+
</testsuites>
14+
15+
<filter>
16+
<whitelist addUncoveredFilesFromWhitelist="true">
17+
<directory>.</directory>
18+
<exclude>
19+
<file>*Bundle.php</file>
20+
<directory>Resources/</directory>
21+
<directory>Admin/</directory>
22+
<directory>Tests/</directory>
23+
<directory>vendor/</directory>
24+
</exclude>
25+
</whitelist>
26+
</filter>
27+
28+
<php>
29+
<server name="KERNEL_DIR" value="Tests/Resources/app" />
30+
</php>
31+
1632
</phpunit>

0 commit comments

Comments
 (0)