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!
23.
Tagging Scenarios in order to Load Fixtures
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
}
}
11 Comments
How can i make run finish script? I just downloaded it but when I run cucumber authentication.feature file I have this error below:
@BeforeScenario # FeatureContext::clearData()
│
╳ An exception occured in driver: could not find driver (Doctrine\DBAL\Exception\DriverException)
So all steps are skipping.
How can I fix it?
Thank you in advance.
Hey Soltan!
When you go into that finish directory, make sure to also open the README.md file - it has some setup instructions that you need, including initializing the database. In this case, because the tutorial uses MySQL, I believe your error means that you don't have the mysql or PDO extension compiled into your PHP. That's what the "could not find driver" means. Make sure you have the php-pdo extension installed - here are some more details about that: https://stackoverflow.com/q...
Cheers!
Great course!
It's a pity I can't get a certificate of achievement because some challenges are not working :(
Update: They are working now! :)
Hey boykodev
I see you also reported that some challenges were not working, I just check it out and they are working well. Could you confirm this? Thanks :)
Yes, they all work fine now.
Awesome, thanks!
I keep getting an error for "The text "Samsung Galaxy S II" was not found anywhere in the text of the current page."
Here is my code:
/**
* @BeforeScenario @fixtures
*/
public function loadFixtures()
{
$loader = new ContainerAwareLoader($this->getContainer());
$loader->loadFromDirectory(__DIR__.'/../../src/AppBundle/DataFixtures');
$executer = new OrmExecutor($this->getEntityManager());
$executer->execute($loader->getFixtures(), true);
}
@fixtures
Scenario Outline:
When I fill in the search box with "<term>"
And I press the search button
Then I should see "<result>"
Examples:
| term | | result |
| Samsung | | Samsung Galaxy S II |
| XBox | | No products found |
Everything has gone good up till this point. Please help!
Yo Josh!
If everything worked up to this point, it must be something small! If you add a var_dump('hey!') to loadFixtures and run just this one Scenario Outline, is it called? Also, if you add a "And print last response" to the outline, what do you see? Does the page work? Are the products visible on the page?
It could be several things - use the debugging tools from earlier: I'm sure we'll find the issue. Nothing stands out to me - so you must be close.
Cheers!
Hey Ryan. The var_dump inside the loadFixtures works fine. I also added a "And print last response" and on the page it showed a "No products found message" and the table was empty. It looks like my Features are running fine. It just seems that the fixtures are not getting loaded, once the loadFixtures method is called. Here is my code if you can look over quick and see if I missed something. Thanks! https://github.com/joshcraw...
Hey Josh!
Yep, now I see the problem: move clearData() *above* loadFixtures() - we talk about this near the bottom of this section: https://knpuniversity.com/s.... For you, it's adding the fixtures, and then clearing everything. Hence, no results :). It's a tricky one.
Cheers!
This worked great. Thanks a lot. This is kind of a weird piece of code:
$executer = new ORMExecutor($this->getEntityManager());
$executer->execute($loader->getFixtures(), true);
If is supply a new ORMPurger($em) object as the second argument to ORMExecuter(), then suddenly $executer->execute won't run unless I change true to false as the second argument. I just find it a little weird that what you pass to the second method is dependent upon what you pass to the constructor. I dunno. Maybe I'm being weird. Thanks for everything!
"Houston: no signs of life"
Start the conversation!