Same filename and directory in other branches
- 8.9.x core/modules/node/tests/src/Unit/PageCache/DenyNodePreviewTest.php
- 9 core/modules/node/tests/src/Unit/PageCache/DenyNodePreviewTest.php
Namespace
Drupal\Tests\node\Unit\PageCache
File
core/modules/node/tests/src/Unit/PageCache/DenyNodePreviewTest.php
View source
<?php
declare (strict_types=1);
namespace Drupal\Tests\node\Unit\PageCache;
use Drupal\Core\PageCache\ResponsePolicyInterface;
use Drupal\node\PageCache\DenyNodePreview;
use Drupal\Tests\UnitTestCase;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
class DenyNodePreviewTest extends UnitTestCase {
protected $policy;
protected $request;
protected $response;
protected $routeMatch;
protected function setUp() : void {
parent::setUp();
$this->routeMatch = $this
->createMock('Drupal\\Core\\Routing\\RouteMatchInterface');
$this->policy = new DenyNodePreview($this->routeMatch);
$this->response = new Response();
$this->request = new Request();
}
public function testPrivateImageStyleDownloadPolicy($expected_result, $route_name) {
$this->routeMatch
->expects($this
->once())
->method('getRouteName')
->willReturn($route_name);
$actual_result = $this->policy
->check($this->response, $this->request);
$this
->assertSame($expected_result, $actual_result);
}
public static function providerPrivateImageStyleDownloadPolicy() {
return [
[
ResponsePolicyInterface::DENY,
'entity.node.preview',
],
[
NULL,
'some.other.route',
],
[
NULL,
NULL,
],
[
NULL,
FALSE,
],
[
NULL,
TRUE,
],
[
NULL,
new \StdClass(),
],
[
NULL,
[
1,
2,
3,
],
],
];
}
}
Classes