コード例 #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);
 }