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

Removes Zend\Expressive\Authentication\ResponsePrototypeTrait #17

Merged
merged 7 commits into from
Feb 27, 2018

Conversation

wshafer
Copy link
Contributor

@wshafer wshafer commented Feb 27, 2018

Using PR: zendframework/zend-expressive#561 as a guide this PR removes the ResponsePrototypeTrait in favor of factoryFactories.

Fixes issue: #16

@wshafer
Copy link
Contributor Author

wshafer commented Feb 27, 2018

Ping @webimpress


/**
* Constructor
*
* @param ResourceServer $resourceServer
* @param ResponseInterface $responsePrototype
*/
public function __construct(ResourceServer $resourceServer, ResponseInterface $responsePrototype)
public function __construct(ResourceServer $resourceServer, callable $responseFactory)
Copy link
Member

Choose a reason for hiding this comment

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

Please remove the whole PHPDoc on __construct. It's not updated and we are not using them when there is no any additional information in it.

*/
protected $responsePrototype;
protected $responseFactory;

/**
* Constructor
*
* @param AuthorizationServer $server
* @param ResponseInterface $responsePrototype
*/
Copy link
Member

Choose a reason for hiding this comment

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

The same here, please remove PHPDocs

@@ -10,6 +10,7 @@

namespace ZendTest\Expressive\Authentication\OAuth2;

use function foo\func;
Copy link
Member

Choose a reason for hiding this comment

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

Why we need it? Please remove.

$this->response->reveal()
function () {
return $this->response->reveal();
}
Copy link
Member

Choose a reason for hiding this comment

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

I would add property in that class (and also in other tests), because we have the same usage there many times - and use then just $this->responseFactory.

- Adds property declarations, with annotations detailing types.
- Use a `$responseFactory` property instead of creating a factory each
  time the SUT is instantiated.
->willReturn(false);
->get(ResponseInterface::class)
->willReturn(function () {
});
Copy link
Member

Choose a reason for hiding this comment

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

Also here we can use this->responseFactory

Copy link
Member

Choose a reason for hiding this comment

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

No, we cannot, as it is not defined in this class.

In point of fact, this test likely needs to be re-written, as it's supposedly testing that the service can be created if the response service is missing. We should either test that an exception occurs if the service is missing (as get() will raise an exception), or that a TypeError occurs due to an invalid service. I'll make those changes shortly.

Copy link
Member

Choose a reason for hiding this comment

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

->willReturn(false);
->get(ResponseInterface::class)
->willReturn(function () {
});
Copy link
Member

Choose a reason for hiding this comment

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

And here - this->responseFactory

Copy link
Member

Choose a reason for hiding this comment

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

Ok, here is not defined :)

Ensures that the factories are testing expected behavior:

- TypeError should be raised for a non-callable response factory.
- TypeError should be raised for a response instance returned instead of a response factory.
@weierophinney weierophinney merged commit 6caabba into zendframework:release-1.0.0 Feb 27, 2018
weierophinney added a commit that referenced this pull request Feb 27, 2018
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.

3 participants