Skip to content

Commit 70dcf94

Browse files
committed
Update CSP tests
1 parent 137ff5e commit 70dcf94

File tree

2 files changed

+27
-12
lines changed

2 files changed

+27
-12
lines changed

tests/CSPMock.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?php declare(strict_types=1);
2+
/*
3+
* This file is part of Aplus Framework HTTP Library.
4+
*
5+
* (c) Natan Felles <natanfelles@gmail.com>
6+
*
7+
* For the full copyright and license information, please view the LICENSE
8+
* file that was distributed with this source code.
9+
*/
10+
namespace Tests\HTTP;
11+
12+
use Framework\HTTP\CSP;
13+
14+
class CSPMock extends CSP
15+
{
16+
public function getNonceAttr(string $type) : string
17+
{
18+
return parent::getNonceAttr($type);
19+
}
20+
21+
public function sanitizeValue(string $value) : string
22+
{
23+
return parent::sanitizeValue($value);
24+
}
25+
}

tests/CSPTest.php

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -178,12 +178,7 @@ public function testStyleNonceAttr() : void
178178

179179
public function testInvalidNonceAttr() : void
180180
{
181-
$csp = new class() extends CSP {
182-
public function getNonceAttr(string $type) : string
183-
{
184-
return parent::getNonceAttr($type);
185-
}
186-
};
181+
$csp = new CSPMock();
187182
$this->expectException(\InvalidArgumentException::class);
188183
$this->expectExceptionMessage('Invalid CSP directive: foo');
189184
$csp->getNonceAttr('foo');
@@ -283,12 +278,7 @@ public function testMakeHash() : void
283278

284279
public function testSanitizeValue() : void
285280
{
286-
$csp = new class() extends CSP {
287-
public function sanitizeValue(string $value) : string
288-
{
289-
return parent::sanitizeValue($value);
290-
}
291-
};
281+
$csp = new CSPMock();
292282
self::assertSame("'none'", $csp->sanitizeValue('none'));
293283
self::assertSame("'self'", $csp->sanitizeValue('self'));
294284
self::assertSame("'strict-dynamic'", $csp->sanitizeValue('strict-dynamic'));

0 commit comments

Comments
 (0)