Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
k0ka committed Feb 1, 2024
1 parent 384cd51 commit 7a64783
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
1 change: 0 additions & 1 deletion src/Common/Api/OperatorTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@ protected function sendRequest(Operation $operation, array $userValues = [], boo
}

$options['openstack.skip_auth'] = $operation->getSkipAuth();
print_r($options);

return $this->client->$method($operation->getMethod(), $uri, $options);
}
Expand Down
19 changes: 13 additions & 6 deletions tests/unit/Common/Api/OperatorTraitTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function test_it_returns_operations()

public function test_it_sends_a_request_when_operations_are_executed()
{
$this->client->request('GET', 'test', ['headers' => []])->willReturn(new Response());
$this->mockRequest('GET', 'test', new Response());

$this->operator->execute($this->def, []);

Expand All @@ -53,7 +53,10 @@ public function test_it_sends_a_request_when_operations_are_executed()

public function test_it_sends_a_request_when_async_operations_are_executed()
{
$this->client->requestAsync('GET', 'test', ['headers' => []])->willReturn(new Promise());
$this->client
->requestAsync('GET', 'test', ['headers' => [], 'openstack.skip_auth' => false])
->shouldBeCalled()
->willReturn(new Promise());

$this->operator->executeAsync($this->def, []);

Expand All @@ -75,13 +78,13 @@ public function test_it_wraps_sequential_ops_in_promise_when_async_is_appended_t

public function test_it_throws_exception_when_async_is_called_on_a_non_existent_method()
{
$this->expectException(\RuntimeException::class);
$this->expectException(\RuntimeException::class);
$this->operator->fooAsync();
}

public function test_undefined_methods_result_in_error()
{
$this->expectException(\Exception::class);
$this->expectException(\Exception::class);
$this->operator->foo();
}

Expand All @@ -103,16 +106,20 @@ public function test_it_populates_models_from_arrays()

public function test_guzzle_options_are_forwarded()
{
$this->client->request('GET', 'test', ['headers' => [], 'stream' => true])->willReturn(new Response());
$this->client
->request('GET', 'test', ['headers' => [], 'openstack.skip_auth' => false, 'stream' => true])
->shouldBeCalled()
->willReturn(new Response());

$this->operator->execute($this->def, [
'requestOptions' => ['stream' => true]
'requestOptions' => ['stream' => true],
]);

$this->addToAssertionCount(1);
}
}


class TestResource extends AbstractResource
{
}
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/Identity/v2/ServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public function test_it_authenticates()
'tenantId' => $options['tenantId'],
]];

$this->mockRequest('POST', 'tokens', 'token-post', $expectedJson, [], true;
$this->mockRequest('POST', 'tokens', 'token-post', $expectedJson, [], true);

[$token, $baseUrl] = $this->service->authenticate($options);

Expand Down

0 comments on commit 7a64783

Please sign in to comment.