1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Acacha\AdminLTETemplateLaravel\Tests; |
4
|
|
|
|
5
|
|
|
use Acacha\AdminLTETemplateLaravel\Console\InstallCommand; |
6
|
|
|
use PHPUnit\Framework\TestCase; |
7
|
|
|
use Symfony\Component\Console\Application; |
8
|
|
|
use Symfony\Component\Console\Tester\CommandTester; |
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* Class InstallCommandTest. |
12
|
|
|
*/ |
13
|
|
|
class InstallCommandTest extends TestCase |
14
|
|
|
{ |
15
|
|
|
/** @test */ |
16
|
|
|
public function testInstallCommand() |
17
|
|
|
{ |
18
|
|
|
$application = new Application(); |
19
|
|
|
$application->add(new InstallCommand()); |
20
|
|
|
|
21
|
|
|
$command = $application->find('install'); |
22
|
|
|
$commandTester = new CommandTester($command); |
23
|
|
|
|
24
|
|
|
$commandTester->execute([ |
25
|
|
|
'command' => $command->getName(), |
26
|
|
|
]); |
27
|
|
|
|
28
|
|
|
$output = $commandTester->getDisplay(); |
29
|
|
|
$this->assertContains('Running composer require acacha/admin-lte-template-laravel', $output); |
30
|
|
|
$this->assertContains('php artisan adminlte:publish', $output); |
31
|
|
|
$this->assertContains('composer require --dev laravel/dusk', $output); |
32
|
|
|
$this->assertContains('php artisan dusk:install', $output); |
33
|
|
|
} |
34
|
|
|
|
35
|
|
|
/** @test */ |
36
|
|
View Code Duplication |
public function testInstallDevCommand() |
|
|
|
|
37
|
|
|
{ |
38
|
|
|
$application = new Application(); |
39
|
|
|
$application->add(new InstallCommand()); |
40
|
|
|
|
41
|
|
|
$command = $application->find('install'); |
42
|
|
|
$commandTester = new CommandTester($command); |
43
|
|
|
|
44
|
|
|
$commandTester->execute([ |
45
|
|
|
'command' => $command->getName(), |
46
|
|
|
'--dev' => true, |
47
|
|
|
]); |
48
|
|
|
|
49
|
|
|
$output = $commandTester->getDisplay(); |
50
|
|
|
$this->assertContains('Running composer require acacha/admin-lte-template-laravel:dev-master', $output); |
51
|
|
|
$this->assertContains('php artisan adminlte:publish', $output); |
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** @test */ |
55
|
|
View Code Duplication |
public function testInstallNoAnsiCommand() |
|
|
|
|
56
|
|
|
{ |
57
|
|
|
$application = new Application(); |
58
|
|
|
$application->add(new InstallCommand()); |
59
|
|
|
|
60
|
|
|
$command = $application->find('install'); |
61
|
|
|
$commandTester = new CommandTester($command); |
62
|
|
|
|
63
|
|
|
$commandTester->execute([ |
64
|
|
|
'command' => $command->getName(), |
65
|
|
|
'--no-ansi' => true, |
66
|
|
|
]); |
67
|
|
|
|
68
|
|
|
$output = $commandTester->getDisplay(); |
69
|
|
|
$this->assertContains('--no-ansi', $output); |
70
|
|
|
} |
71
|
|
|
} |
72
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.