Skip to content

Commit

Permalink
Refactor composer lint script and add php-cs-fixer as dev-dependency (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasnatter authored Jan 11, 2021
1 parent 107a976 commit ef1677c
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 85 deletions.
9 changes: 5 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ workflows:
- test:
requires:
- composer
- test-coverage:
- check-coverage:
requires:
- composer
- test
Expand Down Expand Up @@ -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:
Expand All @@ -112,7 +112,7 @@ jobs:
paths:
- Tests/reports

test-coverage:
check-coverage:
docker:
- image: sulu/php:7.4-cli
environment: *environment_variables
Expand All @@ -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:
Expand Down
42 changes: 0 additions & 42 deletions .github/workflows/php.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
62 changes: 35 additions & 27 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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": {
Expand Down
4 changes: 2 additions & 2 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
22 changes: 14 additions & 8 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit colors="true" bootstrap="Tests/test-bootstrap.php">
<php>
<ini name="error_reporting" value="-1" />
<server name="APP_ENV" value="test" force="true" />
<server name="SHELL_VERBOSITY" value="-1" />
<!-- See: https://symfony.com/doc/current/components/phpunit_bridge.html#modified-phpunit-script -->
<env name="SYMFONY_DEPRECATIONS_HELPER" value="weak"/>
<!-- Set "SYMFONY_PHPUNIT_VERSION" to use fixed phpunit version: https://symfony.com/doc/current/components/phpunit_bridge.html#modified-phpunit-script -->
<server name="SYMFONY_PHPUNIT_VERSION" value="8.5" />
<!-- Set "SYMFONY_PHPUNIT_REMOVE" to "symfony/yaml" to install "prophecy": https://symfony.com/doc/current/components/phpunit_bridge.html#modified-phpunit-script -->
<server name="SYMFONY_PHPUNIT_REMOVE" value="symfony/yaml"/>

<env name="KERNEL_CLASS" value="Sulu\Bundle\ContentBundle\Tests\Application\Kernel"/>
</php>

<testsuites>
<testsuite name="Sulu Content Bundle">
<directory>./Tests</directory>
Expand All @@ -17,12 +31,4 @@
</exclude>
</whitelist>
</filter>

<php>
<server name="SYMFONY_PHPUNIT_VERSION" value="8"/>
<env name="KERNEL_CLASS" value="Sulu\Bundle\ContentBundle\Tests\Application\Kernel"/>
<env name="APP_ENV" value="test" force="true"/>
<env name="SYMFONY_DEPRECATIONS_HELPER" value="weak"/>
<server name="SYMFONY_PHPUNIT_REMOVE" value="symfony/yaml"/>
</php>
</phpunit>

0 comments on commit ef1677c

Please sign in to comment.