-
Notifications
You must be signed in to change notification settings - Fork 440
/
Copy pathUseCasesTest.php
41 lines (31 loc) · 1.21 KB
/
UseCasesTest.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
<?php
namespace Enqueue\AsyncCommand\Tests\Functional;
use Enqueue\AsyncCommand\CommandResult;
use Enqueue\AsyncCommand\RunCommand;
use Enqueue\AsyncCommand\RunCommandProcessor;
use Enqueue\Consumption\Result;
use Enqueue\NoEffect\NullContext;
use Enqueue\NoEffect\NullMessage;
use Interop\Queue\Message;
use PHPUnit\Framework\TestCase;
/**
* @group functional
*/
class UseCasesTest extends TestCase
{
public function testRunSimpleCommandAndReturnOutput()
{
$runCommand = new RunCommand('foo');
$Message = new NullMessage(json_encode($runCommand));
$Message->setReplyTo('aReplyToQueue');
$processor = new RunCommandProcessor(__DIR__);
$result = $processor->process($Message, new NullContext());
$this->assertInstanceOf(Result::class, $result);
$this->assertInstanceOf(Message::class, $result->getReply());
$replyMessage = $result->getReply();
$commandResult = CommandResult::jsonUnserialize($replyMessage->getBody());
$this->assertSame(123, $commandResult->getExitCode());
$this->assertSame('Command Output', $commandResult->getOutput());
$this->assertSame('Command Error Output', $commandResult->getErrorOutput());
}
}