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

orchestral / testbench-core / 10483300407

21 Aug 2024 04:05AM UTC coverage: 92.107%. Remained the same
10483300407

Pull #222

github

web-flow
Merge 7c7cf8624 into 9b4f48094
Pull Request #222: [7.x] Utilise `Orchestra\Testbench\join_paths`

11 of 14 new or added lines in 7 files covered. (78.57%)

1132 of 1229 relevant lines covered (92.11%)

60.72 hits per line

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

88.89
/src/Bootstrap/LoadConfigurationWithWorkbench.php
1
<?php
2

3
namespace Orchestra\Testbench\Bootstrap;
4

5
use Illuminate\Support\Collection;
6
use Illuminate\Support\LazyCollection;
7
use Orchestra\Testbench\Workbench\Workbench;
8
use Symfony\Component\Finder\Finder;
9

10
use function Orchestra\Testbench\workbench_path;
11

12
/**
13
 * @internal
14
 */
15
class LoadConfigurationWithWorkbench extends LoadConfiguration
16
{
17
    /**
18
     * Determine if workbench config file should be loaded.
19
     *
20
     * @var bool
21
     */
22
    protected $usesWorkbenchConfigFile = false;
23

24
    /**
25
     * Construct a new bootstrap class.
26
     */
27
    public function __construct()
28
    {
29
        $this->usesWorkbenchConfigFile = (Workbench::configuration()->getWorkbenchDiscoversAttributes()['config'] ?? false)
28✔
30
            && is_dir(workbench_path('config'));
28✔
31
    }
32

33
    /**
34
     * Resolve the configuration file.
35
     *
36
     * @param  string  $path
37
     * @param  string  $key
38
     * @return string
39
     */
40
    protected function resolveConfigurationFile(string $path, string $key): string
41
    {
42
        return $this->usesWorkbenchConfigFile === true && is_file(workbench_path('config', "{$key}.php"))
28✔
NEW
43
            ? workbench_path('config', "{$key}.php")
×
44
            : $path;
28✔
45
    }
46

47
    /**
48
     * Extend the loaded configuration.
49
     *
50
     * @param  \Illuminate\Support\Collection  $configurations
51
     * @return \Illuminate\Support\Collection
52
     */
53
    protected function extendsLoadedConfiguration(Collection $configurations): Collection
54
    {
55
        if ($this->usesWorkbenchConfigFile === false) {
28✔
56
            return $configurations;
×
57
        }
58

59
        LazyCollection::make(function () {
28✔
60
            $path = workbench_path('config');
28✔
61

62
            foreach (Finder::create()->files()->name('*.php')->in($path) as $file) {
28✔
63
                $directory = $this->getNestedDirectory($file, $path);
28✔
64

65
                yield $directory.basename($file->getRealPath(), '.php') => $file->getRealPath();
28✔
66
            }
67
        })->reject(static function ($path, $key) use ($configurations) {
28✔
68
            return $configurations->has($key);
28✔
69
        })->each(static function ($path, $key) use ($configurations) {
28✔
70
            $configurations->put($key, $path);
28✔
71
        });
28✔
72

73
        return $configurations;
28✔
74
    }
75
}
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