Skip to content

Commit cd8cda7

Browse files
Master dev kit (#146)
* be aware of deprectations introduce KENEL_CLASS handling, usage of newer phpcr-bundle with correct service visibility merge conflicts Be aware of deprecations (#145) * merge conflicts * merge conflicts * make some services public and do not use KERNEL_DIR change when exist use new KERNEL_CLASS env var fixes due to style hints revert service visibility change revert it increase symfony versions use phpcr-bundle here revert 4.0 stuff here for now Merge conflicts adjust tests * fixes due to style issue * without any symfony version * add a new service to the list to set public * remove compiler pass to make them public add yaml component merge conflicts * Be aware of deprecations (#145) * merge conflicts * merge conflicts * make some services public and do not use KERNEL_DIR change when exist use new KERNEL_CLASS env var fixes due to style hints revert service visibility change revert it increase symfony versions use phpcr-bundle here revert 4.0 stuff here for now Merge conflicts adjust tests * fixes due to style issue * without any symfony version * add a new service to the list to set public * remove compiler pass to make them public add minimum to composer.json (cherry picked from commit e4c4bc5) add yaml component move logs and cache dir use newest phpcr-bundle now fix version increase to increas phpcr-bundle (#149) DevKit updates add change log entry apply changes from styleCI * use correct phpcr-bundle version
1 parent 3e92544 commit cd8cda7

File tree

11 files changed

+90
-80
lines changed

11 files changed

+90
-80
lines changed

.travis.yml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,28 +28,26 @@ cache:
2828
env:
2929
matrix: SYMFONY_VERSION=^3.4@dev
3030
global:
31-
- SYMFONY_DEPRECATIONS_HELPER=24
31+
- SYMFONY_DEPRECATIONS_HELPER=0
3232
- SYMFONY_PHPUNIT_DIR=.phpunit SYMFONY_PHPUNIT_REMOVE="symfony/yaml"
3333
- SYMFONY_PHPUNIT_VERSION=5.7
3434
- TEST_INSTALLATION=false
3535

3636
matrix:
3737
include:
38+
- php: 7.1
39+
env: DEPS=dev SYMFONY_VERSION=^4@dev
3840
- php: 7.1
3941
env: DEPS=dev SYMFONY_VERSION=^3.4@dev
4042
- php: 7.1
41-
env: DEPS=dev SYMFONY_VERSION=3.3.*
42-
- php: 5.6
4343
env: COMPOSER_FLAGS="--prefer-lowest" SYMFONY_VERSION=2.8.* SYMFONY_DEPRECATIONS_HELPER=weak
44-
- php: 7.0
45-
env: SYMFONY_VERSION=3.1.*
46-
- php: 7.0
47-
env: SYMFONY_VERSION=3.2.*
44+
- php: 7.1
45+
env: SYMFONY_VERSION=3.3.*
4846

4947
fast_finish: true
5048
allow_failures:
5149
- php: 7.1
52-
env: DEPS=dev SYMFONY_VERSION=^3.4@dev
50+
env: DEPS=dev SYMFONY_VERSION=^4@dev
5351

5452

5553
before_install:

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
Changelog
22
=========
33

4+
* **2017-11-08**: Removed php 5.6 and 7.0 support, removed Symfony 3.0.* and 3.1.* support
5+
introduce KERNEL_CLASS handling to avoid deprecated KERNEL_DIR, removed usage of `ProcessBuilder`
6+
47
2.0.0
58
-----
69

Makefile

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,13 @@
1313
# file that was distributed with this source code. #
1414
############################################################################
1515

16-
ifeq ("symfony-cmf/testing", "symfony-cmf/testing")
1716
TESTING_SCRIPTS_DIR=bin
18-
else
19-
TESTING_SCRIPTS_DIR=vendor/symfony-cmf/testing/bin
20-
endif
2117
CONSOLE=${TESTING_SCRIPTS_DIR}/console
2218
VERSION=dev-master
2319
ifdef BRANCH
2420
VERSION=dev-${BRANCH}
2521
endif
2622
PACKAGE=symfony-cmf/testing
27-
2823
list:
2924
@echo 'test: will run all tests'
3025
@echo 'unit_tests: will run unit tests only'

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ the context of the CMF.
2121

2222
## Requirements
2323

24-
* PHP 5.6 / 7.0 / 7.1
25-
* Symfony 2.8 / 3.1 / 3.2 / 3.3
24+
* PHP 7.1
25+
* Symfony 2.8 / 3.3 / ^3.4@dev
2626
* See also the `require` section of [composer.json](composer.json)
2727

2828
## Documentation

bootstrap/kernel_bootstrap.php

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

12+
if (getenv('KERNEL_CLASS')) {
13+
$kernelClassName = getenv('KERNEL_CLASS');
14+
15+
return new $kernelClassName($env, true);
16+
}
1217
$rootDir = realpath(__DIR__.'/../../../..');
1318
$phpUnitFile = $rootDir.'/phpunit.xml.dist';
1419

composer.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@
99
}
1010
],
1111
"require": {
12-
"php": "^5.6|^7.0",
13-
"symfony/symfony": "^2.8|^3.0",
12+
"php": "^7.0",
1413
"symfony/phpunit-bridge": "^3.2",
1514
"symfony/monolog-bundle": "^2.1|^3.0",
1615
"doctrine/common": "^2.4",
17-
"doctrine/doctrine-bundle": "^1.0",
16+
"doctrine/doctrine-bundle": "^1.0|^2.0",
1817
"doctrine/phpcr-odm": "^1.1|^2.0",
1918
"doctrine/phpcr-bundle": "^1.1|^2.0",
2019
"doctrine/data-fixtures": "^1.0",
2120
"jackalope/jackalope": "^1.1.5",
2221
"jackalope/jackalope-doctrine-dbal": "^1.1.5",
23-
"friendsofsymfony/jsrouting-bundle": "^1.1"
22+
"friendsofsymfony/jsrouting-bundle": "^1.1",
23+
"symfony/yaml": "^2.8|^3.0"
2424
},
2525
"autoload": {
2626
"psr-4": {
@@ -36,5 +36,6 @@
3636
"branch-alias": {
3737
"dev-master": "2.1-dev"
3838
}
39-
}
39+
},
40+
"minimum-stability":"dev"
4041
}

resources/config/dist/parameters.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ parameters:
1111
phpcr_pass: admin
1212

1313
database_driver: pdo_sqlite
14-
database_path: '%kernel.root_dir%/cache/app.sqlite'
14+
database_path: '%kernel.root_dir%/var/cache/app.sqlite'
1515

1616
locale: en

src/Functional/BaseTestCase.php

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,20 @@ public function getDbManager($type)
126126
return $dbManager;
127127
}
128128

129+
public static function getKernelClass()
130+
{
131+
if (isset($_SERVER['KERNEL_CLASS']) || isset($_ENV['KERNEL_CLASS'])) {
132+
$class = isset($_SERVER['KERNEL_CLASS']) ? $_SERVER['KERNEL_CLASS'] : $_ENV['KERNEL_CLASS'];
133+
if (!class_exists($class)) {
134+
throw new \RuntimeException(sprintf('Class "%s" doesn\'t exist or cannot be autoloaded. Check that the KERNEL_CLASS value in phpunit.xml matches the fully-qualified class name of your Kernel or override the %s::createKernel() method.', $class, static::class));
135+
}
136+
137+
return $class;
138+
}
139+
140+
return parent::getKernelClass();
141+
}
142+
129143
/**
130144
* {@inheritdoc}
131145
*

src/HttpKernel/TestKernel.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,17 @@ public function getCacheDir()
197197
{
198198
return implode('/', [
199199
$this->getKernelDir(),
200+
'var',
200201
'cache',
201202
]);
202203
}
204+
205+
public function getLogDir()
206+
{
207+
return implode('/', [
208+
$this->getKernelDir(),
209+
'var',
210+
'logs',
211+
]);
212+
}
203213
}

src/Phpunit/DatabaseTestListener.php

Lines changed: 28 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -13,29 +13,36 @@
1313

1414
use Doctrine\Common\DataFixtures\Purger;
1515
use Symfony\Component\Process\PhpExecutableFinder;
16-
use Symfony\Component\Process\ProcessBuilder;
16+
use Symfony\Component\Process\Process;
1717

1818
class DatabaseTestListener implements \PHPUnit_Framework_TestListener
1919
{
2020
protected static $currentSuite;
21-
private $processBuilder;
21+
private $processCallable;
2222
private $prefix = [];
2323

24-
public function __construct($processBuilder = null)
24+
public function __construct(callable $processCallable = null)
2525
{
26-
if (null === $processBuilder) {
27-
$this->processBuilder = new ProcessBuilder();
28-
$phpExecutableFinder = new PhpExecutableFinder();
29-
$phpExecutable = $phpExecutableFinder->find(false);
30-
if (false === $phpExecutable) {
31-
throw new \RuntimeException('No PHP executable found on the current system.');
32-
}
26+
$phpExecutableFinder = new PhpExecutableFinder();
27+
$phpExecutable = $phpExecutableFinder->find(false);
28+
if (false === $phpExecutable) {
29+
throw new \RuntimeException('No PHP executable found on the current system.');
30+
}
31+
32+
// Symfony 2.3 does not support array prefix, so we have to implement it ourselves
33+
$this->prefix = [$phpExecutable, __DIR__.'/../../bin/console'];
34+
$this->processCallable = $processCallable;
35+
}
3336

34-
// Symfony 2.3 does not support array prefix, so we have to implement it ourselves
35-
$this->prefix = [$phpExecutable, __DIR__.'/../../bin/console'];
36-
} else {
37-
$this->processBuilder = $processBuilder;
37+
public function getProcess($arguments)
38+
{
39+
if (is_callable($this->processCallable)) {
40+
$callable = $this->processCallable;
41+
42+
return $callable($arguments);
3843
}
44+
45+
return new Process($arguments);
3946
}
4047

4148
public function addError(\PHPUnit_Framework_Test $test, \Exception $e, $time)
@@ -116,17 +123,13 @@ private function setUpPhpcrDatabase($suite)
116123
echo PHP_EOL.PHP_EOL;
117124

118125
// initialize PHPCR DBAL (new way)
119-
$process = $this->processBuilder
120-
->setArguments(array_merge($this->prefix, ['doctrine:phpcr:init:dbal', '--drop', '--force']))
121-
->getProcess();
126+
$process = $this->getProcess(array_merge($this->prefix, ['doctrine:phpcr:init:dbal', '--drop', '--force']));
122127

123128
$process->run();
124129

125130
if (!$process->isSuccessful()) {
126131
// try initializing the old way (Jackalope <1.2)
127-
$process = $this->processBuilder
128-
->setArguments(array_merge($this->prefix, ['doctrine:phpcr:init:dbal', '--drop']))
129-
->getProcess();
132+
$process = $this->getProcess(array_merge($this->prefix, ['doctrine:phpcr:init:dbal', '--drop']));
130133

131134
$process->run();
132135

@@ -139,9 +142,7 @@ private function setUpPhpcrDatabase($suite)
139142
}
140143

141144
// initialize repositories
142-
$process = $this->processBuilder
143-
->setArguments(array_merge($this->prefix, ['doctrine:phpcr:repository:init']))
144-
->getProcess();
145+
$process = $this->getProcess(array_merge($this->prefix, ['doctrine:phpcr:repository:init']));
145146

146147
$process->run();
147148

@@ -159,9 +160,7 @@ private function setUpOrmDatabase($suite)
159160
{
160161
echo PHP_EOL.PHP_EOL;
161162

162-
$process = $this->processBuilder
163-
->setArguments(array_merge($this->prefix, ['doctrine:schema:drop', '--env=orm', '--force']))
164-
->getProcess();
163+
$process = $this->getProcess(array_merge($this->prefix, ['doctrine:schema:drop', '--env=orm', '--force']));
165164

166165
$process->run();
167166

@@ -172,9 +171,7 @@ private function setUpOrmDatabase($suite)
172171
return;
173172
}
174173

175-
$process = $this->processBuilder
176-
->setArguments(array_merge($this->prefix, ['doctrine:database:create', '--env=orm']))
177-
->getProcess();
174+
$process = $this->getProcess(array_merge($this->prefix, ['doctrine:database:create', '--env=orm']));
178175

179176
$process->run();
180177

@@ -185,9 +182,7 @@ private function setUpOrmDatabase($suite)
185182
return;
186183
}
187184

188-
$process = $this->processBuilder
189-
->setArguments(array_merge($this->prefix, ['doctrine:schema:create', '--env=orm']))
190-
->getProcess();
185+
$process = $this->getProcess(array_merge($this->prefix, ['doctrine:schema:create', '--env=orm']));
191186
$process->run();
192187

193188
if (!$process->isSuccessful()) {
@@ -206,9 +201,7 @@ public function endTestSuite(\PHPUnit_Framework_TestSuite $suite)
206201
return;
207202
}
208203

209-
$process = $this->processBuilder
210-
->setArguments(array_merge($this->prefix, ['doctrine:database:drop', '--force']))
211-
->getProcess();
204+
$process = $this->getProcess(array_merge($this->prefix, ['doctrine:database:drop', '--force']));
212205

213206
$process->run();
214207

0 commit comments

Comments
 (0)