diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml new file mode 100644 index 0000000..838bff0 --- /dev/null +++ b/.github/workflows/tests.yml @@ -0,0 +1,115 @@ +on: + pull_request: + schedule: + - cron: "0 0 * * *" + +concurrency: + group: ${{ github.head_ref || 'cron' }} + cancel-in-progress: true + +jobs: + tests: + runs-on: ubuntu-latest + strategy: + matrix: + php-version: + - '8.1' + - '8.0' + - '7.4' + - '7.3' + - '7.2' + - '7.1' + - '7.0' + mockery-version: + - '1.5.0' + - '1.4.0' + - '1.3.0' + - '1.2.0' + - '1.1.0' + - '1.0.0' + - '0.9.0' + - '0.8.0' + + exclude: + # PHP 8.1 Exclusions + - php-version: '8.1' + mockery-version: '1.3.0' + - php-version: '8.1' + mockery-version: '1.2.0' + - php-version: '8.1' + mockery-version: '1.1.0' + - php-version: '8.1' + mockery-version: '1.0.0' + - php-version: '8.1' + mockery-version: '0.9.0' + - php-version: '8.1' + mockery-version: '0.8.0' + + # PHP 8.0 Exclusions + - php-version: '8.0' + mockery-version: '1.1.0' + - php-version: '8.0' + mockery-version: '1.0.0' + - php-version: '8.0' + mockery-version: '0.9.0' + - php-version: '8.0' + mockery-version: '0.8.0' + + # PHP 7.4 Exclusions + - php-version: '7.4' + mockery-version: '1.1.0' + - php-version: '7.4' + mockery-version: '1.0.0' + - php-version: '7.4' + mockery-version: '0.9.0' + - php-version: '7.4' + mockery-version: '0.8.0' + + # PHP 7.2 Exclusions + - php-version: '7.2' + mockery-version: '1.5.0' + - php-version: '7.2' + mockery-version: '1.4.0' + + # PHP 7.1 Exclusions + - php-version: '7.1' + mockery-version: '1.5.0' + - php-version: '7.1' + mockery-version: '1.4.0' + + # PHP 7.0 Exclusions + - php-version: '7.0' + mockery-version: '1.5.0' + - php-version: '7.0' + mockery-version: '1.4.0' + + name: Mockery ${{ matrix.mockery-version }} on PHP ${{ matrix.php-version }} + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + ref: ${{ github.head_ref }} + + - name: Install PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-version }} + ini-values: zend.assertions=1 + + - name: Install Dependencies + run: composer require mockery/mockery:~${{ matrix.mockery-version }} squizlabs/php_codesniffer phpmd/phpmd cundd/test-flight + + - name: PHPUnit + run: vendor/bin/phpunit + + - name: Test Flight + if: matrix.php-version != '8.1' + run: | + vendor/bin/test-flight README.md + vendor/bin/test-flight classes/ + + - name: PHPCS + run: vendor/bin/phpcs --standard=PSR2 classes/ tests/ + + - name: PHPMD + run: vendor/bin/phpmd classes/ text cleancode,codesize,controversial,design,naming,unusedcode diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 85183ea..0000000 --- a/.travis.yml +++ /dev/null @@ -1,55 +0,0 @@ -language: php - -cache: - directories: - - $HOME/.composer/cache - -env: - - MOCKERY_VERSION=dev-master - - MOCKERY_VERSION=~1.4.0 - - MOCKERY_VERSION=~1.3.0 - - MOCKERY_VERSION=~1.2.0 - - MOCKERY_VERSION=~1.1.0 - - MOCKERY_VERSION=~1.0.0 - - MOCKERY_VERSION=~0.9.0 - - MOCKERY_VERSION=~0.8.0 - -php: - - 8.0 - - 7.4 - - 7.3 - - 7.2 - - 7.1 - - 7.0 - - 5.6 - -matrix: - fast_finish: true - exclude: - - php: 8.0 - env: MOCKERY_VERSION=~1.1.0 - - php: 8.0 - env: MOCKERY_VERSION=~1.0.0 - - php: 8.0 - env: MOCKERY_VERSION=~0.9.0 - - php: 8.0 - env: MOCKERY_VERSION=~0.8.0 - - - php: 7.4 - env: MOCKERY_VERSION=~1.1.0 - - php: 7.4 - env: MOCKERY_VERSION=~1.0.0 - - php: 7.4 - env: MOCKERY_VERSION=~0.9.0 - - php: 7.4 - env: MOCKERY_VERSION=~0.8.0 - -install: - - composer require mockery/mockery:${MOCKERY_VERSION} squizlabs/php_codesniffer phpmd/phpmd cundd/test-flight - -script: - - vendor/bin/phpunit - - vendor/bin/test-flight README.md - - vendor/bin/test-flight classes/ - - vendor/bin/phpcs --standard=PSR2 classes/ tests/ - - vendor/bin/phpmd classes/ text cleancode,codesize,controversial,design,naming,unusedcode diff --git a/README.md b/README.md index 4c096c7..53c9629 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,11 @@ +[![.github/workflows/tests.yml](https://github.com/php-mock/php-mock-mockery/actions/workflows/tests.yml/badge.svg)](https://github.com/php-mock/php-mock-mockery/actions/workflows/tests.yml) + # Mock PHP built-in functions with Mockery This package integrates the function mock library [PHP-Mock](https://github.com/php-mock/php-mock) with Mockery. -# Installation +## Installation Use [Composer](https://getcomposer.org/): @@ -11,14 +13,14 @@ Use [Composer](https://getcomposer.org/): composer require --dev php-mock/php-mock-mockery ``` -# Usage +## Usage [`PHPMockery::mock()`](http://php-mock.github.io/php-mock-mockery/api/class-phpmock.mockery.PHPMockery.html#_mock) let's you build a function mock which can be equiped with Mockery's expectations. After your test you'll have to disable all created function mocks by calling `Mockery::close()`. -## Example +### Example ```php namespace foo; @@ -31,7 +33,7 @@ assert (3 == time()); \Mockery::close(); ``` -## Restrictions +### Restrictions This library comes with the same restrictions as the underlying [`php-mock`](https://github.com/php-mock/php-mock#requirements-and-restrictions): @@ -46,14 +48,12 @@ This library comes with the same restrictions as the underlying this issue you can call [`PHPMockery::define()`](http://php-mock.github.io/php-mock-mockery/api/class-phpmock.mockery.PHPMockery.html#_define) before that first call. This would define a side effectless namespaced function. -# License and authors +## License and authors This project is free and under the WTFPL. Responsable for this project is Markus Malkusch markus@malkusch.de. -## Donations +### Donations If you like this project and feel generous donate a few Bitcoins here: [1335STSwu9hST4vcMRppEPgENMHD2r1REK](bitcoin:1335STSwu9hST4vcMRppEPgENMHD2r1REK) - -[![Build Status](https://travis-ci.org/php-mock/php-mock-mockery.svg?branch=master)](https://travis-ci.org/php-mock/php-mock-mockery) diff --git a/composer.json b/composer.json index efbe075..c7bfe93 100644 --- a/composer.json +++ b/composer.json @@ -22,7 +22,7 @@ "php-mock/php-mock-integration": "^2" }, "require-dev": { - "phpunit/phpunit": "^4|^5" + "phpunit/phpunit": "^4|^5|^8" }, "archive": { "exclude": ["/tests"] diff --git a/tests/PHPMockeryTest.php b/tests/PHPMockeryTest.php index 3f799a7..e5f8f9b 100644 --- a/tests/PHPMockeryTest.php +++ b/tests/PHPMockeryTest.php @@ -32,10 +32,8 @@ protected function mockFunction($namespace, $functionName, callable $function) PHPMockery::mock($namespace, $functionName)->andReturnUsing($function); } - protected function setUp() + protected function setUpCompat() { - parent::setUp(); - $this->workaroundMockeryIssue268(); }