ZendSpec.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace spec\Supervisor\Connector;
  3. use Zend\XmlRpc\Client;
  4. use Zend\XmlRpc\Client\Exception\FaultException;
  5. use PhpSpec\ObjectBehavior;
  6. class ZendSpec extends ObjectBehavior
  7. {
  8. function let(Client $client)
  9. {
  10. $this->beConstructedWith($client);
  11. }
  12. function it_is_initializable()
  13. {
  14. $this->shouldHaveType('Supervisor\Connector\Zend');
  15. }
  16. function it_is_a_conncetor()
  17. {
  18. $this->shouldImplement('Supervisor\Connector');
  19. }
  20. function it_calls_a_method(Client $client)
  21. {
  22. $client->call('namespace.method', [])->willReturn('response');
  23. $this->call('namespace', 'method')->shouldReturn('response');
  24. }
  25. function it_throws_an_exception_when_the_call_fails(Client $client)
  26. {
  27. $e = new FaultException('Invalid response', 100);
  28. $client->call('namespace.method', [])->willThrow($e);
  29. $this->shouldThrow('Supervisor\Exception\Fault')->duringCall('namespace', 'method');
  30. }
  31. function it_throws_a_known_exception_when_proper_fault_returned(Client $client)
  32. {
  33. $e = new FaultException('UNKNOWN_METHOD', 1);
  34. $client->call('namespace.method', [])->willThrow($e);
  35. $this->shouldThrow('Supervisor\Exception\Fault\UnknownMethod')->duringCall('namespace', 'method');
  36. }
  37. }