generated from yiisoft/package-template
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
88 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
echo 'failed' | ||
exit $1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Yiisoft\Yii\Debug\Api\Tests\Unit\Inspector; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Yiisoft\Yii\Debug\Api\Inspector\ApplicationState; | ||
|
||
final class ApplicationStateTest extends TestCase | ||
{ | ||
public function testStatus(): void | ||
{ | ||
$this->assertEquals([], ApplicationState::$params); | ||
|
||
ApplicationState::$params = ['key' => 'value']; | ||
$this->assertEquals(['key' => 'value'], ApplicationState::$params); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Yiisoft\Yii\Debug\Api\Tests\Unit\Inspector\Command; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Yiisoft\Aliases\Aliases; | ||
use Yiisoft\Yii\Debug\Api\Inspector\Command\BashCommand; | ||
use Yiisoft\Yii\Debug\Api\Inspector\CommandResponse; | ||
|
||
final class BashCommandTest extends TestCase | ||
{ | ||
public function testSuccess(): void | ||
{ | ||
$aliases = new Aliases([ | ||
'@root' => __DIR__, | ||
]); | ||
$command = new BashCommand($aliases, ['echo', 'test']); | ||
|
||
$response = $command->run(); | ||
|
||
$this->assertSame(CommandResponse::STATUS_OK, $response->getStatus()); | ||
$this->assertSame('test' . PHP_EOL, $response->getResult()); | ||
$this->assertSame([], $response->getErrors()); | ||
} | ||
|
||
public function testError(): void | ||
{ | ||
$aliases = new Aliases([ | ||
'@root' => dirname(__DIR__, 3) . '/Support/Application', | ||
]); | ||
$command = new BashCommand($aliases, ['bash', 'fail.sh', '1']); | ||
|
||
$response = $command->run(); | ||
|
||
$this->assertSame(CommandResponse::STATUS_ERROR, $response->getStatus()); | ||
$this->assertSame('failed' . PHP_EOL, $response->getResult()); | ||
$this->assertSame([], $response->getErrors()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Yiisoft\Yii\Debug\Api\Tests\Unit\Inspector; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
use Yiisoft\Yii\Debug\Api\Inspector\CommandResponse; | ||
|
||
final class CommandResponseTest extends TestCase | ||
{ | ||
public function testStatus(): void | ||
{ | ||
$response = new CommandResponse(CommandResponse::STATUS_OK, 'result', ['errors']); | ||
|
||
$this->assertSame(CommandResponse::STATUS_OK, $response->getStatus()); | ||
$this->assertSame('result', $response->getResult()); | ||
$this->assertSame(['errors'], $response->getErrors()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters