public function AuthcacheP13nTestDefaultRequestHandler::testDefaultRequestHandlerWithRequestFilter in Authenticated User Page Caching (Authcache) 7.2
Test handler with request filter.
File
- modules/
authcache_p13n/ tests/ authcache_p13n.request-handler.test, line 108 - Define unit tests for request handler.
Class
- AuthcacheP13nTestDefaultRequestHandler
- Test cases for default request handler.
Code
public function testDefaultRequestHandlerWithRequestFilter() {
$filters = array(
'request' => array(
new AuthcacheP13nTestFilterStub($this->stubObserver),
new AuthcacheP13nTestFilterStub($this->stubObserver),
),
);
$context_providers = array();
$params = array(
'some' => 'args',
);
// Setup expectations.
$first_filter = $this->stubObserver
->method($filters['request'][0], 'filter', array(
'some' => 'filtered args',
))
->expect(AuthcacheP13nTestStubVerifyer::once())
->expect(AuthcacheP13nTestStubVerifyer::args(array(
'request',
$params,
)));
$second_filter = $this->stubObserver
->method($filters['request'][1], 'filter', array(
'some' => 'args after second filter',
))
->expect(AuthcacheP13nTestStubVerifyer::once())
->expect(AuthcacheP13nTestStubVerifyer::args(array(
'request',
array(
'some' => 'filtered args',
),
)));
$validate = $this->stubObserver
->method($this->requestValidator, 'validate')
->expect(AuthcacheP13nTestStubVerifyer::once())
->expect(AuthcacheP13nTestStubVerifyer::args(array(
array(
'some' => 'args after second filter',
),
)));
// Run handler.
$handler = new AuthcacheP13nDefaultRequestHandler($this->coreService, $this->requestValidator, $this->contentBuilder, $this->contentEncoder, $filters, $context_providers);
ob_start();
$handler
->handle($params);
ob_end_clean();
// Verify stubs.
$this
->assert($first_filter
->verify($message), $message);
$this
->assert($second_filter
->verify($message), $message);
$this
->assert($validate
->verify($message), $message);
}