Last active
February 18, 2017 12:10
-
-
Save jeroenvdgulik/c693d3f37b76efb66a55a2b50944c499 to your computer and use it in GitHub Desktop.
"Solving" the issue of Symfony 3.x and PHPUnit 6.x (obviously this is a hack until they fix it properly)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// create a file in /tests/bootstrap.php at the root of your symfony project | |
$loader = require(__DIR__ . '/../app/autoload.php'); // or whatever path your autoload.php is in | |
if (!class_exists('\PHPUnit_Framework_TestCase') && class_exists('\PHPUnit\Framework\TestCase')) { | |
class_alias('\PHPUnit\Framework\TestCase', '\PHPUnit_Framework_TestCase'); | |
} | |
return $loader; | |
// In your phpunit.xml or phpunit.xml.dist change: | |
bootstrap="app/autoload.php" | |
// to | |
bootstrap="tests/bootstrap.php" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Alternatively if you use your own bootstrap file, just add this line: | |
if (!class_exists('\PHPUnit_Framework_TestCase') && class_exists('\PHPUnit\Framework\TestCase')) { | |
class_alias('\PHPUnit\Framework\TestCase', '\PHPUnit_Framework_TestCase'); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Create a file in /tests/alias.php at the root of your symfony project containing: | |
if (!class_exists('\PHPUnit_Framework_TestCase') && class_exists('\PHPUnit\Framework\TestCase')) { | |
class_alias('\PHPUnit\Framework\TestCase', '\PHPUnit_Framework_TestCase'); | |
} | |
// In your composer.json We can misuse composer autoloading. | |
// much thanks to @WyriHaximus who pointed it out. | |
// Add the following: | |
"autoload-dev": { | |
"files": [ | |
"tests/alias.php" | |
] | |
}, | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this. Works really well!
I updated it to support more variants in my Symfony3 project.