• 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

95.45
/src/Foundation/Console/Actions/GeneratesFile.php
1
<?php
2

3
namespace Orchestra\Testbench\Foundation\Console\Actions;
4

5
use Illuminate\Console\View\Components\Factory as ComponentsFactory;
6
use Illuminate\Filesystem\Filesystem;
7

8
class GeneratesFile extends Action
9
{
10
    /**
11
     * Construct a new action instance.
12
     *
13
     * @param  \Illuminate\Filesystem\Filesystem  $filesystem
14
     * @param  \Illuminate\Console\View\Components\Factory|null  $components
15
     * @param  bool  $force
16
     * @param  string|null  $workingPath
17
     */
18
    public function __construct(
19
        public Filesystem $filesystem,
20
        public ?ComponentsFactory $components = null,
21
        public bool $force = false,
22
        ?string $workingPath = null
23
    ) {
24
        $this->workingPath = $workingPath;
6✔
25
    }
26

27
    /**
28
     * Handle the action.
29
     *
30
     * @param  string|false|null  $from
31
     * @param  string|false|null  $to
32
     * @return void
33
     */
34
    public function handle($from, $to): void
35
    {
36
        if (! \is_string($from) || ! \is_string($to)) {
6✔
UNCOV
37
            return;
×
38
        }
39

40
        if (! $this->filesystem->exists($from)) {
6✔
41
            $this->components?->twoColumnDetail(
1✔
42
                \sprintf('Source file [%s] doesn\'t exists', $this->pathLocation($from)),
1✔
43
                '<fg=yellow;options=bold>SKIPPED</>'
1✔
44
            );
1✔
45

46
            return;
1✔
47
        }
48

49
        if (! $this->force && $this->filesystem->exists($to)) {
5✔
50
            $this->components?->twoColumnDetail(
2✔
51
                \sprintf('File [%s] already exists', $this->pathLocation($to)),
2✔
52
                '<fg=yellow;options=bold>SKIPPED</>'
2✔
53
            );
2✔
54

55
            return;
2✔
56
        }
57

58
        $this->filesystem->copy($from, $to);
3✔
59

60
        $gitKeepFile = \sprintf('%s/.gitkeep', \dirname($to));
3✔
61

62
        if ($this->filesystem->exists($gitKeepFile)) {
3✔
63
            $this->filesystem->delete($gitKeepFile);
2✔
64
        }
65

66
        $this->components?->task(
3✔
67
            \sprintf('File [%s] generated', $this->pathLocation($to))
3✔
68
        );
3✔
69
    }
70
}
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