Skip to content

Commit 0f6dc9a

Browse files
committed
StateHandler test
1 parent a69962b commit 0f6dc9a

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php declare(strict_types=1);
2+
3+
namespace ApiClients\Tests\Supervisord\CommandBus\Handler;
4+
5+
use ApiClients\Client\Supervisord\CommandBus\Command\StateCommand;
6+
use ApiClients\Client\Supervisord\CommandBus\Handler\StateHandler;
7+
use ApiClients\Client\Supervisord\Resource\StateInterface;
8+
use ApiClients\Foundation\Hydrator\Hydrator;
9+
use ApiClients\Tools\Services\XmlRpc\XmlRpcService;
10+
use ApiClients\Tools\TestUtilities\TestCase;
11+
use function React\Promise\resolve;
12+
13+
final class StateHandlerTest extends TestCase
14+
{
15+
public function testCommand()
16+
{
17+
$state = [
18+
'statecode' => 1,
19+
'statecname' => 'GOOD',
20+
];
21+
22+
$resource = $this->prophesize(StateInterface::class)->reveal();
23+
24+
$service = $this->prophesize(XmlRpcService::class);
25+
$service->call('supervisor.getState')->shouldBeCalled()->willReturn(resolve($state));
26+
27+
$hydrator = $this->prophesize(Hydrator::class);
28+
$hydrator->hydrate(StateInterface::HYDRATE_CLASS, $state)->shouldBeCalled()->willReturn($resource);
29+
30+
$handler = new StateHandler($service->reveal(), $hydrator->reveal());
31+
$result = $this->await($handler->handle(new StateCommand()));
32+
33+
self::assertSame($resource, $result);
34+
}
35+
}

0 commit comments

Comments
 (0)