// composer.json
{
"require": {
"php": "^7.1.3",
"composer/package-versions-deprecated": "^1.11", // 1.11.99
"doctrine/doctrine-bundle": "^1.6", // 1.8.1
"doctrine/doctrine-cache-bundle": "^1.2", // 1.3.2
"doctrine/doctrine-migrations-bundle": "^1.1", // v1.3.1
"doctrine/orm": "^2.5", // v2.7.2
"fzaninotto/faker": "^1.7", // v1.7.1
"knplabs/knp-markdown-bundle": "^1.4", // 1.6.0
"sensio/framework-extra-bundle": "^5.0", // v5.1.3
"stof/doctrine-extensions-bundle": "dev-master", // dev-master
"symfony/asset": "^4.0", // v4.0.1
"symfony/console": "^4.0", // v4.0.1
"symfony/flex": "^1.0", // v1.9.10
"symfony/form": "^4.0", // v4.0.1
"symfony/framework-bundle": "^4.0", // v4.0.1
"symfony/lts": "^4@dev", // dev-master
"symfony/maker-bundle": "^1.0", // v1.0.2
"symfony/monolog-bundle": "^3.1", // v3.1.2
"symfony/polyfill-apcu": "^1.0", // v1.6.0
"symfony/profiler-pack": "^1.0", // v1.0.3
"symfony/security-bundle": "^4.0", // v4.0.1
"symfony/security-csrf": "^4.0",
"symfony/swiftmailer-bundle": "^3.1", // v3.1.6
"symfony/translation": "^4.0", // v4.0.1
"symfony/twig-bundle": "^4.0", // v4.0.1
"symfony/validator": "^4.0", // v4.0.1
"symfony/web-server-bundle": "^4.0", // v4.0.1
"symfony/yaml": "^4.0" // v4.0.1
},
"require-dev": {
"symfony/dotenv": "^4.0", // v4.0.1
"symfony/phpunit-bridge": "^4.0", // v4.0.1
"doctrine/doctrine-fixtures-bundle": "^3.0" // 3.0.2
}
}
11 Comments
At the beginning of this chapter, Ryan says the new Sym4 app still works. But I am getting this error when trying to load the homepage (even after removing the two lines from AppKernel.php):
Error: Class AppBundle\Security\LoginFormAuthenticator contains 1 abstract method and must therefore be declared abstract or implement the remaining methods (Symfony\Component\Security\Guard\AuthenticatorInterface::onAuthenticationSuccess)It looks like something has changed in Guard Authenticator. Is this something that is addressed later in the tutorial? Or should I get it fixed now before trying to install Flex?
So.. the answer is just keep going. Ryan addresses this issue in Chapter 09.
Hello, Ryan!
When I installed Flex, it converted my <strong>phpunit.xml.dist</strong> to this:
However, when starting a new Symfony4 project from scratch and installing PHPUnit in it, I get the following <strong>phpunit.xml.dist</strong>
My question is why is the top one different from the bottom and why does the top one contain 2 mostly identical sections above and below
Thank you!
Hey Vladimir Z.!
GREAT question :). And, there are 2 things going on:
1) Currently, when you run tests in a Symfony 4 / Flex project, it does NOT read your .env file. Instead, you're supposed to duplicate your environment variables in your phpunit.xml.dist file. That will likely change (I'm changing it, because it's annoying: https://github.com/symfony/..., but that's the current state of things. So, because of this, when Flex installs a recipe, and that recipe adds a new environment variable, it adds it to .env, .env.dist AND to phpunit.xml.dist. This is what you're seeing: the recipe causes these changes.
2) BUT, there's also the duplication. This should not happen - it smells like some sort of Flex bug to me, tbh - because you had an existing phpunit.xml.dist file and were upgrading to Flex, this may have caused some situation that is not currently accounted for. Definitely remove that duplication. If you know the steps to replicate, you could definitely open an issue on Symfony Flex for that: https://github.com/symfony/.... I would be happy to support that issue, as I think it's valid. However, we *may*/probably will remove this phpunit.xml.dist functionality soon anyways (via my linked PR - just need to finish it!).
Cheers!
Hi weaverryan!
The duplication in phpunit.xml.dist can be replicated by simply following your Upgrade to Symfony4 and Flex!
tutorial. It happens when Flex gets installed.
Would you suggest removing the duplication or dumping this phpunit.xml.dist file altogether and simply going with a fresh one that is created when PHPUnit is first installed? In this case, how would I "feed" the test environmental variables? Would I put them into the test YAML files, or will they be read from .env?
Thanks!
Hey Vladimir Z.
I would stick with the file that comes from installing Symfony4 (the short one), and then add all the "env" variables that my project needs
Cheers!
¡Hola, Diego!
Say, I want to store my test environmental variables in the .env file as well. How can I "feed" them into the phpunit.xml.dist file instead of declaring with there with the <env name="..." value=".../"> ?
Or does it read them automatically from the .env file and the variables added to the phpunit.xml.dist file directly simply overwrite them?
Gracias.
Hola! como estas? :)
I'm afraid that you have to manually add them to both files: .env and phpunit.xml.dist
As Ryan said, this is an annoying thing to do but Symfony people is working on to get it better
Is there any way to somehow read them from .env in phpunit.xml.dist? Like using the env() function in the YAML files?
Vladimir Z. yep! For now, you can "mimic" my PR and create a tests/bootstrap.php - https://github.com/symfony/.... It's a super simple change to your project, and will get you what you need. Then, soon, everyone will hopefully be using a similar approach anyways :)
Thank you, Ryan! Will Try this.
"Houston: no signs of life"
Start the conversation!