-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCommandTest.php
More file actions
64 lines (51 loc) · 1.51 KB
/
CommandTest.php
File metadata and controls
64 lines (51 loc) · 1.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
namespace Rareloop\Hatchet\Test;
use Mockery;
use PHPUnit\Framework\TestCase;
use Rareloop\Hatchet\Commands\Command;
use Rareloop\Lumberjack\Application;
use Symfony\Component\Console\Application as ConsoleApplication;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
class CommandTest extends TestCase
{
use MockeryPHPUnitIntegration;
/** @test */
public function can_create_a_command_with_a_name()
{
$app = new Application;
$command = new CommandWithName($app);
$this->assertSame('test:command', $command->getName());
}
/** @test */
public function can_create_a_command_from_signature_variable()
{
$app = new Application;
$command = new CommandWithSignature($app);
$definition = $command->getDefinition();
$this->assertSame('test:command', $command->getName());
$this->assertTrue($definition->hasOption('option'));
}
/** @test */
public function can_add_description_from_class_variable()
{
$app = new Application;
$command = new CommandWithDescription($app);
$this->assertSame('testing123', $command->getDescription());
}
}
class CommandWithName extends Command
{
protected $name = 'test:command';
}
class CommandWithSignature extends Command
{
protected $signature = 'test:command {name} {--option}';
}
#[AsCommand(
name: 'test:command',
description: 'testing123'
)]
class CommandWithDescription extends Command
{
}