Skip to content
This repository has been archived by the owner on Mar 1, 2023. It is now read-only.

Added support for phpunit 8 #20

Merged
merged 4 commits into from
Aug 1, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ build/logs/
vendor/

composer.phar
composer.lock
.php_cs.cache
.DS_Store
Thumbs.db
/.phpunit.result.cache
6 changes: 5 additions & 1 deletion .php_cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,11 @@ $config->getFinder()
->exclude('vendor')
->name('*.php')
->ignoreDotFiles(true)
->ignoreVCS(true);
->ignoreVCS(true)
->notPath('src/TestingHelper/Constraint/ArraySubset.php')
->notPath('src/TestingHelper/Phpunit/MockeryTestCase.php')
->notPath('tests/Fixture/FooObject.php')
->notPath('tests/Fixture/MockObject.php');

$cacheDir = getenv('TRAVIS') ? getenv('HOME') . '/.php-cs-fixer' : __DIR__;

Expand Down
76 changes: 50 additions & 26 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ language: php

env:
global:
- TEST="./vendor/bin/phpunit --verbose"
- COMPOSER_UP="composer update --no-interaction --prefer-dist --no-progress --profile --no-suggest"
- TEST="./vendor/bin/phpunit --verbose"
- COMPOSER_UP="composer update --no-interaction --prefer-dist --no-progress --profile --no-suggest"

cache:
directories:
Expand All @@ -19,33 +19,57 @@ before_install:
- ./build/travis/configure_php.sh

install:
- composer global require hirak/prestissimo
- $COMPOSER_UP
- composer global require hirak/prestissimo
- |
if [[ "$SETUP" = "high" ]]; then
$COMPOSER_UP
elif [[ "$SETUP" = "lowest" ]]; then
$COMPOSER_UP --prefer-lowest --prefer-stable;
fi

jobs:
allow_failures:
- php: nightly
- php: 7.4snapshot

include:
- stage: Test
php: 7.2
env: REMOVE_XDEBUG=true

- stage: Coding standard
php: 7.2
env: REMOVE_XDEBUG=true
script:
- ./vendor/bin/php-cs-fixer fix --verbose --diff --dry-run
- stage: Coding standard
php: 7.2
env: REMOVE_XDEBUG=false
script:
- ./vendor/bin/phpstan analyse -c phpstan.neon -l 7 src

- stage: Coverage
php: 7.2
env: REMOVE_XDEBUG=false
script:
- bash -xc "$TEST -c ./phpunit.xml.dist --coverage-clover=coverage.xml"
after_success:
- bash <(curl -s https://codecov.io/bash)
- stage: Test
php: 7.2
env: SETUP=lowest REMOVE_XDEBUG=true
- stage: Test
php: 7.2
env: SETUP=high REMOVE_XDEBUG=true
- stage: Test
php: 7.3
env: SETUP=lowest REMOVE_XDEBUG=true
- stage: Test
php: 7.3
env: SETUP=high REMOVE_XDEBUG=true
- stage: Test
php: 7.4snapshot
env: SETUP=lowest REMOVE_XDEBUG=true
- stage: Test
php: nightly
env: SETUP=high REMOVE_XDEBUG=true

- stage: Coding standard
php: 7.3
env: SETUP=high REMOVE_XDEBUG=true
script:
- ./vendor/bin/php-cs-fixer fix --verbose --diff --dry-run
- stage: Coding standard
php: 7.3
env: SETUP=high REMOVE_XDEBUG=false
script:
- ./vendor/bin/phpstan analyse -c phpstan.neon -l 7 src

- stage: Coverage
php: 7.3
env: SETUP=high REMOVE_XDEBUG=false
script:
- bash -xc "$TEST -c ./phpunit.xml.dist --coverage-clover=coverage.xml"
after_success:
- bash <(curl -s https://codecov.io/bash)

notifications:
email:
Expand Down
12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ Usage
-------------

``` php
use Narrowspark\TestingHelper\Traits\TestHelperTrait;
use Narrowspark\TestingHelper\Traits\AssertArrayTrait;

class ModelTest extends \PHPUnit_Framework_TestCase
{
use TestHelperTrait;
use AssertArrayTrait;

// Now you can do something like this.
public function testIfArrayContainIrix()
Expand All @@ -34,6 +34,14 @@ class ModelTest extends \PHPUnit_Framework_TestCase

self::assertInArray('Irix', $haystack);
}

// or
public function testAssertArraySubsetThrowsExceptionForInvalidSubset(): void
{
$this->expectException(ExpectationFailedException::class);

$this->assertArraySubset([6, 7], [1, 2, 3, 4, 5, 6]);
}
}
```

Expand Down
85 changes: 48 additions & 37 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,59 +1,70 @@
{
"name" : "narrowspark/testing-helper",
"type" : "library",
"name": "narrowspark/testing-helper",
"type": "library",
"description": "Provides test helpers.",
"keywords" : [
"phpunit", "mockery", "mock", "faker", "setter", "getter", "timing", "test"
"keywords": [
"phpunit",
"mockery",
"mock",
"faker",
"setter",
"getter",
"timing",
"test"
],
"license" : "MIT",
"homepage" : "https://github.com/narrowspark/testing-helper",
"support" : {
"issues" : "https://github.com/narrowspark/testing-helper/issues",
"source" : "https://github.com/narrowspark/testing-helper"
},
"authors" : [
"homepage": "https://github.com/narrowspark/testing-helper",
"license": "MIT",
"authors": [
{
"name" : "Daniel Bannert",
"email" : "[email protected]",
"name": "Daniel Bannert",
"email": "[email protected]",
"homepage": "http://anolilab.de",
"role" : "Developer"
"role": "Developer"
}
],
"require": {
"php" : "^7.2",
"psr/http-factory" : "^1.0.0",
"psr/container" : "^1.0.0",
"psr/http-message" : "^1.0.0",
"psr/http-server-middleware" : "^1.0.0"
"php": "^7.2",
"phpunit/phpunit": "^8.0",
"psr/container": "^1.0.0",
"psr/http-factory": "^1.0.0",
"psr/http-message": "^1.0.0",
"psr/http-server-middleware": "^1.0.0"
},
"require-dev": {
"fzaninotto/faker" : "^1.6",
"mockery/mockery" : "^1.0",
"narrowspark/coding-standard" : "^1.0.0",
"phpunit/phpunit" : "^7.2.0",
"guzzlehttp/psr7": "^1.4"
"ext-json": "*",
"fzaninotto/faker": "^1.8.0",
"guzzlehttp/psr7": "^1.6.1",
"mockery/mockery": "^1.2.2",
"narrowspark/coding-standard": "^2.0.0"
},
"suggest": {
"fzaninotto/faker": "Required to use the FakerTrait (^1.6)",
"mockery/mockery": "Required to use the MockeryTestCase (^0.9)",
"nyholm/nsa": "Required to test your private/protected methods/properties (^1.1)."
},
"autoload": {
"psr-4": {
"Narrowspark\\TestingHelper\\" : "src/TestingHelper/"
"Narrowspark\\TestingHelper\\": "src/TestingHelper/"
}
},
"autoload-dev": {
"psr-4": {
"Narrowspark\\TestingHelper\\Tests\\" : "tests/"
}
},
"suggest": {
"fzaninotto/faker" : "Required to use the FakerTrait (^1.6)",
"mockery/mockery" : "Required to use the MockeryTestCase (^0.9)",
"nyholm/nsa" : "Required to test your private/protected methods/properties (^1.1)."
"Narrowspark\\TestingHelper\\Tests\\": "tests/"
},
"classmap": [
"vendor/phpunit/phpunit/tests/"
]
},
"minimum-stability": "dev",
"prefer-stable": true,
"scripts": {
"test" : "phpunit",
"coverage" : "phpunit --coverage-html=\"build/logs\"",
"coverage": "phpunit --coverage-html=\"build/logs\"",
"cs": "php-cs-fixer fix",
"phpstan": "phpstan analyse -c phpstan.neon -l 7 src --memory-limit=-1"
"phpstan": "phpstan analyse -c phpstan.neon -l 7 src --memory-limit=-1",
"test": "phpunit"
},
"minimum-stability" : "dev",
"prefer-stable" : true
"support": {
"issues": "https://github.com/narrowspark/testing-helper/issues",
"source": "https://github.com/narrowspark/testing-helper"
}
}
Loading