• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

orchestral / testbench-browser-kit / 13722984244

07 Mar 2025 02:39PM UTC coverage: 74.359%. Remained the same
13722984244

push

github

web-flow
Release 10.1.0

29 of 39 relevant lines covered (74.36%)

5.95 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

74.36
/src/TestCase.php
1
<?php
2

3
namespace Orchestra\Testbench\BrowserKit;
4

5
use Illuminate\Foundation\Testing;
6
use Laravel\BrowserKitTesting\Concerns as BrowserKitTesting;
7
use Orchestra\Testbench\Concerns;
8
use Orchestra\Testbench\Pest;
9
use Orchestra\Testbench\PHPUnit\TestCase as PHPUnit;
10

11
abstract class TestCase extends PHPUnit implements Contracts\TestCase
12
{
13
    use BrowserKitTesting\ImpersonatesUsers;
14
    use BrowserKitTesting\InteractsWithAuthentication;
15
    use BrowserKitTesting\InteractsWithConsole;
16
    use BrowserKitTesting\InteractsWithContainer;
17
    use BrowserKitTesting\InteractsWithDatabase;
18
    use BrowserKitTesting\InteractsWithExceptionHandling;
19
    use BrowserKitTesting\InteractsWithSession;
20
    use BrowserKitTesting\MakesHttpRequests;
21
    use Concerns\Testing;
22

23
    /**
24
     * The base URL to use while testing the application.
25
     *
26
     * @var string
27
     */
28
    protected $baseUrl = 'http://localhost';
29

30
    /**
31
     * Setup the test environment.
32
     *
33
     * @return void
34
     */
35
    #[\Override]
36
    protected function setUp(): void
37
    {
38
        $this->setUpTheTestEnvironment();
8✔
39
    }
40

41
    /**
42
     * Clean up the testing environment before the next test.
43
     *
44
     * @return void
45
     */
46
    #[\Override]
47
    protected function tearDown(): void
48
    {
49
        $this->tearDownTheTestEnvironment();
8✔
50
    }
51

52
    /**
53
     * Boot the testing helper traits.
54
     *
55
     * @return array<string, string>
56
     */
57
    protected function setUpTraits()
58
    {
59
        return $this->setUpTheTestEnvironmentTraits(static::$cachedTestCaseUses);
8✔
60
    }
61

62
    /**
63
     * Determine trait should be ignored from being autoloaded.
64
     *
65
     * @param  class-string  $use
66
     * @return bool
67
     */
68
    protected function setUpTheTestEnvironmentTraitToBeIgnored(string $use): bool
69
    {
70
        return \in_array($use, [
8✔
71
            Testing\RefreshDatabase::class,
8✔
72
            Testing\DatabaseMigrations::class,
8✔
73
            Testing\DatabaseTransactions::class,
8✔
74
            Testing\WithoutMiddleware::class,
8✔
75
            Testing\WithFaker::class,
8✔
76
            BrowserKitTesting\ImpersonatesUsers::class,
8✔
77
            BrowserKitTesting\InteractsWithAuthentication::class,
8✔
78
            BrowserKitTesting\InteractsWithConsole::class,
8✔
79
            BrowserKitTesting\InteractsWithContainer::class,
8✔
80
            BrowserKitTesting\InteractsWithDatabase::class,
8✔
81
            BrowserKitTesting\InteractsWithExceptionHandling::class,
8✔
82
            BrowserKitTesting\InteractsWithSession::class,
8✔
83
            Concerns\CreatesApplication::class,
8✔
84
            Concerns\HandlesAnnotations::class,
8✔
85
            Concerns\HandlesDatabases::class,
8✔
86
            Concerns\HandlesRoutes::class,
8✔
87
            Concerns\InteractsWithMigrations::class,
8✔
88
            Concerns\InteractsWithPHPUnit::class,
8✔
89
            Concerns\InteractsWithWorkbench::class,
8✔
90
            Concerns\Testing::class,
8✔
91
            Concerns\WithFactories::class,
8✔
92
            Concerns\WithLaravelMigrations::class,
8✔
93
        ]);
8✔
94
    }
95

96
    /**
97
     * Refresh the application instance.
98
     *
99
     * @return void
100
     */
101
    #[\Override]
102
    protected function refreshApplication()
103
    {
104
        $_ENV['APP_ENV'] = 'testing';
8✔
105

106
        $this->app = $this->createApplication();
8✔
107
    }
108

109
    /**
110
     * Prepare the testing environment before the running the test case.
111
     *
112
     * @return void
113
     */
114
    #[\Override]
115
    public static function setUpBeforeClass(): void
116
    {
117
        static::setUpBeforeClassUsingPHPUnit();
×
118

119
        /** @phpstan-ignore class.notFound */
120
        if (static::usesTestingConcern(Pest\WithPest::class)) {
×
121
            static::setUpBeforeClassUsingPest(); /** @phpstan-ignore staticMethod.notFound */
×
122
        }
123

124
        static::setUpBeforeClassUsingTestCase();
×
125
        static::setUpBeforeClassUsingWorkbench();
×
126
    }
127

128
    /**
129
     * Clean up the testing environment before the next test case.
130
     *
131
     * @return void
132
     */
133
    #[\Override]
134
    public static function tearDownAfterClass(): void
135
    {
136
        static::tearDownAfterClassUsingWorkbench();
×
137
        static::tearDownAfterClassUsingTestCase();
×
138

139
        /** @phpstan-ignore class.notFound */
140
        if (static::usesTestingConcern(Pest\WithPest::class)) {
×
141
            static::tearDownAfterClassUsingPest(); /** @phpstan-ignore staticMethod.notFound */
×
142
        }
143

144
        static::tearDownAfterClassUsingPHPUnit();
×
145
    }
146
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc