|
0
|
1 <?php
|
|
|
2
|
|
|
3 /*
|
|
|
4 |--------------------------------------------------------------------------
|
|
|
5 | Test Case
|
|
|
6 |--------------------------------------------------------------------------
|
|
|
7 |
|
|
|
8 | The closure you provide to your test functions is always bound to a specific PHPUnit test
|
|
|
9 | case class. By default, that class is "PHPUnit\Framework\TestCase". Of course, you may
|
|
|
10 | need to change it using the "pest()" function to bind a different classes or traits.
|
|
|
11 |
|
|
|
12 */
|
|
|
13
|
|
|
14 pest()->extend(Tests\TestCase::class)
|
|
|
15 ->use(Illuminate\Foundation\Testing\RefreshDatabase::class)
|
|
|
16 ->in('Feature');
|
|
|
17
|
|
|
18 /*
|
|
|
19 |--------------------------------------------------------------------------
|
|
|
20 | Expectations
|
|
|
21 |--------------------------------------------------------------------------
|
|
|
22 |
|
|
|
23 | When you're writing tests, you often need to check that values meet certain conditions. The
|
|
|
24 | "expect()" function gives you access to a set of "expectations" methods that you can use
|
|
|
25 | to assert different things. Of course, you may extend the Expectation API at any time.
|
|
|
26 |
|
|
|
27 */
|
|
|
28
|
|
|
29 expect()->extend('toBeOne', function () {
|
|
|
30 return $this->toBe(1);
|
|
|
31 });
|
|
|
32
|
|
|
33 /*
|
|
|
34 |--------------------------------------------------------------------------
|
|
|
35 | Functions
|
|
|
36 |--------------------------------------------------------------------------
|
|
|
37 |
|
|
|
38 | While Pest is very powerful out-of-the-box, you may have some testing code specific to your
|
|
|
39 | project that you don't want to repeat in every file. Here you can also expose helpers as
|
|
|
40 | global functions to help you to reduce the number of lines of code in your test files.
|
|
|
41 |
|
|
|
42 */
|
|
|
43
|
|
|
44 function something()
|
|
|
45 {
|
|
|
46 // ..
|
|
|
47 }
|