Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Added MiddlewarePipeInterface as abstraction layer for MiddlewarePipe #146

Merged
merged 6 commits into from
Jan 24, 2018
Merged

Added MiddlewarePipeInterface as abstraction layer for MiddlewarePipe #146

merged 6 commits into from
Jan 24, 2018

Conversation

michalbundyra
Copy link
Member

@michalbundyra michalbundyra commented Jan 23, 2018

MiddlewarePipe is a final class, so we need to have abstraction layer to make mocking easy

Fixes #144

MiddlewarePipe is a final class, so we need to have abstraction layer
to make mocking easy

Fixes #144
Copy link
Member

@weierophinney weierophinney left a comment

Choose a reason for hiding this comment

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

Very much a 👍 ; will merge in a bit and update the docs when I do.

Check if it implements MiddlewarePipeInterface and if all public methods
(not special methods) are defined in MiddlewarePipeInterface.
@michalbundyra
Copy link
Member Author

@weierophinney - I've added unit test into this PR, please have a look

$pipeline = new MiddlewarePipe();

$r = new ReflectionObject($pipeline);
$methods = $r->getMethods(\ReflectionMethod::IS_PUBLIC);
Copy link
Member

Choose a reason for hiding this comment

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

Import ReflectionMethod, please.

@@ -179,4 +182,31 @@ public function testHandleProcessesEnqueuedMiddleware()

$this->assertSame($response, $pipeline->handle($this->request));
}

public function testMiddlewarePipeIsInstanceOfMiddlewarePipeInterface()
Copy link
Member

Choose a reason for hiding this comment

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

I'd rename this to testMiddlewarePipeOnlyImplementsMiddlewarePipeInterfaceApi(), as that's what it's really doing.

Honestly, I'm not 100% certain we need this to be as thorough as it is; checking that MiddlewarePipe instanceof MiddlewarePipeInterface is likely enough for our purposes. There may be reasons to add additional public methods down the line, primarily to provide optional collaborators, that would invalidate this test otherwise.

Copy link
Member Author

Choose a reason for hiding this comment

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

@weierophinney

There may be reasons to add additional public methods down the line, primarily to provide optional collaborators, that would invalidate this test otherwise.

And this was the reason why I've created that test as thorough as it is. I think any public method added into that class, should be also defined in the abstraction later. This is the whole point of that PR.
If test fails, it will show us that something is changed, and we will have chance to think again if it's really needed there.

Copy link
Member

Choose a reason for hiding this comment

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

I'm convinced. Thanks for the feedback!

@weierophinney weierophinney merged commit c16cb6e into zendframework:release-3.0.0 Jan 24, 2018
weierophinney added a commit that referenced this pull request Jan 24, 2018
@weierophinney
Copy link
Member

Thanks, @webimpress!

@michalbundyra michalbundyra deleted the middleware-pipe-interface branch January 24, 2018 18:19
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants