-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ExceptionTest.php
44 lines (33 loc) · 1.18 KB
/
ExceptionTest.php
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
<?php
use Illuminate\Console\Command;
use Thettler\LaravelConsoleToolkit\Attributes\Argument;
use Thettler\LaravelConsoleToolkit\Concerns\UsesConsoleToolkit;
use Thettler\LaravelConsoleToolkit\Exceptions\InvalidTypeException;
it('Inputs need an type', function () {
$command = new class () extends Command {
use UsesConsoleToolkit;
protected $name = 'test';
#[Argument]
public $requiredArgument;
public function handle()
{
}
};
$this->callCommand($command, [
'requiredArgument' => 'Argument_Required',
]);
})->throws(InvalidTypeException::class, 'A type is required for the console input "requiredArgument".');
it('Inputs only allows named types an type', function () {
$command = new class () extends Command {
use UsesConsoleToolkit;
protected $name = 'test';
#[Argument]
public string|int $requiredArgument;
public function handle()
{
}
};
$this->callCommand($command, [
'requiredArgument' => 'Argument_Required',
]);
})->throws(InvalidTypeException::class, 'Only named types can be used for the console input "requiredArgument".');