Skip to content

Commit c952316

Browse files
committed
add some tests
1 parent 37b71cf commit c952316

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

test/IO/InputTest.php

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace Inhere\ConsoleTest\IO;
4+
5+
use Inhere\Console\IO\Input;
6+
use PHPUnit\Framework\TestCase;
7+
8+
/**
9+
* Class InputTest
10+
*
11+
* @package Inhere\ConsoleTest\IO
12+
*/
13+
class InputTest extends TestCase
14+
{
15+
public function testBasic(): void
16+
{
17+
$in = new Input(['./bin/app', 'cmd', 'val0', 'val1']);
18+
19+
$this->assertSame('./bin/app', $in->getScript());
20+
$this->assertSame('app', $in->getScriptName());
21+
$this->assertSame('cmd', $in->getCommand());
22+
}
23+
24+
public function testArguments(): void
25+
{
26+
$in = new Input(['./bin/app', 'cmd', 'val0', 'val1']);
27+
28+
$this->assertTrue($in->hasArg(0));
29+
$this->assertSame('val0', $in->getArgument(0));
30+
$this->assertSame('val1', $in->getArgument(1));
31+
}
32+
33+
public function testBindArgument(): void
34+
{
35+
$in = new Input(['./bin/app', 'cmd', 'val0', 'val1']);
36+
37+
$this->assertTrue($in->hasArg(0));
38+
$this->assertFalse($in->hasArg('arg0'));
39+
$this->assertFalse($in->hasArg('arg1'));
40+
41+
$in->bindArgument('arg0', 0);
42+
$this->assertTrue($in->hasArg('arg0'));
43+
44+
$in->bindArguments(['arg1' => 1]);
45+
$this->assertTrue($in->hasArg('arg1'));
46+
}
47+
}

0 commit comments

Comments
 (0)