Advanced Laravel Testing: setUp, setUpBeforeClass and Parent Class

preview_player
Показать описание
The second free video of my newest course about advanced automated testing in Laravel.

- - - - -
Support the channel by checking out my products:

- - - - -
Other places to follow:
Рекомендации по теме
Комментарии
Автор

setup is calling multiple time too. either we created it in parent class. so what is the difference here.

tech_solutionsgroup
Автор

Thank you for this video, didn't know setUp was called multiple times as we are using it in a similar case to create a user. But once there are a lot of test cases, would it be advisable to use traits instead? (as there are other feature test that don't require creating a new user). I think this is shown in your previous video when evaluating a school management system.

IndraPrastha
Автор

We can do something like this too, to make sure some part of code in setUp run only once.

```
protected static $setUpHasRunOnce = false;

public function setUp(): void
{
parent::setUp();

if (!static::$setUpHasRunOnce) {

static::$setUpHasRunOnce = true;
}
}
```

pratikrane
Автор

Hi, I have one question on you, please. Is it possible to do with Laravel framework bot which would be checking for example if the graphic card is in e-shop and if it would be a true than the bot will immediately buy it ? or is python better for this one project ?

ludwigtomas
Автор

Thank you for this video 👍, that was really usefull. I have an off-topic question about laravel blade components. Let's assume I have a component like services which contains dynamic contents from the database which is administrable in a backoffice. This component will be used in many pages. So how can i deal with this, can I directly use the model function App\Model\Service::all() inside the component or do I have to set a variable services in each controller rendering page which contains this component or something else🤔? Thank you😁

reneravoala
Автор

Hey Povilas, i have a question, when you modify the TestCase class doesn’t it violate the O in SOLID principle which mean you should not able to modify the original class and you should extend and modify there instead? Or i am missing something?

rahmatsetiawan