示例#1
0
 /**
  * Test runAsyncAction method with a DELETE request
  */
 public function testRunAsyncActionDelete()
 {
     $mock = new MockHandler([new Response(200, ['Content-Type' => 'application/json'], '{
                 "id": 123456,
                 "url": "https://syrup-testing.keboola.com/queue/job/123456",
                 "status": "waiting"
             }'), new Response(200, ['Content-Type' => 'application/json'], '{
                 "id": 123456,
                 "status": "processing"
             }'), new Response(200, ['Content-Type' => 'application/json'], '{
                 "id": 123456,
                 "status": "success"
             }')]);
     // Add the history middleware to the handler stack.
     $container = [];
     $history = Middleware::history($container);
     $stack = HandlerStack::create($mock);
     $stack->push($history);
     $client = new Client(['token' => 'test', 'handler' => $stack, 'runId' => 'runIdTest', 'super' => 'provisioning']);
     $response = $client->runAsyncAction("async/docker/1", "DELETE");
     /** @var Request $request */
     $request = $container[0]['request'];
     $this->assertEquals("https://syrup.keboola.com/provisioning/async/docker/1", $request->getUri()->__toString());
     $this->assertEquals("DELETE", $request->getMethod());
     $this->assertEquals('[]', $request->getBody()->read(1000));
     $this->assertEquals("test", $request->getHeader("x-storageapi-token")[0]);
     $this->assertEquals("runIdTest", $request->getHeader("x-kbc-runid")[0]);
     $this->assertCount(3, $container);
     $this->assertEquals("success", $response["status"]);
 }