Skip to content

Conversation

@egorzot
Copy link
Contributor

@egorzot egorzot commented Dec 24, 2020

Closes #148

@egorzot egorzot requested a review from sspat December 24, 2020 15:48
@egorzot egorzot self-assigned this Dec 24, 2020
@sspat
Copy link
Contributor

sspat commented Dec 28, 2020

@egorzot please improve coverage

return new class implements SetRequest, RequestHandler {
public function setRequest(Request $request): void
{
throw new Exception('test request was set');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be tested without exceptions, by creating a getter on this class and asserting that it returns the expected response object after the controller is executed.

return new class implements SetClientIp, RequestHandler {
public function setClientIp(string $ip): void
{
throw new Exception('test ip was set');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This can be tested without exceptions, by creating a getter on this class and asserting that it returns the expected ip address after the controller is executed.


$this->expectException(Throwable::class);
$this->expectException(Throwable::class);
$this->expectExceptionMessage('"TestClass" has 0 public methods, exactly one expected');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe an anonymous class can be used here and get_class to assert it's name?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Unit tests for \OnMoon\OpenApiServerBundle\Controller\ApiController

3 participants