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

orchestral / testbench-core / 11968182539

22 Nov 2024 07:16AM UTC coverage: 91.991% (+0.7%) from 91.321%
11968182539

Pull #265

github

crynobone
wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
Pull Request #265: [7.x] Allow to configure `tty` via `Orchestra\Testbench\remote()` function

3 of 4 new or added lines in 1 file covered. (75.0%)

93 existing lines in 25 files now uncovered.

1206 of 1311 relevant lines covered (91.99%)

61.99 hits per line

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

82.14
/src/Concerns/InteractsWithWorkbench.php
1
<?php
2

3
namespace Orchestra\Testbench\Concerns;
4

5
use Illuminate\Support\Arr;
6
use Orchestra\Testbench\Workbench\Workbench;
7

8
/**
9
 * @internal
10
 */
11
trait InteractsWithWorkbench
12
{
13
    use InteractsWithPHPUnit;
14
    use InteractsWithTestCase;
15

16
    /**
17
     * Get Application's base path.
18
     *
19
     * @return string|null
20
     */
21
    public static function applicationBasePathUsingWorkbench(): ?string
22
    {
23
        if (! static::usesTestingConcern()) {
156✔
24
            return $_ENV['APP_BASE_PATH'] ?? null;
4✔
25
        }
26

27
        return $_ENV['APP_BASE_PATH'] ?? $_ENV['TESTBENCH_APP_BASE_PATH'] ?? null;
154✔
28
    }
29

30
    /**
31
     * Ignore package discovery from.
32
     *
33
     * @return array<int, string>|null
34
     */
35
    public function ignorePackageDiscoveriesFromUsingWorkbench(): ?array
36
    {
37
        if (property_exists($this, 'enablesPackageDiscoveries') && \is_bool($this->enablesPackageDiscoveries)) {
150✔
38
            return $this->enablesPackageDiscoveries === false ? ['*'] : [];
149✔
39
        }
40

41
        return static::usesTestingConcern(WithWorkbench::class)
1✔
UNCOV
42
            ? static::cachedConfigurationForWorkbench()?->getExtraAttributes()['dont-discover'] ?? []
×
43
            : null;
1✔
44
    }
45

46
    /**
47
     * Get package bootstrapper.
48
     *
49
     * @param  \Illuminate\Foundation\Application  $app
50
     * @return array<int, class-string>|null
51
     */
52
    protected function getPackageBootstrappersUsingWorkbench($app): ?array
53
    {
54
        if (empty($bootstrappers = static::cachedConfigurationForWorkbench()?->getExtraAttributes()['bootstrappers'] ?? null)) {
155✔
55
            return null;
155✔
56
        }
57

UNCOV
58
        return static::usesTestingConcern(WithWorkbench::class)
×
UNCOV
59
            ? Arr::wrap($bootstrappers)
×
UNCOV
60
            : [];
×
61
    }
62

63
    /**
64
     * Get package providers.
65
     *
66
     * @param  \Illuminate\Foundation\Application  $app
67
     * @return array<int, class-string>|null
68
     */
69
    protected function getPackageProvidersUsingWorkbench($app): ?array
70
    {
71
        if (empty($providers = static::cachedConfigurationForWorkbench()?->getExtraAttributes()['providers'] ?? null)) {
149✔
UNCOV
72
            return null;
×
73
        }
74

75
        return static::usesTestingConcern(WithWorkbench::class)
149✔
76
            ? Arr::wrap($providers)
24✔
77
            : [];
149✔
78
    }
79

80
    /**
81
     * Resolve application Console Kernel implementation.
82
     *
83
     * @param  \Illuminate\Foundation\Application  $app
84
     * @return string
85
     */
86
    protected function applicationConsoleKernelUsingWorkbench($app): string
87
    {
88
        if (static::usesTestingConcern(WithWorkbench::class)) {
155✔
89
            return Workbench::applicationConsoleKernel() ?? 'Orchestra\Testbench\Console\Kernel';
24✔
90
        }
91

92
        return 'Orchestra\Testbench\Console\Kernel';
131✔
93
    }
94

95
    /**
96
     * Get application HTTP Kernel implementation using Workbench.
97
     *
98
     * @param  \Illuminate\Foundation\Application  $app
99
     * @return string
100
     */
101
    protected function applicationHttpKernelUsingWorkbench($app): string
102
    {
103
        if (static::usesTestingConcern(WithWorkbench::class)) {
155✔
104
            return Workbench::applicationHttpKernel() ?? 'Orchestra\Testbench\Http\Kernel';
24✔
105
        }
106

107
        return 'Orchestra\Testbench\Http\Kernel';
131✔
108
    }
109

110
    /**
111
     * Get application HTTP exception handler using Workbench.
112
     *
113
     * @param  \Illuminate\Foundation\Application  $app
114
     * @return string
115
     */
116
    protected function applicationExceptionHandlerUsingWorkbench($app): string
117
    {
118
        if (static::usesTestingConcern(WithWorkbench::class)) {
159✔
119
            return Workbench::applicationExceptionHandler() ?? 'Orchestra\Testbench\Exceptions\Handler';
24✔
120
        }
121

122
        return 'Orchestra\Testbench\Exceptions\Handler';
135✔
123
    }
124

125
    /**
126
     * Define or get the cached uses for test case.
127
     *
128
     * @return \Orchestra\Testbench\Contracts\Config|null
129
     */
130
    public static function cachedConfigurationForWorkbench()
131
    {
132
        return Workbench::configuration();
155✔
133
    }
134

135
    /**
136
     * Prepare the testing environment before the running the test case.
137
     *
138
     * @return void
139
     *
140
     * @codeCoverageIgnore
141
     */
142
    public static function setUpBeforeClassUsingWorkbench(): void
143
    {
144
        /** @var array{laravel: string|null} $config */
145
        $config = static::cachedConfigurationForWorkbench();
146

147
        if (
148
            ! \is_null($config['laravel'])
149
            && isset(static::$cachedTestCaseUses[WithWorkbench::class])
150
        ) {
151
            $_ENV['TESTBENCH_APP_BASE_PATH'] = $config['laravel'];
152
        }
153
    }
154

155
    /**
156
     * Clean up the testing environment before the next test case.
157
     *
158
     * @return void
159
     *
160
     * @codeCoverageIgnore
161
     */
162
    public static function tearDownAfterClassUsingWorkbench(): void
163
    {
164
        unset($_ENV['TESTBENCH_APP_BASE_PATH']);
165
    }
166
}
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