-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from Flowpack/add-tests
TASK: add tests
- Loading branch information
Showing
16 changed files
with
537 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: CI | ||
|
||
on: [ push ] | ||
|
||
jobs: | ||
phpunit: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- uses: php-actions/composer@v6 | ||
|
||
- name: PHPUnit Tests | ||
uses: php-actions/phpunit@v4 | ||
with: | ||
php_extensions: xdebug | ||
bootstrap: vendor/autoload.php | ||
configuration: phpunit.xml | ||
coverage_text: true | ||
env: | ||
XDEBUG_MODE: coverage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ | |
composer.lock | ||
vendor | ||
Packages | ||
.phpunit.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Unit\Factory; | ||
|
||
use Flowpack\ContentSecurityPolicy\Factory\PolicyFactory; | ||
use Flowpack\ContentSecurityPolicy\Model\Directive; | ||
use Flowpack\ContentSecurityPolicy\Model\Nonce; | ||
use Flowpack\ContentSecurityPolicy\Model\Policy; | ||
use PHPUnit\Framework\Attributes\CoversClass; | ||
use PHPUnit\Framework\Attributes\UsesClass; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
#[CoversClass(PolicyFactory::class)] | ||
#[UsesClass(Policy::class)] | ||
#[UsesClass(Directive::class)] | ||
class PolicyFactoryTest extends TestCase | ||
{ | ||
public function testCreateShouldReturnPolicy(): void | ||
{ | ||
$policyFactory = new PolicyFactory(); | ||
$nonceMock = $this->createMock(Nonce::class); | ||
|
||
$defaultDirective = [ | ||
'base-uri' => [ | ||
'self', | ||
], | ||
'script-src' => [ | ||
'self', | ||
], | ||
]; | ||
$customDirective = [ | ||
'script-src' => [ | ||
'{nonce}', | ||
], | ||
]; | ||
|
||
$expected = [ | ||
'base-uri' => [ | ||
"'self'", | ||
], | ||
'script-src' => [ | ||
"'self'", | ||
"'nonce-'", | ||
], | ||
]; | ||
|
||
$result = $policyFactory->create($nonceMock, $defaultDirective, $customDirective); | ||
|
||
self::assertSame($expected, $result->getDirectives()); | ||
} | ||
} |
Oops, something went wrong.