diff --git a/.ecrc b/.ecrc new file mode 100644 index 000000000..4d0f6e504 --- /dev/null +++ b/.ecrc @@ -0,0 +1,12 @@ +{ + "Verbose": true, + "IgnoreDefaults": false, + "Exclude": [ + ".phpunit.result.cache", + ".php-cs-fixer.cache", + ".idea", + ".git", + "vendor/", + "tests/fixtures" + ] +} diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..eda412b6c --- /dev/null +++ b/.editorconfig @@ -0,0 +1,18 @@ +root = true + +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +indent_style = space +indent_size = 2 +trim_trailing_whitespace = true + +[*.php] +indent_size = 4 + +[*.md] +trim_trailing_whitespace = false + +[*.neon] +indent_style = tab diff --git a/.gitattributes b/.gitattributes index 93298ab07..0b9d70cfc 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,7 +1,12 @@ -/docs export-ignore -/tests export-ignore -/.gitattributes export-ignore -/.gitignore export-ignore -/.travis.yml export-ignore -/phpunit.xml export-ignore -/phpunit.xml.dist export-ignore +/docs export-ignore +/tests export-ignore +/.gitattributes export-ignore +/.gitignore export-ignore +/.php-cs-fixer.dist.php export-ignore +/.editorconfig export-ignore +/.ecrc export-ignore +/docker-compose.yaml export-ignore +/phpstan.neon export-ignore +/phpstan-baseline.neon export-ignore +/phpunit.xml.dist export-ignore +/resources export-ignore diff --git a/.github/workflows/continuous integration.yml b/.github/workflows/continuous integration.yml new file mode 100644 index 000000000..711b7ce52 --- /dev/null +++ b/.github/workflows/continuous integration.yml @@ -0,0 +1,142 @@ +name: "Continuous Integration" + +on: + push: + pull_request: + +jobs: + phpstan: + name: "PHPStan" + runs-on: "ubuntu-latest" + + steps: + - name: "Checkout code" + uses: "actions/checkout@v2" + + - name: "Install PHP" + uses: "shivammathur/setup-php@v2" + with: + php-version: "8.0" + extensions: "curl, soap" + tools: "composer:v2" + + - name: "Enforce using stable dependencies" + run: "composer config minimum-stability stable" + + - name: "Check Composer configuration" + run: "composer validate --strict" + + - name: "Install dependencies with Composer" + uses: "ramsey/composer-install@v2" + with: + dependency-versions: "highest" + composer-options: "--prefer-dist -o" + + - name: "Run PHPStan" + run: "composer run-script phpstan" + + editorconfig-checker: + name: EditorConfig Checker + runs-on: "ubuntu-latest" + + steps: + - name: "Checkout code" + uses: "actions/checkout@v2" + + - name: "Install EditorConfig Checker" + uses: "editorconfig-checker/action-editorconfig-checker@main" + + - name: "Run EditorConfig Checker" + run: "editorconfig-checker" + + codestyle: + name: "PHP-CS-Fixer" + runs-on: "ubuntu-latest" + + steps: + - name: "Checkout code" + uses: "actions/checkout@v2" + + - name: "Install PHP" + uses: "shivammathur/setup-php@v2" + with: + php-version: "8.0" + extensions: "curl, soap" + tools: "composer:v2" + + - name: "Enforce using stable dependencies" + run: "composer config minimum-stability stable" + + - name: "Check Composer configuration" + run: "composer validate --strict" + + - name: "Install dependencies with Composer" + uses: "ramsey/composer-install@v2" + with: + dependency-versions: "highest" + composer-options: "--prefer-dist -o" + + - name: "Run PHP-CS-Fixer" + run: "composer run-script cs" + + phpunit: + name: "PHPUnit Test" + runs-on: "ubuntu-latest" + + strategy: + fail-fast: false + matrix: + php: + - "8.0" + - "8.1" + - "8.2" + - "8.3" + - "8.4" + dependencies: + - "lowest" + - "highest" + stability: + - "stable" + + steps: + - name: "Checkout code" + uses: "actions/checkout@v2" + with: + fetch-depth: 2 + + - name: "Install PHP" + uses: "shivammathur/setup-php@v2" + with: + php-version: "${{ matrix.php }}" + extensions: "curl, soap" + tools: "composer:v2" + coverage: "pcov" + + - name: "Enforce using stable dependencies" + run: "composer config minimum-stability stable" + if: "${{ matrix.stability == 'stable' }}" + + - name: "Check Composer configuration" + run: "composer validate --strict" + + - name: "Install dependencies with Composer" + uses: "ramsey/composer-install@v2" + with: + dependency-versions: "${{ matrix.dependencies }}" + composer-options: "--prefer-dist -o" + + - name: "Run PHPUnit Test" + run: "vendor/bin/phpunit --coverage-clover=coverage.clover --log-junit=phpunit.xml" + + - name: "Publish Test Report" + uses: "mikepenz/action-junit-report@v2" + if: "always()" # always run even if the previous step fails + with: + report_paths: "phpunit.xml" + check_name: "PHPUnit Test Report (${{ matrix.php }}, ${{ matrix.dependencies }}, ${{ matrix.stability }})" + + - name: "Publish Scrutinizer Coverage" + uses: "sudo-bot/action-scrutinizer@latest" + if: "always()" # always run even if the previous step fails + with: + cli-args: "--format=php-clover coverage.clover" diff --git a/.gitignore b/.gitignore index 2883d5b45..88071df64 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,8 @@ -*.idea* -*.sublime-* **/vendor/* coverage/* notes.md tests/fixtures/cassette* -/.php_cs.cache /.php_cs +composer.lock +.phpunit.result.cache +.php-cs-fixer.cache diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php new file mode 100644 index 000000000..2733e07e9 --- /dev/null +++ b/.php-cs-fixer.dist.php @@ -0,0 +1,18 @@ +setRules([ + '@PSR12' => true, + '@Symfony' => true, + '@Symfony:risky' => true, + '@PHP80Migration' => true, + '@PHP80Migration:risky' => true, + '@PHPUnit84Migration:risky' => true, + ]) + ->setFinder( + PhpCsFixer\Finder::create() + ->exclude('vendor') + ->exclude('docs') + ->in(__DIR__) + ) + ->setRiskyAllowed(true); diff --git a/.php_cs.dist b/.php_cs.dist deleted file mode 100644 index 871b5ac9a..000000000 --- a/.php_cs.dist +++ /dev/null @@ -1,20 +0,0 @@ -setRules([ - '@PSR2' => true, - 'single_blank_line_before_namespace' => true, - 'concat_space' => ['spacing' => 'one'], - 'single_quote' => true, - 'braces' => true, - ]) - - ->setFinder( - PhpCsFixer\Finder::create() - ->exclude('vendor') - ->exclude('docs') - ->in(__DIR__) - ) - - ->setRiskyAllowed(true); - diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 06f543c1e..000000000 --- a/.travis.yml +++ /dev/null @@ -1,64 +0,0 @@ -language: php -dist: precise - -matrix: - fast_finish: true - include: - - env: TEST_DIR=. - php: 5.3 - - env: TEST_DIR=. COMPOSER_FLAGS="--prefer-lowest" - php: 5.3 - - env: TEST_DIR=. - php: 5.4 - - env: TEST_DIR=. - php: 5.5 - - env: TEST_DIR=. - php: 5.6 - - env: TEST_DIR=. COMPOSER_FLAGS="--prefer-lowest" - php: 5.6 - - env: TEST_DIR=. - php: 7.0 - - env: TEST_DIR=. COMPOSER_FLAGS="--prefer-lowest" - php: 7.0 - - env: TEST_DIR=. - php: 7.1 - - env: TEST_DIR=. COMPOSER_FLAGS="--prefer-lowest" - php: 7.1 - - env: TEST_DIR=. PHP_CS_FIXER=true - php: 7.2 - - env: TEST_DIR=tests/integration/guzzle/3 - php: 5.6 - - env: TEST_DIR=tests/integration/guzzle/4 - php: 5.6 - - env: TEST_DIR=tests/integration/guzzle/5 - php: 5.6 - - env: TEST_DIR=tests/integration/guzzle/6 - php: 5.6 - - env: TEST_DIR=tests/integration/soap - php: 5.6 - -before_install: - - composer self-update - -install: - - composer update --prefer-source -o $COMPOSER_FLAGS - - PHPUNIT_BIN=$(pwd)/vendor/bin/phpunit - - cd ${TEST_DIR} - - composer update --prefer-source -o $COMPOSER_FLAGS - -script: - - $PHPUNIT_BIN --coverage-clover=coverage.clover - - if [ "${PHP_CS_FIXER}" = "true" ]; then wget http://cs.sensiolabs.org/download/php-cs-fixer-v2.phar && php ./php-cs-fixer-v2.phar fix --dry-run --diff $TRAVIS_BUILD_DIR; fi - -after_success: - - wget https://scrutinizer-ci.com/ocular.phar - - php ocular.phar code-coverage:upload --format=php-clover coverage.clover - -cache: - directories: - - vendor - - tests/integration/guzzle/3/vendor - - tests/integration/guzzle/4/vendor - - tests/integration/guzzle/5/vendor - - tests/integration/guzzle/6/vendor - - $HOME/.composer/cache diff --git a/LICENSE.md b/LICENSE.md index 0d8812c51..bb5af01e3 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -16,4 +16,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. \ No newline at end of file +THE SOFTWARE. diff --git a/README.md b/README.md index 75b060ce2..bae7e2488 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ ![PHP-VCR](https://user-images.githubusercontent.com/133832/27151811-0d95c6c4-514c-11e7-834e-eff1eec2ea16.png) -[![Build Status](https://travis-ci.org/php-vcr/php-vcr.svg?branch=master)](https://travis-ci.org/php-vcr/php-vcr) +[![Continuous Integration](https://github.com/php-vcr/php-vcr/actions/workflows/continuous%20integration.yml/badge.svg?branch=master)](https://github.com/php-vcr/php-vcr/actions/workflows/continuous%20integration.yml) [![Code Coverage](https://scrutinizer-ci.com/g/php-vcr/php-vcr/badges/coverage.png?s=15cf1644c8cf37a868e03cfba809a5e24c78f285)](https://scrutinizer-ci.com/g/php-vcr/php-vcr/) [![Scrutinizer Quality Score](https://scrutinizer-ci.com/g/php-vcr/php-vcr/badges/quality-score.png?s=4f638dbca5eb51fb9c87a1dd45c5df94687d85bd)](https://scrutinizer-ci.com/g/php-vcr/php-vcr/) @@ -8,13 +8,13 @@ This is a port of the [VCR](http://github.com/vcr/vcr) Ruby library to PHP. Record your test suite's HTTP interactions and replay them during future test runs for fast, deterministic, accurate tests. A bit of documentation can be found on the [php-vcr website](http://php-vcr.github.io). -Disclaimer: Doing this in PHP is not as easy as in programming languages which support monkey patching (I'm looking at you, Ruby) – this project is not yet fully tested, so please use at your own risk! +Disclaimer: Doing this in PHP is not as easy as in programming languages which support monkey patching (I'm looking at you, Ruby) ## Features * Automatically records and replays your HTTP(s) interactions with minimal setup/configuration code. * Supports common http functions and extensions - * everyting using [streamWrapper](http://php.net/manual/en/class.streamwrapper.php): fopen(), fread(), file_get_contents(), ... without any modification (except `$http_response_header` see #96) + * everything using [streamWrapper](http://php.net/manual/en/class.streamwrapper.php): fopen(), fread(), file_get_contents(), ... without any modification (except `$http_response_header` see [#96](https://github.com/php-vcr/php-vcr/issues/96)) * [SoapClient](http://www.php.net/manual/en/soapclient.soapclient.php) by adding `\VCR\VCR::turnOn();` in your `tests/bootstrap.php` * curl(), by adding `\VCR\VCR::turnOn();` in your `tests/bootstrap.php` * The same request can receive different responses in different tests -- just use different cassettes. @@ -30,7 +30,7 @@ Disclaimer: Doing this in PHP is not as easy as in programming languages which s Using static method calls: ``` php -class VCRTest extends \PHPUnit_Framework_TestCase +class VCRTest extends TestCase { public function testShouldInterceptStreamWrapper() { @@ -68,7 +68,7 @@ class VCRTest extends \PHPUnit_Framework_TestCase You can use annotations in PHPUnit by using [phpunit-testlistener-vcr](https://github.com/php-vcr/phpunit-testlistener-vcr): ``` php -class VCRTest extends \PHPUnit_Framework_TestCase +class VCRTest extends TestCase { /** * @vcr unittest_annotation_test @@ -97,9 +97,9 @@ $ composer require --dev php-vcr/php-vcr PHP-VCR depends on: - * PHP 5.3+ + * PHP 8 * Curl extension - * HTTP library [Guzzle](http://guzzlephp.org) + * [symfony/event-dispatcher](https://github.com/symfony/event-dispatcher) * [symfony/yaml](https://github.com/symfony/yaml) * [beberlei/assert](https://github.com/beberlei/assert) @@ -121,7 +121,7 @@ composer test [Old changelog entries](docs/old-changelog.md) ## Copyright -Copyright (c) 2013-2016 Adrian Philipp. Released under the terms of the MIT license. See LICENSE for details. +Copyright (c) 2013-2023 Adrian Philipp. Released under the terms of the MIT license. See LICENSE for details. [Contributors](https://github.com/php-vcr/php-vcr/graphs/contributors)