This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
Go to file
Fabien Potencier 3f5d4c55ba bug #11370 [FrameworkBundle] avoid raising unexpected RuntimeException when specifying $_SERVER['KERNEL_DIR'] (iteman)
This PR was submitted for the master branch but it was merged into the 2.5 branch instead (closes #11370).

Discussion
----------

[FrameworkBundle] avoid raising unexpected RuntimeException when specifying $_SERVER['KERNEL_DIR']

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | -
| License       | MIT
| Doc PR        | -

Since v2.5.0 (exactly e778cf19cd), all tests that use WebTestCase are to be errors "RuntimeException: Unable to guess the Kernel directory." even though $_SERVER['KERNEL_DIR'] is specified. This has been preventing another test runner (e.g. [MakeGood](https://github.com/piece/makegood)) from running tests for a Symfony application without overriding KernelTestCase::getPhpUnitXmlDir() as follows.

The bootstrap file for testing in the app directory:

```php
<?php
...
$_SERVER['KERNEL_DIR'] = __DIR__;
require_once dirname(__DIR__) . '/var/bootstrap.php.cache';
```

console output:

```console
PHPUnit 4.1.3 by Sebastian Bergmann.

EE

Acme\DemoBundle\Tests\Controller\DemoController
 [ ] Index
 [ ] Secure section

Time: 146 ms, Memory: 9.50Mb

There were 2 errors:

1) Acme\DemoBundle\Tests\Controller\DemoControllerTest::testIndex
RuntimeException: Unable to guess the Kernel directory.

/path/to/symfony-application/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.php:56
/path/to/symfony-application/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.php:103
/path/to/symfony-application/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.php:156
/path/to/symfony-application/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Test/KernelTestCase.php:137
/path/to/symfony-application/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Test/WebTestCase.php:33
/path/to/symfony-application/src/Acme/DemoBundle/Tests/Controller/DemoControllerTest.php:11
/path/to/eclipse/plugins/com.piece_framework.makegood.stagehandtestrunner_3.1.0.v201407050319/resources/php/vendor/piece/stagehand-testrunner/src/Runner/PHPUnitRunner.php:81
/path/to/eclipse/plugins/com.piece_framework.makegood.stagehandtestrunner_3.1.0.v201407050319/resources/php/vendor/piece/stagehand-testrunner/src/Process/TestRunner.php:100
/path/to/eclipse/plugins/com.piece_framework.makegood.stagehandtestrunner_3.1.0.v201407050319/resources/php/vendor/piece/stagehand-testrunner/src/CLI/TestRunnerApplication/Command/PluginCommand.php:149
/path/to/symfony-application/vendor/symfony/symfony/src/Symfony/Component/Console/Command/Command.php:252
/path/to/symfony-application/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:887
/path/to/symfony-application/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:193
/path/to/symfony-application/vendor/symfony/symfony/src/Symfony/Component/Console/Application.php:124
...
```

Commits
-------

6f58674 [FrameworkBundle] changed KernelTestCase::getKernelClass() to check $_SERVER['KERNEL_DIR'] before invoking getPhpUnitXmlDir()
2014-07-23 17:01:18 +02:00
src/Symfony [FrameworkBundle] changed KernelTestCase::getKernelClass() to check $_SERVER['KERNEL_DIR'] before invoking getPhpUnitXmlDir() 2014-07-23 17:01:18 +02:00
.editorconfig Add EditorConfig File 2012-06-16 14:08:15 +02:00
.gitignore Revert "encourage the running of coverage" 2013-12-04 07:03:18 +01:00
.travis.yml Merge branch '2.4' into 2.5 2014-07-08 14:21:33 +02:00
autoload.php.dist made the dist autoloader to return the autoloder 2013-05-09 09:12:11 +02:00
CHANGELOG-2.2.md Merge branch '2.2' into 2.3 2013-12-03 15:51:26 +01:00
CHANGELOG-2.3.md updated CHANGELOG for 2.3.18 2014-07-15 16:20:17 +02:00
CHANGELOG-2.4.md updated CHANGELOG for 2.4.8 2014-07-15 16:51:55 +02:00
CHANGELOG-2.5.md updated CHANGELOG for 2.5.2 2014-07-15 17:39:39 +02:00
composer.json Merge branch '2.4' into 2.5 2014-06-06 05:57:03 +02:00
CONTRIBUTING.md added the BC docs to the contributing file 2014-03-04 08:26:38 +01:00
CONTRIBUTORS.md update CONTRIBUTORS for 2.3.18 2014-07-15 16:20:27 +02:00
LICENSE updated LICENSE year 2014-03-13 07:25:45 +01:00
phpunit.xml.dist Merge branch '2.3' into 2.4 2014-07-09 11:04:55 +02:00
README.md Fix typos in README 2013-01-19 11:32:41 +01:00
UPGRADE-2.1.md [CS Fix] Consistent coding-style of concatenation operator usage 2013-04-02 10:39:57 +01:00
UPGRADE-2.2.md Merge branch '2.3' into 2.4 2014-04-28 19:43:58 +02:00
UPGRADE-2.3.md [Upgrade] Fixed markdown syntax 2014-07-09 17:19:57 +02:00
UPGRADE-2.4.md [Form] Changed (Number|Integer)ToLocalizedStringTransformer::reverseTransform() to do rounding 2013-08-01 17:19:11 +02:00
UPGRADE-2.5.md Yaml component change in 2.5 2014-06-06 05:02:05 +02:00
UPGRADE-3.0.md [Process] Deprecate using values that are not string for Process::setStdin and ProcessBuilder::setInput 2014-05-23 11:02:52 +02:00

README

What is Symfony2?

Symfony2 is a PHP 5.3 full-stack web framework. It is written with speed and flexibility in mind. It allows developers to build better and easy to maintain websites with PHP.

Symfony can be used to develop all kind of websites, from your personal blog to high traffic ones like Dailymotion or Yahoo! Answers.

Requirements

Symfony2 is only supported on PHP 5.3.3 and up.

Be warned that PHP versions before 5.3.8 are known to be buggy and might not work for you:

Installation

The best way to install Symfony2 is to download the Symfony Standard Edition available at http://symfony.com/download.

Documentation

The "Quick Tour" tutorial gives you a first feeling of the framework. If, like us, you think that Symfony2 can help speed up your development and take the quality of your work to the next level, read the official Symfony2 documentation.

Contributing

Symfony2 is an open source, community-driven project. If you'd like to contribute, please read the Contributing Code part of the documentation. If you're submitting a pull request, please follow the guidelines in the Submitting a Patch section and use Pull Request Template.

Running Symfony2 Tests

Information on how to run the Symfony2 test suite can be found in the Running Symfony2 Tests section.