diff --git a/.circleci/config.yml b/.circleci/config.yml index d6f36e7d..b119a10e 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -36,7 +36,7 @@ workflows: - test: requires: - composer - - test-coverage: + - check-coverage: requires: - composer - test @@ -102,7 +102,7 @@ jobs: - disable_php_memory_limit - run: php -m - run: php composer.phar bootstrap-test-environment - - run: php composer.phar test-coverage -- --coverage-clover Tests/reports/clover.xml + - run: php composer.phar test -- --coverage-php Tests/reports/coverage.php --coverage-html Tests/reports/html --log-junit Tests/reports/unit/junit.xml --coverage-clover Tests/reports/clover.xml - store_artifacts: path: Tests/reports/html - store_test_results: @@ -112,7 +112,7 @@ jobs: paths: - Tests/reports - test-coverage: + check-coverage: docker: - image: sulu/php:7.4-cli environment: *environment_variables @@ -122,7 +122,8 @@ jobs: at: . - enable_php_pcov - disable_php_memory_limit - - run: php composer.phar test-coverage-checker + - run: php vendor/bin/code-coverage-checker "Tests/reports/coverage.php" "line" "99.00" "Content/Domain" "Content/Application" + - run: php vendor/bin/code-coverage-checker "Tests/reports/coverage.php" "line" "94.00" "Content/Infrastructure" "DependencyInjection" coverage-all-upload: docker: diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml deleted file mode 100644 index 0b2d3e62..00000000 --- a/.github/workflows/php.yml +++ /dev/null @@ -1,42 +0,0 @@ -name: PHP - -on: - pull_request: - push: - branches: - - master - -jobs: - - php-cs-fixer: - name: Run php-cs-fixer - runs-on: ubuntu-18.04 - - steps: - - name: Checkout project - uses: actions/checkout@v1 - - - name: Create downloads directory - run: mkdir downloads - - - name: Get downloads path - id: php-cs-fixer-dir - run: echo "::set-output name=dir::downloads" - - - name: Get php-cs-fixer path - id: php-cs-fixer-path - run: echo "::set-output name=path::${{ steps.php-cs-fixer-dir.outputs.dir }}/php-cs-fixer.phar" - - - name: Cache php-cs-fixer - id: php-cs-fixer-cache - uses: actions/cache@v1 - with: - path: ${{ steps.php-cs-fixer-dir.outputs.dir }} - key: php-cs-fixer - - - name: Download php-cs-fixer - if: steps.php-cs-fixer-cache.outputs.cache-hit != 'true' - run: curl "https://cs.symfony.com/download/php-cs-fixer-v2.phar" --output ${{ steps.php-cs-fixer-path.outputs.path }} && chmod +x ${{ steps.php-cs-fixer-path.outputs.path }} - - - name: Run php-cs-fixer - run: ./${{ steps.php-cs-fixer-path.outputs.path }} fix --dry-run --diff diff --git a/Tests/Unit/Content/Application/ContentDataMapper/DataMapper/RoutableDataMapperTest.php b/Tests/Unit/Content/Application/ContentDataMapper/DataMapper/RoutableDataMapperTest.php index 749a1597..770ddab8 100644 --- a/Tests/Unit/Content/Application/ContentDataMapper/DataMapper/RoutableDataMapperTest.php +++ b/Tests/Unit/Content/Application/ContentDataMapper/DataMapper/RoutableDataMapperTest.php @@ -66,7 +66,8 @@ protected function createRouteDataMapperInstance( */ protected function wrapRoutableMock(ObjectProphecy $routableMock): RoutableInterface { - return new class($routableMock) extends MockWrapper implements TemplateInterface, + return new class($routableMock) extends MockWrapper implements + TemplateInterface, RoutableInterface { use RoutableMockWrapperTrait; use TemplateMockWrapperTrait; diff --git a/Tests/Unit/Content/Application/ContentWorkflow/ContentWorkflowTest.php b/Tests/Unit/Content/Application/ContentWorkflow/ContentWorkflowTest.php index 01b8e7c4..80697e4d 100644 --- a/Tests/Unit/Content/Application/ContentWorkflow/ContentWorkflowTest.php +++ b/Tests/Unit/Content/Application/ContentWorkflow/ContentWorkflowTest.php @@ -55,7 +55,8 @@ protected function createContentWorkflowInstance( */ protected function wrapWorkflowMock(ObjectProphecy $workflowMock) { - return new class($workflowMock) extends MockWrapper implements DimensionContentInterface, + return new class($workflowMock) extends MockWrapper implements + DimensionContentInterface, WorkflowInterface { use DimensionContentMockWrapperTrait; use WorkflowMockWrapperTrait; diff --git a/composer.json b/composer.json index 323a23ee..7f096029 100644 --- a/composer.json +++ b/composer.json @@ -32,6 +32,7 @@ "require-dev": { "coduo/php-matcher": "^3.2 || ^4.0 || ^5.0", "doctrine/doctrine-fixtures-bundle": "^2.0 || ^3.0", + "friendsofphp/php-cs-fixer": "^2.17", "handcraftedinthealps/code-coverage-checker": "^0.2.1", "handcraftedinthealps/zendsearch": "^2.0", "jackalope/jackalope-doctrine-dbal": "^1.3.4", @@ -72,47 +73,54 @@ } }, "scripts": { + "bootstrap-dev-environment": [ + "Tests/Application/bin/adminconsole sulu:build dev --env dev" + ], + "bootstrap-test-environment": [ + "Tests/Application/bin/adminconsole doctrine:database:create --if-not-exists --env test", + "Tests/Application/bin/adminconsole doctrine:schema:update --force --env test" + ], "lint": [ - "@lint-composer", "@phpstan", + "@php-cs", + "@lint-twig", "@lint-yaml", "@lint-container", - "@lint-twig", + "@lint-composer", "@lint-schema", - "@deptract" + "@deptrac" ], "test": [ "@phpunit" ], - "test-coverage": "@phpunit --coverage-php Tests/reports/coverage.php --coverage-html Tests/reports/html --log-junit Tests/reports/unit/junit.xml", - "test-coverage-checker": [ - "@php vendor/bin/code-coverage-checker \"Tests/reports/coverage.php\" \"line\" \"99.00\" \"Content/Domain\" \"Content/Application\"", - "@php vendor/bin/code-coverage-checker \"Tests/reports/coverage.php\" \"line\" \"94.00\" \"Content/Infrastructure\" \"DependencyInjection\"" - ], - "test-unit": "@phpunit Tests/Unit", - "test-unit-coverage": "@phpunit Tests/Unit --coverage-php Tests/reports/coverage.php --coverage-html Tests/reports/html --log-junit Tests/reports/unit/junit.xml", - "test-unit-coverage-checker": "@php Tests/coverage-checker.php \"line\" \"96.00\" \"Dimension/Domain\" \"Content/Domain\"", - "test-functional": "@phpunit Tests/Functional --log-junit Tests/reports/functional/junit.xml", - "lint-composer": "@composer validate --strict", - "lint-yaml": "Tests/Application/bin/adminconsole lint:yaml Resources/config Tests/Application/config", - "lint-twig": "Tests/Application/bin/adminconsole lint:twig Tests/Application/templates", - "lint-container": "Tests/Application/bin/adminconsole lint:container", - "lint-schema": "Tests/Application/bin/adminconsole doctrine:schema:validate", - "deptract": "vendor/bin/deptrac", + "phpunit": "vendor/bin/simple-phpunit", "phpstan": [ - "Tests/Application/bin/adminconsole cache:warmup --env test", - "vendor/bin/simple-phpunit install", + "Tests/Application/bin/adminconsole cache:warmup --env dev", + "@test install", "vendor/bin/phpstan analyze" ], - "bootstrap-dev-environment": [ - "Tests/Application/bin/adminconsole sulu:build dev --env dev" + "php-cs": "vendor/bin/php-cs-fixer fix --verbose --diff --dry-run", + "php-cs-fix": "vendor/bin/php-cs-fixer fix", + "lint-composer": "@composer validate --strict", + "lint-twig": "Tests/Application/bin/adminconsole lint:twig Tests/Application/templates", + "lint-yaml": "Tests/Application/bin/adminconsole lint:yaml Resources/config Tests/Application/config", + "lint-container": [ + "Tests/Application/bin/adminconsole lint:container --env dev", + "Tests/Application/bin/websiteconsole lint:container --env dev", + "Tests/Application/bin/adminconsole lint:container --env test", + "Tests/Application/bin/websiteconsole lint:container --env test", + "Tests/Application/bin/adminconsole lint:container --env stage", + "Tests/Application/bin/websiteconsole lint:container --env stage", + "Tests/Application/bin/adminconsole lint:container --env prod", + "Tests/Application/bin/websiteconsole lint:container --env prod" ], - "bootstrap-test-environment": [ - "Tests/Application/bin/adminconsole doctrine:database:drop --if-exists --force --env test", - "Tests/Application/bin/adminconsole doctrine:database:create --env test", - "Tests/Application/bin/adminconsole doctrine:schema:update --force --env test" + "lint-doctrine": [ + "Tests/Application/bin/adminconsole doctrine:database:create --if-not-exists", + "Tests/Application/bin/adminconsole doctrine:schema:update --force", + "Tests/Application/bin/adminconsole doctrine:schema:validate", + "Tests/Application/bin/adminconsole doctrine:ensure-production-settings --env prod" ], - "phpunit": "vendor/bin/simple-phpunit" + "deptrac": "vendor/bin/deptrac" }, "extra": { "branch-alias": { diff --git a/phpstan.neon b/phpstan.neon index a0ec9f44..661cfc76 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -17,12 +17,12 @@ parameters: - %currentWorkingDirectory%/Tests/Application/Kernel.php - %currentWorkingDirectory%/Tests/Application/var/* symfony: - container_xml_path: %currentWorkingDirectory%/Tests/Application/var/cache/admin/test/Sulu_Bundle_ContentBundle_Tests_Application_KernelTestDebugContainer.xml + container_xml_path: %currentWorkingDirectory%/Tests/Application/var/cache/admin/dev/Sulu_Bundle_ContentBundle_Tests_Application_KernelDevDebugContainer.xml console_application_loader: Tests/phpstan/console-application.php doctrine: objectManagerLoader: Tests/phpstan/object-manager.php bootstrapFiles: - - vendor/bin/.phpunit/phpunit-8-0/vendor/autoload.php + - vendor/bin/.phpunit/phpunit-8.5-0/vendor/autoload.php ignoreErrors: - message: "#^Method Sulu\\\\Bundle\\\\ContentBundle\\\\Content\\\\Infrastructure\\\\Sulu\\\\Structure\\\\ContentDocument\\:\\:getStructure\\(\\) should return Sulu\\\\Component\\\\Content\\\\Document\\\\Structure\\\\StructureInterface but returns null\\.$#" count: 1 diff --git a/phpunit.xml.dist b/phpunit.xml.dist index a60f0dbd..49d56651 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,5 +1,19 @@ + + + + + + + + + + + + + + ./Tests @@ -17,12 +31,4 @@ - - - - - - - -