File tree Expand file tree Collapse file tree 3 files changed +93
-0
lines changed Expand file tree Collapse file tree 3 files changed +93
-0
lines changed Original file line number Diff line number Diff line change
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
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ declare (strict_types=1 );
4
+
5
+ namespace Tests ;
6
+
7
+ use Closure ;
8
+ use Illuminate \Foundation \Testing \LazilyRefreshDatabase ;
9
+ use Illuminate \Support \Facades \Http ;
10
+ use Mockery \MockInterface ;
11
+ use Orchestra \Testbench \Attributes \WithMigration ;
12
+ use Orchestra \Testbench \Concerns \WithWorkbench ;
13
+ use Orchestra \Testbench \TestCase as Orchestra ;
14
+
15
+ #[WithMigration]
16
+ class TestCase extends Orchestra
17
+ {
18
+ use LazilyRefreshDatabase;
19
+ use WithWorkbench;
20
+
21
+ protected function setUp (): void
22
+ {
23
+ parent ::setUp ();
24
+
25
+ Http::preventingStrayRequests ();
26
+ }
27
+
28
+ /**
29
+ * Use this when you are using app() to create an instance of a class with parameters.
30
+ * The normal mock() method does not correctly mock when using the container in this way.
31
+ * e.g. app(Example::class, ['argument' => 'foo'])
32
+ */
33
+ protected function mockBind (string $ abstract , ?Closure $ callback = null ): MockInterface
34
+ {
35
+ $ mock = $ this ->mock ($ abstract , $ callback );
36
+
37
+ app ()->offsetSet ($ abstract , $ mock );
38
+
39
+ return $ mock ;
40
+ }
41
+ }
Original file line number Diff line number Diff line change
1
+ <?php
2
+
3
+ test ('that true is true ' , function () {
4
+ expect (true )->toBeTrue ();
5
+ });
You can’t perform that action at this time.
0 commit comments