diff --git a/.gitattributes b/.gitattributes index 58fd0e3..066b042 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,9 +1,7 @@ .editorconfig export-ignore .gitattributes export-ignore .gitignore export-ignore +/.github export-ignore /.php_cs export-ignore -/.styleci.yml export-ignore -/.scrutinizer.yml export-ignore -/.travis.yml export-ignore /phpunit.xml.dist export-ignore /Tests/ export-ignore diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..152a89a --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,3 @@ +# These are supported funding model platforms + +github: [Nyholm] diff --git a/.github/workflows/.editorconfig b/.github/workflows/.editorconfig new file mode 100644 index 0000000..7bd3346 --- /dev/null +++ b/.github/workflows/.editorconfig @@ -0,0 +1,2 @@ +[*.yml] +indent_size = 2 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..10e23c4 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,54 @@ +name: Tests +on: [ pull_request ] + +jobs: + phpunit: + name: PHPUnit + runs-on: ubuntu-latest + strategy: + max-parallel: 10 + matrix: + php: [ '7.2', '7.3', '7.4', '8.0' ] + sf_version: [ '4.4.*', '5.3.*' ] + + steps: + - name: Set up PHP + uses: shivammathur/setup-php@2.7.0 + with: + php-version: ${{ matrix.php }} + coverage: none + tools: flex + + - name: Checkout code + uses: actions/checkout@v2 + + - name: Download dependencies + env: + SYMFONY_REQUIRE: ${{ matrix.sf_version }} + uses: ramsey/composer-install@v1 + + - name: Run tests + run: ./vendor/bin/phpunit + + lowest: + name: Lowest deps + runs-on: ubuntu-latest + steps: + - name: Set up PHP + uses: shivammathur/setup-php@2.5.0 + with: + php-version: 7.3 + coverage: none + + - name: Checkout code + uses: actions/checkout@v2 + + - name: Download dependencies + with: + dependency-versions: "lowest" + uses: ramsey/composer-install@v1 + + - name: Run tests + env: + SYMFONY_DEPRECATIONS_HELPER: "max[self]=0" + run: ./vendor/bin/phpunit diff --git a/.github/workflows/static.yml b/.github/workflows/static.yml new file mode 100644 index 0000000..7d8b221 --- /dev/null +++ b/.github/workflows/static.yml @@ -0,0 +1,80 @@ +on: [pull_request] +name: Static analysis + +jobs: + phpstan: + name: PHPStan + runs-on: ubuntu-20.04 + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 8.0 + coverage: none + tools: phpstan:0.12.92, cs2pr + + - name: Download dependencies + uses: ramsey/composer-install@v1 + + - name: PHPStan + run: phpstan analyze --no-progress --error-format=checkstyle | cs2pr + + php-cs-fixer: + name: PHP-CS-Fixer + runs-on: ubuntu-20.04 + + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 8.0 + coverage: none + tools: php-cs-fixer:2.19.0, cs2pr + + - name: PHP-CS-Fixer + run: php-cs-fixer fix --dry-run --format=checkstyle | cs2pr + + psalm: + name: Psalm + runs-on: ubuntu-20.04 + steps: + - name: Checkout code + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 8.0 + coverage: none + tools: vimeo/psalm:4.8.1 + + - name: Download dependencies + uses: ramsey/composer-install@v1 + + - name: Psalm + run: psalm --no-progress --output-format=github + + composer-normalize: + name: Composer Normalize + runs-on: ubuntu-20.04 + + steps: + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 8.0 + coverage: none + tools: composer-normalize + + - name: Checkout code + uses: actions/checkout@v2 + + - name: Normalize + run: composer-normalize --dry-run diff --git a/.gitignore b/.gitignore index 12acd15..915ea06 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ -/php_cs.cache -/composer.lock -/phpunit.xml -/vendor/ +.php_cs.cache +.phpunit.result.cache +composer.lock +phpunit.xml +vendor/ diff --git a/.php_cs b/.php_cs index 720b702..7c31317 100644 --- a/.php_cs +++ b/.php_cs @@ -8,7 +8,6 @@ $finder = PhpCsFixer\Finder::create() return PhpCsFixer\Config::create() ->setRules([ '@Symfony' => true, - 'array_syntax' => ['syntax' => 'short'], ]) ->setFinder($finder) -; \ No newline at end of file +; diff --git a/.scrutinizer.yml b/.scrutinizer.yml deleted file mode 100644 index 28ef3ae..0000000 --- a/.scrutinizer.yml +++ /dev/null @@ -1,9 +0,0 @@ -filter: - excluded_paths: [vendor/*, Tests/*] -checks: - php: - code_rating: true - duplication: true -tools: - external_code_coverage: - timeout: 1800 # Timeout in seconds. diff --git a/.styleci.yml b/.styleci.yml deleted file mode 100644 index 435b5fb..0000000 --- a/.styleci.yml +++ /dev/null @@ -1,12 +0,0 @@ -preset: symfony - -finder: - exclude: - - "Resources" - - "vendor" - -enabled: - - short_array_syntax - -disabled: - - phpdoc_annotation_without_dot # This is still buggy: https://github.com/symfony/symfony/pull/19198 diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 66914c6..0000000 --- a/.travis.yml +++ /dev/null @@ -1,64 +0,0 @@ -language: php - -cache: - directories: - - $HOME/.composer/cache - -branches: - except: - - /^analysis-.*$/ - - /^patch-.*$/ - -env: - global: - - TEST_COMMAND="composer test" - - SYMFONY_PHPUNIT_VERSION="6.3" - -matrix: - fast_finish: true - include: - # Run test with code coverage - - php: 7.2 - env: COVERAGE=true TEST_COMMAND="composer test-ci" - - # Test with lowest dependencies - - php: 7.1 - env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" SYMFONY_DEPRECATIONS_HELPER="weak" - - # Test the latest stable release - - php: 7.0 - - php: 7.1 - - # Force some major versions of Symfony - - php: 7.2 - env: DEPENDENCIES="dunglas/symfony-lock:^3" - - php: 7.2 - env: DEPENDENCIES="dunglas/symfony-lock:^4" - - # Latest commit to master - - php: 7.2 - env: STABILITY="dev" - - allow_failures: - # Dev-master is allowed to fail. - - env: STABILITY="dev" - -before_install: - - if [[ $COVERAGE != true ]]; then phpenv config-rm xdebug.ini || true; fi - - if ! [ -z "$STABILITY" ]; then composer config minimum-stability ${STABILITY}; fi; - - if ! [ -z "$DEPENDENCIES" ]; then composer require --no-update ${DEPENDENCIES}; fi; - -install: - # To be removed when this issue will be resolved: https://github.com/composer/composer/issues/5355 - - if [[ "$COMPOSER_FLAGS" == *"--prefer-lowest"* ]]; then composer update --prefer-dist --no-interaction --prefer-stable --quiet; fi - - composer update ${COMPOSER_FLAGS} --prefer-dist --no-interaction - - vendor/bin/simple-phpunit install - -script: - - composer validate --strict --no-check-lock - - $TEST_COMMAND - -after_success: - - if [[ $COVERAGE = true ]]; then wget https://scrutinizer-ci.com/ocular.phar; fi - - if [[ $COVERAGE = true ]]; then php ocular.phar code-coverage:upload --format=php-clover build/coverage.xml; fi - diff --git a/Tests/.gitignore b/Tests/.gitignore deleted file mode 100644 index e69de29..0000000 diff --git a/composer.json b/composer.json index 13a60ce..fbf5d06 100644 --- a/composer.json +++ b/composer.json @@ -3,26 +3,26 @@ "type": "symfony-bundle", "license": "MIT", "require": { - "php": "^7.1.3", + "php": ">=7.2", "psr/http-client": "^1.0", "psr/http-factory": "^1.0", - "symfony/config": "^4.1", - "symfony/contracts": "^1.0.2", - "symfony/dependency-injection": "^4.1", - "symfony/framework-bundle": "^4.1", - "symfony/http-kernel": "^4.1", - "twig/twig": "^2.0" + "symfony/config": "^4.4 || ^5.3 || ^6.0", + "symfony/dependency-injection": "^4.4 || ^5.3 || ^6.0", + "symfony/framework-bundle": "^4.4 || ^5.3 || ^6.0", + "symfony/http-kernel": "^4.4 || ^5.3 || ^6.0", + "twig/twig": "^2.14 || ^3.3" }, "require-dev": { - "phpunit/phpunit": "^7.4", - "symfony/phpunit-bridge": "^4.1" - }, - "config": { - "sort-packages": true + "phpunit/phpunit": "^8.5 || ^9.5" }, "autoload": { "psr-4": { - "Happyr\\WordpressBundle\\": "" + "Happyr\\WordpressBundle\\": "src/" + } + }, + "autoload-dev": { + "psr-4": { + "Happyr\\WordpressBundle\\Tests\\": "tests/" } } } diff --git a/composer.lock b/composer.lock deleted file mode 100644 index b4f946f..0000000 --- a/composer.lock +++ /dev/null @@ -1,1028 +0,0 @@ -{ - "_readme": [ - "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", - "This file is @generated automatically" - ], - "content-hash": "b232c0226af759834a76feb76abc6842", - "packages": [ - { - "name": "psr/container", - "version": "1.0.0", - "source": { - "type": "git", - "url": "https://github.com/php-fig/container.git", - "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/container/zipball/b7ce3b176482dbbc1245ebf52b181af44c2cf55f", - "reference": "b7ce3b176482dbbc1245ebf52b181af44c2cf55f", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Container\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common Container Interface (PHP FIG PSR-11)", - "homepage": "https://github.com/php-fig/container", - "keywords": [ - "PSR-11", - "container", - "container-interface", - "container-interop", - "psr" - ], - "time": "2017-02-14T16:28:37+00:00" - }, - { - "name": "psr/http-client", - "version": "0.3.0", - "source": { - "type": "git", - "url": "https://github.com/php-fig/http-client.git", - "reference": "34bb3312cf19984a826d87ac379df4e2cb0c54b4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/http-client/zipball/34bb3312cf19984a826d87ac379df4e2cb0c54b4", - "reference": "34bb3312cf19984a826d87ac379df4e2cb0c54b4", - "shasum": "" - }, - "require": { - "php": "^7.0", - "psr/http-message": "^1.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Http\\Client\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common interface for HTTP clients", - "homepage": "https://github.com/php-fig/http-client", - "keywords": [ - "http", - "http-client", - "psr", - "psr-18" - ], - "time": "2018-09-05T04:11:20+00:00" - }, - { - "name": "psr/http-factory", - "version": "1.0.0", - "source": { - "type": "git", - "url": "https://github.com/php-fig/http-factory.git", - "reference": "378bfe27931ecc54ff824a20d6f6bfc303bbd04c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/http-factory/zipball/378bfe27931ecc54ff824a20d6f6bfc303bbd04c", - "reference": "378bfe27931ecc54ff824a20d6f6bfc303bbd04c", - "shasum": "" - }, - "require": { - "php": ">=7.0.0", - "psr/http-message": "^1.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Http\\Message\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common interfaces for PSR-7 HTTP message factories", - "keywords": [ - "factory", - "http", - "message", - "psr", - "psr-17", - "psr-7", - "request", - "response" - ], - "time": "2018-07-30T21:54:04+00:00" - }, - { - "name": "psr/http-message", - "version": "1.0.1", - "source": { - "type": "git", - "url": "https://github.com/php-fig/http-message.git", - "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/http-message/zipball/f6561bf28d520154e4b0ec72be95418abe6d9363", - "reference": "f6561bf28d520154e4b0ec72be95418abe6d9363", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Http\\Message\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common interface for HTTP messages", - "homepage": "https://github.com/php-fig/http-message", - "keywords": [ - "http", - "http-message", - "psr", - "psr-7", - "request", - "response" - ], - "time": "2016-08-06T14:39:51+00:00" - }, - { - "name": "psr/log", - "version": "1.0.2", - "source": { - "type": "git", - "url": "https://github.com/php-fig/log.git", - "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/php-fig/log/zipball/4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", - "reference": "4ebe3a8bf773a19edfe0a84b6585ba3d401b724d", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Psr\\Log\\": "Psr/Log/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "PHP-FIG", - "homepage": "http://www.php-fig.org/" - } - ], - "description": "Common interface for logging libraries", - "homepage": "https://github.com/php-fig/log", - "keywords": [ - "log", - "psr", - "psr-3" - ], - "time": "2016-10-10T12:19:37+00:00" - }, - { - "name": "symfony/config", - "version": "v4.1.4", - "source": { - "type": "git", - "url": "https://github.com/symfony/config.git", - "reference": "76015a3cc372b14d00040ff58e18e29f69eba717" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/config/zipball/76015a3cc372b14d00040ff58e18e29f69eba717", - "reference": "76015a3cc372b14d00040ff58e18e29f69eba717", - "shasum": "" - }, - "require": { - "php": "^7.1.3", - "symfony/filesystem": "~3.4|~4.0", - "symfony/polyfill-ctype": "~1.8" - }, - "conflict": { - "symfony/finder": "<3.4" - }, - "require-dev": { - "symfony/dependency-injection": "~3.4|~4.0", - "symfony/event-dispatcher": "~3.4|~4.0", - "symfony/finder": "~3.4|~4.0", - "symfony/yaml": "~3.4|~4.0" - }, - "suggest": { - "symfony/yaml": "To use the yaml reference dumper" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.1-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Config\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Config Component", - "homepage": "https://symfony.com", - "time": "2018-08-08T06:37:38+00:00" - }, - { - "name": "symfony/contracts", - "version": "dev-master", - "source": { - "type": "git", - "url": "https://github.com/symfony/contracts.git", - "reference": "d4240ac5965db1fb41a6604410804cae05ff8b72" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/contracts/zipball/d4240ac5965db1fb41a6604410804cae05ff8b72", - "reference": "d4240ac5965db1fb41a6604410804cae05ff8b72", - "shasum": "" - }, - "require": { - "php": "^7.1.3" - }, - "require-dev": { - "psr/container": "^1.0" - }, - "suggest": { - "psr/cache": "When using the Cache contracts", - "psr/container": "When using the Service contracts" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Contracts\\": "" - }, - "exclude-from-classmap": [ - "**/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "A set of abstractions extracted out of the Symfony components", - "homepage": "https://symfony.com", - "keywords": [ - "abstractions", - "contracts", - "decoupling", - "interfaces", - "interoperability", - "standards" - ], - "time": "2018-09-04T08:20:02+00:00" - }, - { - "name": "symfony/debug", - "version": "v4.1.4", - "source": { - "type": "git", - "url": "https://github.com/symfony/debug.git", - "reference": "47ead688f1f2877f3f14219670f52e4722ee7052" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/debug/zipball/47ead688f1f2877f3f14219670f52e4722ee7052", - "reference": "47ead688f1f2877f3f14219670f52e4722ee7052", - "shasum": "" - }, - "require": { - "php": "^7.1.3", - "psr/log": "~1.0" - }, - "conflict": { - "symfony/http-kernel": "<3.4" - }, - "require-dev": { - "symfony/http-kernel": "~3.4|~4.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.1-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Debug\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Debug Component", - "homepage": "https://symfony.com", - "time": "2018-08-03T11:13:38+00:00" - }, - { - "name": "symfony/dependency-injection", - "version": "v4.1.4", - "source": { - "type": "git", - "url": "https://github.com/symfony/dependency-injection.git", - "reference": "bae4983003c9d451e278504d7d9b9d7fc1846873" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/dependency-injection/zipball/bae4983003c9d451e278504d7d9b9d7fc1846873", - "reference": "bae4983003c9d451e278504d7d9b9d7fc1846873", - "shasum": "" - }, - "require": { - "php": "^7.1.3", - "psr/container": "^1.0" - }, - "conflict": { - "symfony/config": "<4.1.1", - "symfony/finder": "<3.4", - "symfony/proxy-manager-bridge": "<3.4", - "symfony/yaml": "<3.4" - }, - "provide": { - "psr/container-implementation": "1.0" - }, - "require-dev": { - "symfony/config": "~4.1", - "symfony/expression-language": "~3.4|~4.0", - "symfony/yaml": "~3.4|~4.0" - }, - "suggest": { - "symfony/config": "", - "symfony/expression-language": "For using expressions in service container configuration", - "symfony/finder": "For using double-star glob patterns or when GLOB_BRACE portability is required", - "symfony/proxy-manager-bridge": "Generate service proxies to lazy load them", - "symfony/yaml": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.1-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\DependencyInjection\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony DependencyInjection Component", - "homepage": "https://symfony.com", - "time": "2018-08-08T11:48:58+00:00" - }, - { - "name": "symfony/event-dispatcher", - "version": "v4.1.4", - "source": { - "type": "git", - "url": "https://github.com/symfony/event-dispatcher.git", - "reference": "bfb30c2ad377615a463ebbc875eba64a99f6aa3e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/event-dispatcher/zipball/bfb30c2ad377615a463ebbc875eba64a99f6aa3e", - "reference": "bfb30c2ad377615a463ebbc875eba64a99f6aa3e", - "shasum": "" - }, - "require": { - "php": "^7.1.3" - }, - "conflict": { - "symfony/dependency-injection": "<3.4" - }, - "require-dev": { - "psr/log": "~1.0", - "symfony/config": "~3.4|~4.0", - "symfony/dependency-injection": "~3.4|~4.0", - "symfony/expression-language": "~3.4|~4.0", - "symfony/stopwatch": "~3.4|~4.0" - }, - "suggest": { - "symfony/dependency-injection": "", - "symfony/http-kernel": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.1-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\EventDispatcher\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony EventDispatcher Component", - "homepage": "https://symfony.com", - "time": "2018-07-26T09:10:45+00:00" - }, - { - "name": "symfony/filesystem", - "version": "v4.1.4", - "source": { - "type": "git", - "url": "https://github.com/symfony/filesystem.git", - "reference": "c0f5f62db218fa72195b8b8700e4b9b9cf52eb5e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/c0f5f62db218fa72195b8b8700e4b9b9cf52eb5e", - "reference": "c0f5f62db218fa72195b8b8700e4b9b9cf52eb5e", - "shasum": "" - }, - "require": { - "php": "^7.1.3", - "symfony/polyfill-ctype": "~1.8" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.1-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\Filesystem\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Filesystem Component", - "homepage": "https://symfony.com", - "time": "2018-08-18T16:52:46+00:00" - }, - { - "name": "symfony/http-foundation", - "version": "v4.1.4", - "source": { - "type": "git", - "url": "https://github.com/symfony/http-foundation.git", - "reference": "3a5c91e133b220bb882b3cd773ba91bf39989345" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/http-foundation/zipball/3a5c91e133b220bb882b3cd773ba91bf39989345", - "reference": "3a5c91e133b220bb882b3cd773ba91bf39989345", - "shasum": "" - }, - "require": { - "php": "^7.1.3", - "symfony/polyfill-mbstring": "~1.1" - }, - "require-dev": { - "predis/predis": "~1.0", - "symfony/expression-language": "~3.4|~4.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.1-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\HttpFoundation\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony HttpFoundation Component", - "homepage": "https://symfony.com", - "time": "2018-08-27T17:47:02+00:00" - }, - { - "name": "symfony/http-kernel", - "version": "v4.1.4", - "source": { - "type": "git", - "url": "https://github.com/symfony/http-kernel.git", - "reference": "33de0a1ff2e1720096189e3ced682d7a4e8f5e35" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/http-kernel/zipball/33de0a1ff2e1720096189e3ced682d7a4e8f5e35", - "reference": "33de0a1ff2e1720096189e3ced682d7a4e8f5e35", - "shasum": "" - }, - "require": { - "php": "^7.1.3", - "psr/log": "~1.0", - "symfony/debug": "~3.4|~4.0", - "symfony/event-dispatcher": "~4.1", - "symfony/http-foundation": "^4.1.1", - "symfony/polyfill-ctype": "~1.8" - }, - "conflict": { - "symfony/config": "<3.4", - "symfony/dependency-injection": "<4.1", - "symfony/var-dumper": "<4.1.1", - "twig/twig": "<1.34|<2.4,>=2" - }, - "provide": { - "psr/log-implementation": "1.0" - }, - "require-dev": { - "psr/cache": "~1.0", - "symfony/browser-kit": "~3.4|~4.0", - "symfony/config": "~3.4|~4.0", - "symfony/console": "~3.4|~4.0", - "symfony/css-selector": "~3.4|~4.0", - "symfony/dependency-injection": "^4.1", - "symfony/dom-crawler": "~3.4|~4.0", - "symfony/expression-language": "~3.4|~4.0", - "symfony/finder": "~3.4|~4.0", - "symfony/process": "~3.4|~4.0", - "symfony/routing": "~3.4|~4.0", - "symfony/stopwatch": "~3.4|~4.0", - "symfony/templating": "~3.4|~4.0", - "symfony/translation": "~3.4|~4.0", - "symfony/var-dumper": "^4.1.1" - }, - "suggest": { - "symfony/browser-kit": "", - "symfony/config": "", - "symfony/console": "", - "symfony/dependency-injection": "", - "symfony/var-dumper": "" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.1-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Component\\HttpKernel\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony HttpKernel Component", - "homepage": "https://symfony.com", - "time": "2018-08-28T06:17:42+00:00" - }, - { - "name": "symfony/phpunit-bridge", - "version": "v4.1.4", - "source": { - "type": "git", - "url": "https://github.com/symfony/phpunit-bridge.git", - "reference": "d5f433034543bbe3b0dfa2f34e6cc85bf839846f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/phpunit-bridge/zipball/d5f433034543bbe3b0dfa2f34e6cc85bf839846f", - "reference": "d5f433034543bbe3b0dfa2f34e6cc85bf839846f", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "conflict": { - "phpunit/phpunit": "<4.8.35|<5.4.3,>=5.0" - }, - "suggest": { - "ext-zip": "Zip support is required when using bin/simple-phpunit", - "symfony/debug": "For tracking deprecated interfaces usages at runtime with DebugClassLoader" - }, - "bin": [ - "bin/simple-phpunit" - ], - "type": "symfony-bridge", - "extra": { - "branch-alias": { - "dev-master": "4.1-dev" - }, - "thanks": { - "name": "phpunit/phpunit", - "url": "https://github.com/sebastianbergmann/phpunit" - } - }, - "autoload": { - "files": [ - "bootstrap.php" - ], - "psr-4": { - "Symfony\\Bridge\\PhpUnit\\": "" - }, - "exclude-from-classmap": [ - "/Tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony PHPUnit Bridge", - "homepage": "https://symfony.com", - "time": "2018-08-27T17:47:02+00:00" - }, - { - "name": "symfony/polyfill-ctype", - "version": "v1.9.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-ctype.git", - "reference": "e3d826245268269cd66f8326bd8bc066687b4a19" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/e3d826245268269cd66f8326bd8bc066687b4a19", - "reference": "e3d826245268269cd66f8326bd8bc066687b4a19", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "suggest": { - "ext-ctype": "For best performance" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.9-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Ctype\\": "" - }, - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - }, - { - "name": "Gert de Pagter", - "email": "BackEndTea@gmail.com" - } - ], - "description": "Symfony polyfill for ctype functions", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "ctype", - "polyfill", - "portable" - ], - "time": "2018-08-06T14:22:27+00:00" - }, - { - "name": "symfony/polyfill-mbstring", - "version": "v1.9.0", - "source": { - "type": "git", - "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "d0cd638f4634c16d8df4508e847f14e9e43168b8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/d0cd638f4634c16d8df4508e847f14e9e43168b8", - "reference": "d0cd638f4634c16d8df4508e847f14e9e43168b8", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "suggest": { - "ext-mbstring": "For best performance" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.9-dev" - } - }, - "autoload": { - "psr-4": { - "Symfony\\Polyfill\\Mbstring\\": "" - }, - "files": [ - "bootstrap.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Nicolas Grekas", - "email": "p@tchwork.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony polyfill for the Mbstring extension", - "homepage": "https://symfony.com", - "keywords": [ - "compatibility", - "mbstring", - "polyfill", - "portable", - "shim" - ], - "time": "2018-08-06T14:22:27+00:00" - } - ], - "packages-dev": [ - { - "name": "twig/twig", - "version": "v2.5.0", - "source": { - "type": "git", - "url": "https://github.com/twigphp/Twig.git", - "reference": "6a5f676b77a90823c2d4eaf76137b771adf31323" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/twigphp/Twig/zipball/6a5f676b77a90823c2d4eaf76137b771adf31323", - "reference": "6a5f676b77a90823c2d4eaf76137b771adf31323", - "shasum": "" - }, - "require": { - "php": "^7.0", - "symfony/polyfill-ctype": "^1.8", - "symfony/polyfill-mbstring": "~1.0" - }, - "require-dev": { - "psr/container": "^1.0", - "symfony/debug": "^2.7", - "symfony/phpunit-bridge": "^3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.5-dev" - } - }, - "autoload": { - "psr-0": { - "Twig_": "lib/" - }, - "psr-4": { - "Twig\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com", - "homepage": "http://fabien.potencier.org", - "role": "Lead Developer" - }, - { - "name": "Armin Ronacher", - "email": "armin.ronacher@active-4.com", - "role": "Project Founder" - }, - { - "name": "Twig Team", - "homepage": "https://twig.symfony.com/contributors", - "role": "Contributors" - } - ], - "description": "Twig, the flexible, fast, and secure template language for PHP", - "homepage": "https://twig.symfony.com", - "keywords": [ - "templating" - ], - "time": "2018-07-13T07:18:09+00:00" - } - ], - "aliases": [], - "minimum-stability": "stable", - "stability-flags": { - "symfony/contracts": 20 - }, - "prefer-stable": false, - "prefer-lowest": false, - "platform": { - "php": "^7.1.3" - }, - "platform-dev": [] -} diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon new file mode 100644 index 0000000..64654c2 --- /dev/null +++ b/phpstan-baseline.neon @@ -0,0 +1,17 @@ +parameters: + ignoreErrors: + - + message: "#^Call to an undefined method Symfony\\\\Component\\\\Config\\\\Definition\\\\Builder\\\\NodeDefinition\\:\\:children\\(\\)\\.$#" + count: 1 + path: src/DependencyInjection/Configuration.php + + - + message: "#^Instantiated class Twig_SimpleFunction not found\\.$#" + count: 4 + path: src/Twig/WordpressExtension.php + + - + message: "#^Method Happyr\\\\WordpressBundle\\\\Twig\\\\WordpressExtension\\:\\:getFunctions\\(\\) should return array\\ but returns array\\\\.$#" + count: 1 + path: src/Twig/WordpressExtension.php + diff --git a/phpstan.neon.dist b/phpstan.neon.dist new file mode 100644 index 0000000..72b5c82 --- /dev/null +++ b/phpstan.neon.dist @@ -0,0 +1,8 @@ +includes: + - phpstan-baseline.neon + +parameters: + level: 5 + reportUnmatchedIgnoredErrors: false + paths: + - src diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 7baf47f..e8376fb 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,33 +1,20 @@ - - - - - - - - - - ./Tests - - - - - - ./ - - vendor - Tests - - - + + + + ./ + + + vendor + Tests + + + + + + + + ./tests + + diff --git a/psalm.baseline.xml b/psalm.baseline.xml new file mode 100644 index 0000000..95cff1f --- /dev/null +++ b/psalm.baseline.xml @@ -0,0 +1,29 @@ + + + + + children + + + + + $configuration + + + + + $remoteUrl['host'] + + + + + $remoteUrl['host'] + $testUrl['path'] + + + + + $remoteUrl['host'] + + + diff --git a/psalm.xml b/psalm.xml new file mode 100644 index 0000000..d70acfe --- /dev/null +++ b/psalm.xml @@ -0,0 +1,16 @@ + + + + + + + + + diff --git a/Api/WpClient.php b/src/Api/WpClient.php similarity index 99% rename from Api/WpClient.php rename to src/Api/WpClient.php index e562acf..119c808 100644 --- a/Api/WpClient.php +++ b/src/Api/WpClient.php @@ -76,6 +76,7 @@ public function getMenu(string $slug): array /** * Generic GET. + * * @param string $uri example "/wp/v2/categories" * * @throws \Psr\Http\Client\ClientExceptionInterface diff --git a/Controller/WordpressController.php b/src/Controller/WordpressController.php similarity index 91% rename from Controller/WordpressController.php rename to src/Controller/WordpressController.php index 9af291a..abe9864 100644 --- a/Controller/WordpressController.php +++ b/src/Controller/WordpressController.php @@ -5,6 +5,7 @@ namespace Happyr\WordpressBundle\Controller; use Happyr\WordpressBundle\Service\Wordpress; +use Symfony\Bundle\FrameworkBundle\Controller\AbstractController; use Symfony\Bundle\FrameworkBundle\Controller\Controller; use Symfony\Component\HttpFoundation\Response; @@ -13,7 +14,7 @@ * * @author Tobias Nyholm */ -final class WordpressController extends Controller +final class WordpressController extends AbstractController { private $wordpress; private $indexTemplate; diff --git a/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php similarity index 96% rename from DependencyInjection/Configuration.php rename to src/DependencyInjection/Configuration.php index 5d9cac0..d33c840 100644 --- a/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -18,8 +18,8 @@ class Configuration implements ConfigurationInterface { public function getConfigTreeBuilder() { - $treeBuilder = new TreeBuilder(); - $root = $treeBuilder->root('wordpress'); + $treeBuilder = new TreeBuilder('wordpress'); + $root = $treeBuilder->getRootNode(); $root->children() ->scalarNode('url')->cannotBeEmpty()->isRequired()->end() diff --git a/DependencyInjection/WordpressExtension.php b/src/DependencyInjection/WordpressExtension.php similarity index 100% rename from DependencyInjection/WordpressExtension.php rename to src/DependencyInjection/WordpressExtension.php diff --git a/Model/Category.php b/src/Model/Category.php similarity index 88% rename from Model/Category.php rename to src/Model/Category.php index 9aba56c..521eb80 100644 --- a/Model/Category.php +++ b/src/Model/Category.php @@ -70,49 +70,31 @@ public function getId() return $this->id; } - /** - * @return int - */ public function getCount(): int { return $this->count; } - /** - * @return string - */ public function getDescription(): string { return $this->description; } - /** - * @return string - */ public function getLink(): string { return $this->link; } - /** - * @return string - */ public function getName(): string { return $this->name; } - /** - * @return string - */ public function getSlug(): string { return $this->slug; } - /** - * @return string - */ public function getTaxonomy(): string { return $this->taxonomy; diff --git a/Model/Media.php b/src/Model/Media.php similarity index 100% rename from Model/Media.php rename to src/Model/Media.php diff --git a/Model/Menu.php b/src/Model/Menu.php similarity index 100% rename from Model/Menu.php rename to src/Model/Menu.php diff --git a/Model/MenuItem.php b/src/Model/MenuItem.php similarity index 100% rename from Model/MenuItem.php rename to src/Model/MenuItem.php diff --git a/Model/Page.php b/src/Model/Page.php similarity index 100% rename from Model/Page.php rename to src/Model/Page.php diff --git a/Parser/CategoryParserInterface.php b/src/Parser/CategoryParserInterface.php similarity index 100% rename from Parser/CategoryParserInterface.php rename to src/Parser/CategoryParserInterface.php diff --git a/Parser/MediaParserInterface.php b/src/Parser/MediaParserInterface.php similarity index 100% rename from Parser/MediaParserInterface.php rename to src/Parser/MediaParserInterface.php diff --git a/Parser/MenuParserInterface.php b/src/Parser/MenuParserInterface.php similarity index 100% rename from Parser/MenuParserInterface.php rename to src/Parser/MenuParserInterface.php diff --git a/Parser/MessageParser.php b/src/Parser/MessageParser.php similarity index 100% rename from Parser/MessageParser.php rename to src/Parser/MessageParser.php diff --git a/Parser/PageParserInterface.php b/src/Parser/PageParserInterface.php similarity index 100% rename from Parser/PageParserInterface.php rename to src/Parser/PageParserInterface.php diff --git a/Parser/RewriteImageReferences.php b/src/Parser/RewriteImageReferences.php similarity index 100% rename from Parser/RewriteImageReferences.php rename to src/Parser/RewriteImageReferences.php diff --git a/Parser/RewriteLinks.php b/src/Parser/RewriteLinks.php similarity index 94% rename from Parser/RewriteLinks.php rename to src/Parser/RewriteLinks.php index 75d2da9..ff3f846 100644 --- a/Parser/RewriteLinks.php +++ b/src/Parser/RewriteLinks.php @@ -46,7 +46,7 @@ private function rewrite(string $content): string if (empty($testUrl['host']) || $testUrl['host'] !== $remoteUrl['host']) { continue; } - if (preg_match('@/page/(.*)@si', $testUrl['path'], $urlMatch)) { + if (preg_match('@/(?:page|post)/(.*)@si', $testUrl['path'], $urlMatch)) { $replacement = $this->urlGenerator->generate('happyr_wordpress_page', ['slug' => $urlMatch[1]]); $content = str_replace($url, $replacement, $content); } diff --git a/Parser/RewriteMediaUrl.php b/src/Parser/RewriteMediaUrl.php similarity index 99% rename from Parser/RewriteMediaUrl.php rename to src/Parser/RewriteMediaUrl.php index 6f2914d..e87081e 100644 --- a/Parser/RewriteMediaUrl.php +++ b/src/Parser/RewriteMediaUrl.php @@ -33,7 +33,6 @@ private function rewriteUrl(string $content): string } if (!empty($contentUrl['host']) && $remoteUrl['host'] === $contentUrl['host']) { - // rewrite the URL. $content = $this->imageUploader->uploadImage($content); } diff --git a/Parser/RewriteUrls.php b/src/Parser/RewriteUrls.php similarity index 100% rename from Parser/RewriteUrls.php rename to src/Parser/RewriteUrls.php diff --git a/Resources/config/controller.yaml b/src/Resources/config/controller.yaml similarity index 100% rename from Resources/config/controller.yaml rename to src/Resources/config/controller.yaml diff --git a/Resources/config/routes.yaml b/src/Resources/config/routes.yaml similarity index 100% rename from Resources/config/routes.yaml rename to src/Resources/config/routes.yaml diff --git a/Resources/config/services.yaml b/src/Resources/config/services.yaml similarity index 100% rename from Resources/config/services.yaml rename to src/Resources/config/services.yaml diff --git a/Resources/docs/permalinks.png b/src/Resources/docs/permalinks.png similarity index 100% rename from Resources/docs/permalinks.png rename to src/Resources/docs/permalinks.png diff --git a/Resources/views/base.html.twig b/src/Resources/views/base.html.twig similarity index 100% rename from Resources/views/base.html.twig rename to src/Resources/views/base.html.twig diff --git a/Resources/views/index.html.twig b/src/Resources/views/index.html.twig similarity index 100% rename from Resources/views/index.html.twig rename to src/Resources/views/index.html.twig diff --git a/Resources/views/page.html.twig b/src/Resources/views/page.html.twig similarity index 100% rename from Resources/views/page.html.twig rename to src/Resources/views/page.html.twig diff --git a/Service/ImageUploaderInterface.php b/src/Service/ImageUploaderInterface.php similarity index 100% rename from Service/ImageUploaderInterface.php rename to src/Service/ImageUploaderInterface.php diff --git a/Service/LocalImageUploader.php b/src/Service/LocalImageUploader.php similarity index 100% rename from Service/LocalImageUploader.php rename to src/Service/LocalImageUploader.php diff --git a/Service/Wordpress.php b/src/Service/Wordpress.php similarity index 98% rename from Service/Wordpress.php rename to src/Service/Wordpress.php index 9a94b47..cf3e96e 100644 --- a/Service/Wordpress.php +++ b/src/Service/Wordpress.php @@ -5,11 +5,9 @@ namespace Happyr\WordpressBundle\Service; use Happyr\WordpressBundle\Api\WpClient; -use Happyr\WordpressBundle\Model\Category; use Happyr\WordpressBundle\Model\Menu; use Happyr\WordpressBundle\Model\Page; use Happyr\WordpressBundle\Parser\MessageParser; -use Psr\Cache\CacheItemInterface; use Symfony\Contracts\Cache\CacheInterface; use Symfony\Contracts\Cache\ItemInterface; diff --git a/Twig/WordpressExtension.php b/src/Twig/WordpressExtension.php similarity index 73% rename from Twig/WordpressExtension.php rename to src/Twig/WordpressExtension.php index 0a3a4fc..3c96f8d 100644 --- a/Twig/WordpressExtension.php +++ b/src/Twig/WordpressExtension.php @@ -8,6 +8,7 @@ use Happyr\WordpressBundle\Model\Media; use Happyr\WordpressBundle\Service\Wordpress; use Twig\Extension\AbstractExtension; +use Twig\TwigFunction; class WordpressExtension extends AbstractExtension { @@ -21,10 +22,10 @@ public function __construct(Wordpress $wp) public function getFunctions() { return [ - new \Twig_SimpleFunction('getWpMenu', [$this->wordpress, 'getMenu']), - new \Twig_SimpleFunction('getWpPage', [$this->wordpress, 'getPage']), - new \Twig_SimpleFunction('getWpCategoryById', [$this, 'getCategoryById']), - new \Twig_SimpleFunction('getWpMediaById', [$this, 'getMediaById']), + new TwigFunction('getWpMenu', [$this->wordpress, 'getMenu']), + new TwigFunction('getWpPage', [$this->wordpress, 'getPage']), + new TwigFunction('getWpCategoryById', [$this, 'getCategoryById']), + new TwigFunction('getWpMediaById', [$this, 'getMediaById']), ]; } diff --git a/WordpressBundle.php b/src/WordpressBundle.php similarity index 100% rename from WordpressBundle.php rename to src/WordpressBundle.php diff --git a/Tests/Parser/RewriteImageReferencesTest.php b/tests/Parser/RewriteImageReferencesTest.php similarity index 89% rename from Tests/Parser/RewriteImageReferencesTest.php rename to tests/Parser/RewriteImageReferencesTest.php index e9ce75d..96261f5 100644 --- a/Tests/Parser/RewriteImageReferencesTest.php +++ b/tests/Parser/RewriteImageReferencesTest.php @@ -17,14 +17,17 @@ class RewriteImageReferencesTest extends TestCase public function testRewrite($apiUrl, $input, $inputUrl, $output, $outputUrl) { $router = $this->getMockBuilder(ImageUploaderInterface::class) - ->setMethods(['uploadImage']) + ->onlyMethods(['uploadImage']) ->getMock(); $router->expects($this->once()) ->method('uploadImage') ->with($inputUrl) ->willReturn($outputUrl); - $page = $this->getMockBuilder(Page::class)->getMock(); + $page = $this->getMockBuilder(Page::class) + ->disableOriginalConstructor() + ->onlyMethods(['getContent', 'setContent', 'getExcerpt', 'setExcerpt']) + ->getMock(); $page->expects($this->once()) ->method('getContent') ->willReturn($input); diff --git a/Tests/Parser/RewriteLinksTest.php b/tests/Parser/RewriteLinksTest.php similarity index 83% rename from Tests/Parser/RewriteLinksTest.php rename to tests/Parser/RewriteLinksTest.php index f378eb1..91b621a 100644 --- a/Tests/Parser/RewriteLinksTest.php +++ b/tests/Parser/RewriteLinksTest.php @@ -7,7 +7,7 @@ use Happyr\WordpressBundle\Model\Page; use Happyr\WordpressBundle\Parser\RewriteLinks; use PHPUnit\Framework\TestCase; -use Symfony\Component\Routing\Generator\UrlGeneratorInterface; +use Symfony\Component\Routing\Generator\UrlGenerator; class RewriteLinksTest extends TestCase { @@ -16,15 +16,19 @@ class RewriteLinksTest extends TestCase */ public function testRewrite($input, $output, $apiUrl, $newUrl, $routeParams) { - $router = $this->getMockBuilder(UrlGeneratorInterface::class) - ->setMethods(['generate']) + $router = $this->getMockBuilder(UrlGenerator::class) + ->disableOriginalConstructor() + ->onlyMethods(['generate']) ->getMock(); $router->expects($this->once()) ->method('generate') ->with('happyr_wordpress_page', $routeParams) ->willReturn($newUrl); - $page = $this->getMockBuilder(Page::class)->getMock(); + $page = $this->getMockBuilder(Page::class) + ->disableOriginalConstructor() + ->onlyMethods(['getContent', 'setContent', 'getExcerpt', 'setExcerpt']) + ->getMock(); $page->expects($this->once()) ->method('getContent') ->willReturn($input); diff --git a/Tests/Parser/RewriteMediaUrlTest.php b/tests/Parser/RewriteMediaUrlTest.php similarity index 85% rename from Tests/Parser/RewriteMediaUrlTest.php rename to tests/Parser/RewriteMediaUrlTest.php index 79c6e9d..9d5653d 100644 --- a/Tests/Parser/RewriteMediaUrlTest.php +++ b/tests/Parser/RewriteMediaUrlTest.php @@ -16,10 +16,9 @@ class RewriteMediaUrlTest extends TestCase */ public function testRewrite($inputUrl, $outputUrl) { - $media = new Media(); - $media->setSourceUrl($inputUrl); + $media = new Media(['source_url' => $inputUrl, 'id' => 'abc', 'link' => 'http://wordpress.com/media/abc.png', 'slug' => 'abc1']); $imageUploader = $this->getMockBuilder(ImageUploaderInterface::class) - ->setMethods(['uploadImage']) + ->onlyMethods(['uploadImage']) ->getMock(); $imageUploader->method('uploadImage')->willReturn($outputUrl); diff --git a/Tests/Parser/RewriteUrlsTest.php b/tests/Parser/RewriteUrlsTest.php similarity index 72% rename from Tests/Parser/RewriteUrlsTest.php rename to tests/Parser/RewriteUrlsTest.php index cbef511..0aff668 100644 --- a/Tests/Parser/RewriteUrlsTest.php +++ b/tests/Parser/RewriteUrlsTest.php @@ -7,7 +7,7 @@ use Happyr\WordpressBundle\Model\Page; use Happyr\WordpressBundle\Parser\RewriteUrls; use PHPUnit\Framework\TestCase; -use Symfony\Component\Routing\Generator\UrlGeneratorInterface; +use Symfony\Component\Routing\Generator\UrlGenerator; class RewriteUrlsTest extends TestCase { @@ -16,14 +16,18 @@ class RewriteUrlsTest extends TestCase */ public function testRewrite($property, $input, $output) { - $router = $this->getMockBuilder(UrlGeneratorInterface::class) - ->setMethods(['generate']) + $router = $this->getMockBuilder(UrlGenerator::class) + ->disableOriginalConstructor() + ->onlyMethods(['generate']) ->getMock(); $router->expects($this->any()) ->method('generate') ->willReturn('https://example.com/foo'); - $page = $this->getMockBuilder(Page::class)->getMock(); + $page = $this->getMockBuilder(Page::class) + ->disableOriginalConstructor() + ->onlyMethods(['getContent', 'setContent', 'getExcerpt', 'setExcerpt']) + ->getMock(); $page->expects($this->once()) ->method('get'.$property) ->willReturn($input);