コード例 #1
0
 public function test_it_halts_when_user_provided_limit_is_reached()
 {
     $this->client->request('GET', 'servers', ['query' => ['limit' => 2], 'headers' => []])->shouldBeCalled()->willReturn($this->getFixture('servers-page1'));
     $count = 0;
     $api = new ComputeV2Api();
     foreach ($this->resource->enumerate($api->getServers(), ['limit' => 2]) as $item) {
         $count++;
     }
     $this->assertEquals(2, $count);
 }
コード例 #2
0
 public function test_it_predicts_resources_key_without_explicit_property()
 {
     $this->client->request('GET', 'servers', ['query' => ['limit' => 2], 'headers' => []])->shouldBeCalled()->willReturn($this->getFixture('servers-page1'));
     $count = 0;
     $api = new ComputeV2Api();
     $resource = new Server($this->client->reveal(), new $api());
     foreach ($resource->enumerate($api->getServers(), ['limit' => 2]) as $item) {
         $count++;
     }
     $this->assertEquals(2, $count);
 }
コード例 #3
0
 public function test_it_executes_operations_until_a_204_is_received()
 {
     $this->client->request('GET', 'servers', ['headers' => []])->shouldBeCalled()->willReturn($this->getFixture('servers-page1'));
     $this->client->request('GET', 'servers', ['query' => ['marker' => '5'], 'headers' => []])->shouldBeCalled()->willReturn(new Response(204));
     $count = 0;
     $api = new ComputeV2Api();
     foreach ($this->resource->enumerate($api->getServers()) as $item) {
         $count++;
         $this->assertInstanceOf(TestResource::class, $item);
     }
     $this->assertEquals(5, $count);
 }