-
Notifications
You must be signed in to change notification settings - Fork 2
Issue #7: Implemented unit tests, cs-check, static analysis. #8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
5de158b
Issue #7: Implemented unit tests, cs-check, static analysis.
PopNatanael fa1091e
Added SymfonyInsight badge to Readme
PopNatanael 7255849
Code improvements and fixes
PopNatanael c28c11b
directory structure change
PopNatanael 89304ac
ResponseHeaderMiddleware::addHeaders test examples
alexmerlin ccd87eb
Merge pull request #1 from alexmerlin/3.0
PopNatanael c48fe7e
Middleware test improvements
PopNatanael b745714
Test improvements
PopNatanael b056d8c
Further test improvements
PopNatanael 064b5b7
Further test improvements
PopNatanael 0208ea3
Namespace changes
PopNatanael File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,46 @@ | ||
| on: | ||
| - push | ||
|
|
||
| name: Run phpcs checks | ||
|
|
||
| jobs: | ||
| mutation: | ||
| name: PHP ${{ matrix.php }}-${{ matrix.os }} | ||
|
|
||
| runs-on: ${{ matrix.os }} | ||
|
|
||
| strategy: | ||
| matrix: | ||
| os: | ||
| - ubuntu-latest | ||
|
|
||
| php: | ||
| - "8.1" | ||
| - "8.2" | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v3 | ||
|
|
||
| - name: Install PHP | ||
| uses: shivammathur/setup-php@v2 | ||
| with: | ||
| php-version: "${{ matrix.php }}" | ||
| tools: composer:v2, cs2pr | ||
| coverage: none | ||
|
|
||
| - name: Determine composer cache directory | ||
| run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV | ||
|
|
||
| - name: Cache dependencies installed with composer | ||
| uses: actions/cache@v3 | ||
| with: | ||
| path: ${{ env.COMPOSER_CACHE_DIR }} | ||
| key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }} | ||
| restore-keys: | | ||
| php${{ matrix.php }}-composer- | ||
| - name: Install dependencies with composer | ||
| run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi | ||
|
|
||
| - name: Run phpcs checks | ||
| run: vendor/bin/phpcs |
This file contains hidden or 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,46 @@ | ||
| on: | ||
| - push | ||
|
|
||
| name: Run static analysis | ||
|
|
||
| jobs: | ||
| mutation: | ||
| name: PHP ${{ matrix.php }}-${{ matrix.os }} | ||
|
|
||
| runs-on: ${{ matrix.os }} | ||
|
|
||
| strategy: | ||
| matrix: | ||
| os: | ||
| - ubuntu-latest | ||
|
|
||
| php: | ||
| - "8.1" | ||
| - "8.2" | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v3 | ||
|
|
||
| - name: Install PHP | ||
| uses: shivammathur/setup-php@v2 | ||
| with: | ||
| php-version: "${{ matrix.php }}" | ||
| tools: composer:v2, cs2pr | ||
| coverage: none | ||
|
|
||
| - name: Determine composer cache directory | ||
| run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV | ||
|
|
||
| - name: Cache dependencies installed with composer | ||
| uses: actions/cache@v3 | ||
| with: | ||
| path: ${{ env.COMPOSER_CACHE_DIR }} | ||
| key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }} | ||
| restore-keys: | | ||
| php${{ matrix.php }}-composer- | ||
| - name: Install dependencies with composer | ||
| run: composer update --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi | ||
|
|
||
| - name: Run static analysis | ||
| run: vendor/bin/psalm --no-cache --output-format=github --show-info=false --threads=4 |
This file contains hidden or 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,47 @@ | ||
| on: | ||
| - push | ||
|
|
||
| name: Run PHPUnit tests | ||
|
|
||
| jobs: | ||
| mutation: | ||
| name: PHP ${{ matrix.php }}-${{ matrix.os }} | ||
|
|
||
| runs-on: ${{ matrix.os }} | ||
|
|
||
| strategy: | ||
| matrix: | ||
| os: | ||
| - ubuntu-latest | ||
|
|
||
| php: | ||
| - "8.1" | ||
| - "8.2" | ||
|
|
||
| steps: | ||
| - name: Checkout | ||
| uses: actions/checkout@v3 | ||
|
|
||
| - name: Install PHP | ||
| uses: shivammathur/setup-php@v2 | ||
| with: | ||
| php-version: "${{ matrix.php }}" | ||
| tools: composer:v2, cs2pr | ||
| coverage: none | ||
|
|
||
| - name: Determine composer cache directory | ||
| run: echo "COMPOSER_CACHE_DIR=$(composer config cache-dir)" >> $GITHUB_ENV | ||
|
|
||
| - name: Cache dependencies installed with composer | ||
| uses: actions/cache@v3 | ||
| with: | ||
| path: ${{ env.COMPOSER_CACHE_DIR }} | ||
| key: php${{ matrix.php }}-composer-${{ hashFiles('**/composer.json') }} | ||
| restore-keys: | | ||
| php${{ matrix.php }}-composer- | ||
|
|
||
| - name: Install dependencies with composer | ||
| run: composer install --prefer-dist --no-interaction --no-progress --optimize-autoloader --ansi | ||
|
|
||
| - name: Run PHPUnit tests | ||
| run: vendor/bin/phpunit --colors=always |
This file contains hidden or 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 |
|---|---|---|
| @@ -1 +1,6 @@ | ||
| composer.phar | ||
| /vendor/ | ||
| .phpcs-cache | ||
| .idea | ||
| composer.lock | ||
| .phpunit.result.cache |
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -31,4 +31,4 @@ | |
| * Nothing | ||
|
|
||
| ### Fixed | ||
| * Nothing | ||
| * Nothing | ||
This file contains hidden or 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 hidden or 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 hidden or 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 |
|---|---|---|
|
|
@@ -18,4 +18,4 @@ return [ | |
| ] | ||
| ] | ||
| ] | ||
| ]; | ||
| ]; | ||
This file contains hidden or 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,21 @@ | ||
| <?xml version="1.0"?> | ||
| <ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:noNamespaceSchemaLocation="vendor/squizlabs/php_codesniffer/phpcs.xsd"> | ||
|
|
||
| <arg name="basepath" value="."/> | ||
| <arg name="cache" value=".phpcs-cache"/> | ||
| <arg name="colors"/> | ||
| <arg name="extensions" value="php"/> | ||
| <arg name="parallel" value="80"/> | ||
|
|
||
| <!-- Show progress --> | ||
| <arg value="p"/> | ||
|
|
||
| <!-- Paths to check --> | ||
| <file>config</file> | ||
| <file>src</file> | ||
| <file>test</file> | ||
|
|
||
| <!-- Include all rules from the Laminas Coding Standard --> | ||
| <rule ref="LaminasCodingStandard"/> | ||
| </ruleset> |
This file contains hidden or 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,14 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.2/phpunit.xsd" bootstrap="./vendor/autoload.php" colors="true"> | ||
| <testsuites> | ||
| <testsuite name="dot-response-header Test Suite"> | ||
| <directory>./test</directory> | ||
| </testsuite> | ||
| </testsuites> | ||
| <coverage/> | ||
| <source> | ||
| <include> | ||
| <directory suffix=".php">./src</directory> | ||
| </include> | ||
| </source> | ||
| </phpunit> |
This file contains hidden or 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,17 @@ | ||
| <?xml version="1.0"?> | ||
| <psalm | ||
| errorLevel="4" | ||
| resolveFromConfigFile="true" | ||
| findUnusedCode="false" | ||
| findUnusedBaselineEntry="true" | ||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xmlns="https://getpsalm.org/schema/config" | ||
| xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd" | ||
| > | ||
| <projectFiles> | ||
| <directory name="src" /> | ||
| <ignoreFiles> | ||
| <directory name="vendor" /> | ||
| </ignoreFiles> | ||
| </projectFiles> | ||
| </psalm> |
This file contains hidden or 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 hidden or 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 |
|---|---|---|
| @@ -1,23 +1,43 @@ | ||
| <?php | ||
|
|
||
| declare(strict_types=1); | ||
|
|
||
| namespace Dot\ResponseHeader\Factory; | ||
|
|
||
| use Dot\ResponseHeader\Middleware\ResponseHeaderMiddleware; | ||
| use Exception; | ||
| use Psr\Container\ContainerExceptionInterface; | ||
| use Psr\Container\ContainerInterface; | ||
| use Psr\Container\NotFoundExceptionInterface; | ||
|
|
||
| use function array_key_exists; | ||
| use function is_array; | ||
|
|
||
| /** | ||
| * Class ResponseHeaderMiddlewareFactory | ||
| * @package Dot\ResponseHeader\Factory | ||
| */ | ||
| class ResponseHeaderMiddlewareFactory | ||
| { | ||
| public const MESSAGE_MISSING_CONFIG = 'Unable to find config.'; | ||
| public const MESSAGE_MISSING_PACKAGE_CONFIG = 'Unable to find dot-response-header config.'; | ||
|
|
||
| /** | ||
| * @param ContainerInterface $container | ||
| * @return ResponseHeaderMiddleware | ||
| * @throws ContainerExceptionInterface | ||
| * @throws NotFoundExceptionInterface | ||
| * @throws Exception | ||
| */ | ||
| public function __invoke(ContainerInterface $container): ResponseHeaderMiddleware | ||
| { | ||
| if (! $container->has('config')) { | ||
| throw new Exception(self::MESSAGE_MISSING_CONFIG); | ||
| } | ||
| $config = $container->get('config'); | ||
|
|
||
| if ( | ||
| ! array_key_exists('dot_response_headers', $config) | ||
| || ! is_array($config['dot_response_headers']) | ||
| || empty($config['dot_response_headers']) | ||
| ) { | ||
| throw new Exception(self::MESSAGE_MISSING_PACKAGE_CONFIG); | ||
| } | ||
|
|
||
| return new ResponseHeaderMiddleware($container->get('config')['dot_response_headers'] ?? []); | ||
|
alexmerlin marked this conversation as resolved.
|
||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.