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

orchestral / canvas / 6185311258

14 Sep 2023 12:18PM UTC coverage: 86.458% (-3.5%) from 89.945%
6185311258

Pull #24

github

crynobone
wip

Signed-off-by: Mior Muhammad Zaki <crynobone@gmail.com>
Pull Request #24: Use Laravel Generator Preset

173 of 173 new or added lines in 11 files covered. (100.0%)

166 of 192 relevant lines covered (86.46%)

7.2 hits per line

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

87.5
/src/Console/ViewMakeCommand.php
1
<?php
2

3
namespace Orchestra\Canvas\Console;
4

5
use Illuminate\Support\Str;
6
use Orchestra\Canvas\GeneratorPreset;
7
use Symfony\Component\Console\Attribute\AsCommand;
8

9
#[AsCommand(name: 'make:view', description: 'Create a new view')]
10
class ViewMakeCommand extends \Illuminate\Foundation\Console\ViewMakeCommand
11
{
12
    /**
13
     * Resolve the default fully-qualified path to the stub.
14
     *
15
     * @param  string  $stub
16
     * @return string
17
     */
18
    protected function resolveDefaultStubPath($stub)
19
    {
20
        $preset = $this->generatorPreset();
2✔
21

22
        if ($preset instanceof GeneratorPreset) {
2✔
23
            return __DIR__.$stub;
2✔
24
        }
25

26
        return parent::resolveDefaultStubPath($stub);
×
27
    }
28

29
    /**
30
     * Create the matching test case if requested.
31
     *
32
     * @param  string  $path
33
     */
34
    protected function handleTestCreation($path): bool
35
    {
36
        if (! $this->option('test') && ! $this->option('pest')) {
2✔
37
            return false;
1✔
38
        }
39

40
        $preset = $this->generatorPreset();
1✔
41

42
        if (! $preset instanceof GeneratorPreset) {
1✔
43
            return parent::handleTestCreation($path);
×
44
        }
45

46
        $namespaceTestCase = $testCase = $preset->canvas()->config(
1✔
47
            'testing.extends.feature',
1✔
48
            $preset->canvas()->is('laravel') ? 'Tests\TestCase' : 'Orchestra\Testbench\TestCase'
1✔
49
        );
1✔
50

51
        $stub = $this->files->get($this->getTestStub());
1✔
52

53
        if (Str::startsWith($testCase, '\\')) {
1✔
54
            $stub = str_replace('NamespacedDummyTestCase', trim($testCase, '\\'), $stub);
×
55
        } else {
56
            $stub = str_replace('NamespacedDummyTestCase', $namespaceTestCase, $stub);
1✔
57
        }
58

59
        $contents = str_replace(
1✔
60
            ['{{ namespace }}', '{{ class }}', '{{ name }}', 'DummyTestCase'],
1✔
61
            [$this->testNamespace(), $this->testClassName(), $this->testViewName(), class_basename(trim($testCase, '\\'))],
1✔
62
            $stub,
1✔
63
        );
1✔
64

65
        $this->files->ensureDirectoryExists(\dirname($this->getTestPath()), 0755, true);
1✔
66

67
        return $this->files->put($this->getTestPath(), $contents) !== false;
1✔
68
    }
69
}
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