Chapters
23 Chapters
|
1:59:49
|
Login to bookmark this video
-
Course Code
Subscribe to download the code!Compatible PHP versions: >=5.4.0, <7.3.0
Subscribe to download the code!Compatible PHP versions: >=5.4.0, <7.3.0
-
This Video
Subscribe to download the video!
Subscribe to download the video!
-
Course Script
Subscribe to download the script!
Subscribe to download the script!
15.
Practice: Find Elements, Login with 1 Step and Debug
Scroll down to the script below, click on any sentence (including terminal blocks) to jump to that spot in the video!
Subscribe to jump to this part in the video!
Keep on Learning!
If you liked what you've learned so far, dive in! Subscribe to get access to this tutorial plus video, code and script downloads.
This tutorial uses a very old version of Symfony. The fundamentals of Behat are still valid, but integration with Symfony will be different.
What PHP libraries does this tutorial use?
// composer.json
{
"require": {
"php": ">=5.4.0, <7.3.0",
"symfony/symfony": "^2.7", // v2.7.4
"twig/twig": "^1.22", // v1.22.1
"sensio/framework-extra-bundle": "^3.0", // v3.0.16
"doctrine/doctrine-bundle": "^1.5", // v1.5.1
"doctrine/orm": "^2.5", // v2.5.1
"doctrine/doctrine-fixtures-bundle": "^2.2", // v2.2.1
"behat/symfony2-extension": "^2.0" // v2.0.0
},
"require-dev": {
"behat/mink-extension": "^2.0", // v2.0.1
"behat/mink-goutte-driver": "^1.1", // v1.1.0
"behat/mink-selenium2-driver": "^1.2", // v1.2.0
"phpunit/phpunit": "^4.8" // 4.8.18
}
}
6 Comments
Hi Ryan. I can not get to work this chapter. The products are not being created into the database, how can I debug the step that creates the products ''? The error is :
Then I should see 5 products # FeatureContext::iShouldSeeProducts()
Failed asserting that actual size 0 matches expected size 5.
So the products are not being created, I placed var_dumps and dumps on the function thereAreProducts but it doesn't get printed.
Thanks
Hey Daniel!
Hmm, so you're definitely going down the right path for debugging. This is what I would try:
A) At the end of thereAreProducts, put a die statement. Now, go look in your database. Are the products there or is the products table empty? If it's empty, you at least know there is a problem with iShouldSeeProducts(). If not, continue.
B) Remove the die from thereAreProducts and add an "And I break" right before the failing step (Then i should see 5...). Make sure you have an @javascript above the scenario, at least temporarily. Run the scenario. When it stops, do you see 5 products on the page? If you do, then you know that we have a bug in our code that looks for the 5 products (e.g. we're using the wrong CSS class name to select something). If you don't see the products (but know that they are in the database, from [A] above), then it's possible that you're making web requests into Symfony's "dev" environment, but loading all of the products in the "test" environment (and if you have a separate database for those environments, that would cause the problem).
Let me know what you find out!
Hi Ryan! Finally got the error, it was just a type in the for loop... I don not know where to hide myself. Anyway I learnt a lot thanks to your indications. There is only one thing I wasn't able to do and that is to create a play file on the root folder, this project does not have a bootstrap.php.cache.
Cheers!
Hey Daniel!
Great - glad you're on good ground again :). About the play file - just require the app/autoload.php file instead of bootstrap.php.cache. The bootstrap file does the same thing as autoload, but gives you a small (and optional) performance boost in production.
Cheers!
Ah, or just include vendor/autoload.php - if you're outside of Symfony :)
Thanks a lot Ryan! It did work, I haven't notice the autoload.php inside the app directory. I tried the vendor autoload with no luck. I am all set!!
Cheers
"Houston: no signs of life"
Start the conversation!