Ejemplo n.º 1
0
 function it_gets_the_balance(HttpAdapterInterface $adapter, Response $response, Stream $stream)
 {
     $params = ['key' => 'apiKey', 'format' => 'json', 'apiVersion' => Api::VERSION, 'method' => 'balance'];
     $result = ['result' => 'OK', 'balance' => 1000.0, 'currency' => 'HUF', 'balance-currency' => '1000 HUF', 'custom-services' => 0, 'monthlySpentBalance' => 0];
     $stream->getContents()->willReturn(json_encode($result));
     $response->getBody()->willReturn($stream);
     $url = sprintf('%s?%s', Api::ENDPOINT, http_build_query($params));
     $adapter->get($url)->willReturn($response);
     $this->get()->shouldReturnAnInstanceOf('First\\Seeme\\Entity\\Balance');
 }
Ejemplo n.º 2
0
 function it_throws_an_exception_when_ip_is_no_allowed(HttpAdapterInterface $adapter, Response $response, Stream $stream)
 {
     $params = ['key' => 'apiKey', 'format' => 'json', 'apiVersion' => Api::VERSION, 'ip' => '123.213.126.123', 'method' => 'setip'];
     $result = ['result' => 'ERR', 'message' => 'IP is not allowed', 'code' => 1];
     $stream->getContents()->willReturn(json_encode($result));
     $response->getBody()->willReturn($stream);
     $url = sprintf('%s?%s', Api::ENDPOINT, http_build_query($params));
     $adapter->get($url)->willReturn($response);
     $this->shouldThrow('First\\Seeme\\ApiException')->duringSet(2077589115);
 }
Ejemplo n.º 3
0
 function it_throws_an_exception_when_something_bad_happens(HttpAdapterInterface $adapter, Response $response, Stream $stream)
 {
     $params = ['key' => 'apiKey', 'format' => 'json', 'apiVersion' => Api::VERSION, 'number' => 36201234657, 'message' => 'This is a message', 'sender' => 'Sender', 'reference' => 1234, 'callbackParams' => [1, 2, 3], 'callback' => 'http://callback.uri'];
     $result = ['result' => 'ERR', 'message' => 'Something bad happened', 'code' => 1];
     $stream->getContents()->willReturn(json_encode($result));
     $response->getBody()->willReturn($stream);
     $url = sprintf('%s?%s', Api::ENDPOINT, http_build_query($params));
     $adapter->get($url)->willReturn($response);
     extract($params);
     $this->shouldThrow('First\\Seeme\\ApiException')->duringSend($number, $message, $sender, $reference, $callbackParams, $callback);
 }