Subversion-Projekte lars-tiefland.laravel_shop

Revision

Details | Letzte Änderung | Log anzeigen | RSS feed

Revision Autor Zeilennr. Zeile
148 lars 1
<?php
2
 
3
namespace Illuminate\Console\Concerns;
4
 
5
use Illuminate\Support\Str;
6
use Symfony\Component\Console\Input\InputOption;
7
 
8
trait CreatesMatchingTest
9
{
10
    /**
11
     * Add the standard command options for generating matching tests.
12
     *
13
     * @return void
14
     */
15
    protected function addTestOptions()
16
    {
17
        foreach (['test' => 'PHPUnit', 'pest' => 'Pest'] as $option => $name) {
18
            $this->getDefinition()->addOption(new InputOption(
19
                $option,
20
                null,
21
                InputOption::VALUE_NONE,
22
                "Generate an accompanying {$name} test for the {$this->type}"
23
            ));
24
        }
25
    }
26
 
27
    /**
28
     * Create the matching test case if requested.
29
     *
30
     * @param  string  $path
31
     * @return bool
32
     */
33
    protected function handleTestCreation($path)
34
    {
35
        if (! $this->option('test') && ! $this->option('pest')) {
36
            return false;
37
        }
38
 
39
        return $this->callSilent('make:test', [
40
            'name' => Str::of($path)->after($this->laravel['path'])->beforeLast('.php')->append('Test')->replace('\\', '/'),
41
            '--pest' => $this->option('pest'),
42
        ]) == 0;
43
    }
44
}