Chapters
39 Chapters
|
4:45:13
|
Login to bookmark this video
-
Course Code
Subscribe to download the code!Compatible PHP versions: ^7.1.3, <8.0
Subscribe to download the code!Compatible PHP versions: ^7.1.3, <8.0
-
This Video
Subscribe to download the video!
Subscribe to download the video!
-
Subtitles
Subscribe to download the subtitles!
Subscribe to download the subtitles!
-
Course Script
Subscribe to download the script!
Subscribe to download the script!
22.
Conditional Field Setup
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 works great for Symfony 5 and API Platform 2.5/2.6.
What PHP libraries does this tutorial use?
// composer.json
{
"require": {
"php": "^7.1.3, <8.0",
"ext-ctype": "*",
"ext-iconv": "*",
"api-platform/core": "^2.1", // v2.4.5
"composer/package-versions-deprecated": "^1.11", // 1.11.99
"doctrine/annotations": "^1.0", // 1.13.2
"doctrine/doctrine-bundle": "^1.6", // 1.11.2
"doctrine/doctrine-migrations-bundle": "^2.0", // v2.0.0
"doctrine/orm": "^2.4.5", // v2.7.2
"nelmio/cors-bundle": "^1.5", // 1.5.6
"nesbot/carbon": "^2.17", // 2.21.3
"phpdocumentor/reflection-docblock": "^3.0 || ^4.0", // 4.3.1
"symfony/asset": "4.3.*", // v4.3.2
"symfony/console": "4.3.*", // v4.3.2
"symfony/dotenv": "4.3.*", // v4.3.2
"symfony/expression-language": "4.3.*", // v4.3.2
"symfony/flex": "^1.1", // v1.21.6
"symfony/framework-bundle": "4.3.*", // v4.3.2
"symfony/http-client": "4.3.*", // v4.3.3
"symfony/monolog-bundle": "^3.4", // v3.4.0
"symfony/security-bundle": "4.3.*", // v4.3.2
"symfony/twig-bundle": "4.3.*", // v4.3.2
"symfony/validator": "4.3.*", // v4.3.2
"symfony/webpack-encore-bundle": "^1.6", // v1.6.2
"symfony/yaml": "4.3.*" // v4.3.2
},
"require-dev": {
"hautelook/alice-bundle": "^2.5", // 2.7.3
"symfony/browser-kit": "4.3.*", // v4.3.3
"symfony/css-selector": "4.3.*", // v4.3.3
"symfony/maker-bundle": "^1.11", // v1.12.0
"symfony/phpunit-bridge": "^4.3", // v4.3.3
"symfony/stopwatch": "4.3.*", // v4.3.2
"symfony/web-profiler-bundle": "4.3.*" // v4.3.2
}
}
8 Comments
data-start-time="339.276" -> does not work? (testGetUser)
I get a failure stating: Symfony\Component\HttpClient\Exception\JsonException: Response content-type is "text/html; charset=UTF-8" while a JSON-compatible one was expected.
api-platform/core v2.5.5
symfony/http-client v4.3.11
symfony/http-foundation v4.3.11
symfony/http-kernel v4.3.11
symfony/phpunit-bridge v5.0.8
Well well well, Dumb Typo! 🙃 had the line: "$client->request('GET', '/api/users/'.$user->getId());" wrong. forgot trailing / on users 😁
Is it possible to run test without running fixtures?
I have installed AliceBundle and created fixtures to generate sample data. However, whenever I run test, fixtures load automatically. Especially when I use `ReloadDatabaseTrait`, fixtures run every test cases. I can use `RefreshDatabaseTrait ` to run only once per resource test, but I was wondering if we can run test without running fixtures.
Any tips? Thanks!
Hey Sung L.
Of course you can, but it depends on what are you testing. Without fixtures you will need to think more about data that you are testing, how not to get errors about duplicated data, or probably some more
Cheers! Hope this will help.
Hi sadikoff
So..how can I run test without running fixtures? I want to keep fixtures because it helps to generate contents, but I don't want to regenerate fixtures everytime I run test. :)
Ok, lets begin from start, you want to run course code, and course tests, but without regenerating fixtures everytime, am I right?
Yes, that's correct. I like the tests shown in this video tutorial, create a new user, updating, and so on. But I'd like to see the front end filled with fixture data when I need to working on frontend UI.
Let's say I have 500 fixture data for ChesseListing. Every time I run the test, it regenerate 500 cheeses which is overkill. I would like to skip this step, regenerating data, ONLY when I run testing. Or if there is a flag in `./bin/phpunit --skip-fixture` for example, that would be perfect!
Hey Sung L.
Sorry for so late answer, it was crazy SymfonyCon week :) So I understand you point of view! Hm you can try to use separate DB for test environment without fixtures, and fully control data inside your tests
Cheers!
"Houston: no signs of life"
Start the conversation!