Esempio n. 1
0
 public function testWrongContentTypeThrowsInvalidResponseException()
 {
     $this->setExpectedException('Magium\\Mail\\Api\\InvalidResponseException');
     $builder = $this->getMockBuilder('Zend\\Http\\Client')->setMethods(['send']);
     $client = $builder->getMock();
     /* @var $client \Zend\Http\Client */
     $response = new Response();
     $response->setContent(json_encode(['error' => 'error message']));
     $response->setHeaders(Headers::fromString('Content-Type: wrong'));
     $client->expects($this->once())->method('send')->willReturn($response);
     $generator = new Generator(new Configuration(), $client, 'abcd');
     $generator->generate();
 }
Esempio n. 2
0
 public function testUrlIsRight()
 {
     $builder = $this->getMockBuilder('Zend\\Http\\Client')->setMethods(['send']);
     $client = $builder->getMock();
     /* @var $client \Zend\Http\Client */
     $response = new Response();
     $response->setContent(json_encode(['email' => '*****@*****.**']));
     $response->setHeaders(Headers::fromString('Content-Type: application/json'));
     $client->expects($this->once())->method('send')->willReturn($response);
     $configuration = new Configuration();
     $generator = new Generator($configuration, $client, 'abcd');
     $email = $generator->generate();
     self::assertEquals('*****@*****.**', $email);
     self::assertEquals($configuration->getApiEndpointUrl(), $client->getUri()->toString());
 }