Пример #1
0
 /**
  * Test to ensure that the call to perform an action works correctly
  */
 public function testPerformActionWorksSuccessfully()
 {
     $factory = new DropletFactory();
     $data = json_decode($this->ubuntuData, true);
     $droplet = $factory->getDroplet($data['droplet']);
     $headers = ['Content-type' => 'application/json'];
     $mockRequest = $this->getMockBuilder('\\GuzzleHttp\\Message\\Request')->disableOriginalConstructor()->getMock();
     $mockAction = $this->getMock('\\Billow\\Actions\\EnableBackups', ['getRequest', 'getBody']);
     $mockAction->expects($this->once())->method('getBody')->will($this->returnValue(json_encode(['type' => 'enable_backups'])));
     $mockAction->expects($this->once())->method('getRequest')->with($headers, json_encode(['type' => 'enable_backups']))->will($this->returnValue($mockRequest));
     $this->mockClient->expects($this->once())->method('send')->with($mockRequest)->will($this->returnValue($this->mockResponse));
     $service = new DropletService();
     $service->setClient($this->mockClient);
     $response = $service->performAction($droplet, $mockAction, $headers);
     $this->assertSame($response, $this->mockResponse);
 }
Пример #2
0
 /**
  * Test ensure that a runtime exception is thrown if an unknown distro is provided
  *
  * @expectedException \RuntimeException
  * @expectedExceptionMessage There is no droplet matching the image provided in the droplet info
  */
 public function testEnsureRuntimeExceptionIsThrownForUnknownDistro()
 {
     $factory = new DropletFactory();
     $data = $this->ubuntuData;
     $data['droplet']['image']['distribution'] = 'Made up distro';
     $droplet = $factory->getDroplet($data['droplet']);
 }