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

orchestral / testbench-core / 11985659211

23 Nov 2024 08:28AM UTC coverage: 91.958% (-0.03%) from 91.991%
11985659211

push

github

crynobone
wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>

6 of 7 new or added lines in 1 file covered. (85.71%)

1212 of 1318 relevant lines covered (91.96%)

61.81 hits per line

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

88.0
/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\Foundation\Env;
8
use Orchestra\Testbench\Workbench\Workbench;
9
use Symfony\Component\Finder\Finder;
10
use Workbench\App\Models\User;
11

12
use function Orchestra\Testbench\workbench_path;
13

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

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

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

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

61
        LazyCollection::make(function () {
30✔
62
            $path = workbench_path('config');
30✔
63

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

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

75
        /** @var class-string<\Illuminate\Foundation\Auth\User>|false $userModel */
76
        $userModel = match (true) {
30✔
77
            Env::has('AUTH_MODEL') => Env::get('AUTH_MODEL'),
30✔
78
            class_exists(User::class) => User::class,
30✔
79
            default => false,
30✔
80
        };
30✔
81

82
        if ($userModel !== false && is_a($userModel, 'Illuminate\Foundation\Auth\User')) {
30✔
NEW
83
            $configurations->put('auth.providers.users.model', $userModel);
×
84
        }
85

86
        return $configurations;
30✔
87
    }
88
}
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