diff --git a/.travis.yml b/.travis.yml index 82d9ff4b..56371df2 100644 --- a/.travis.yml +++ b/.travis.yml @@ -33,7 +33,10 @@ before_install: - if [[ $COVERAGE != yes ]]; then phpenv config-rm xdebug.ini || true; fi; install: - - composer update --prefer-dist --no-interaction + - if [[ $TRAVIS_PHP_VERSION = hhvm-3.30 ]]; then composer require phpunit/phpunit:4.8.36 --dev; fi + - export COMPOSER_FLAGS="--prefer-dist --no-interaction" + - if [[ $TRAVIS_PHP_VERSION = nightly ]]; then export COMPOSER_FLAGS="$COMOPSER_FLAGS --ignore-platform-reqs"; fi + - composer update $COMPOSER_FLAGS script: - if [[ $COVERAGE = yes ]]; then vendor/bin/phpunit --coverage-clover=coverage.clover; else vendor/bin/phpunit; fi diff --git a/composer.json b/composer.json index b6002ef3..1aa9f270 100644 --- a/composer.json +++ b/composer.json @@ -18,8 +18,7 @@ "symfony/polyfill-ctype": "^1.8" }, "require-dev": { - "phpunit/phpunit": "^4.6", - "sebastian/version": "^1.0.1" + "phpunit/phpunit": "^4.8.36 || ^7.5.13" }, "extra": { "branch-alias": { diff --git a/tests/AssertTest.php b/tests/AssertTest.php index fe675337..69543082 100644 --- a/tests/AssertTest.php +++ b/tests/AssertTest.php @@ -16,7 +16,6 @@ use Exception; use Error; use LogicException; -use PHPUnit_Framework_TestCase; use RuntimeException; use stdClass; use Webmozart\Assert\Assert; @@ -26,7 +25,7 @@ * * @author Bernhard Schussek */ -class AssertTest extends PHPUnit_Framework_TestCase +class AssertTest extends BaseTestCase { private static $resource; @@ -359,7 +358,7 @@ public function getTests() // no tests for readable()/writable() for now array('classExists', array(__CLASS__), true), array('classExists', array(__NAMESPACE__.'\Foobar'), false), - array('subclassOf', array(__CLASS__, 'PHPUnit_Framework_TestCase'), true), + array('subclassOf', array(__CLASS__, 'Webmozart\Assert\Tests\BaseTestCase'), true), array('subclassOf', array(__CLASS__, 'stdClass'), false), array('interfaceExists', array('\Countable'), true), array('interfaceExists', array(__CLASS__), false), @@ -506,6 +505,7 @@ public function testAssert($method, $args, $success, $multibyte = false, $minVer } call_user_func_array(array('Webmozart\Assert\Assert', $method), $args); + $this->addToAssertionCount(1); } /** @@ -527,6 +527,7 @@ public function testNullOr($method, $args, $success, $multibyte = false, $minVer } call_user_func_array(array('Webmozart\Assert\Assert', 'nullOr'.ucfirst($method)), $args); + $this->addToAssertionCount(1); } /** @@ -535,6 +536,7 @@ public function testNullOr($method, $args, $success, $multibyte = false, $minVer public function testNullOrAcceptsNull($method) { call_user_func(array('Webmozart\Assert\Assert', 'nullOr'.ucfirst($method)), null); + $this->addToAssertionCount(1); } /** @@ -559,6 +561,7 @@ public function testAllArray($method, $args, $success, $multibyte = false, $minV array_unshift($args, array($arg)); call_user_func_array(array('Webmozart\Assert\Assert', 'all'.ucfirst($method)), $args); + $this->addToAssertionCount(1); } /** @@ -583,6 +586,7 @@ public function testAllTraversable($method, $args, $success, $multibyte = false, array_unshift($args, new ArrayIterator(array($arg))); call_user_func_array(array('Webmozart\Assert\Assert', 'all'.ucfirst($method)), $args); + $this->addToAssertionCount(1); } public function getStringConversions() diff --git a/tests/BaseTestCase.php b/tests/BaseTestCase.php new file mode 100644 index 00000000..c48b10d0 --- /dev/null +++ b/tests/BaseTestCase.php @@ -0,0 +1,36 @@ +expectException($exceptionName); + if($exceptionMessage) { + $this->expectExceptionMessage($exceptionMessage); + } + if( $exceptionCode) { + $this->expectExceptionCode($exceptionCode); + } + return; + } + parent::setExpectedException($exceptionName, $exceptionMessage, $exceptionCode); + } +} diff --git a/tests/ProjectCodeTest.php b/tests/ProjectCodeTest.php index e8731572..bce516c7 100644 --- a/tests/ProjectCodeTest.php +++ b/tests/ProjectCodeTest.php @@ -2,14 +2,13 @@ namespace Webmozart\Assert\Tests; -use PHPUnit_Framework_TestCase; use ReflectionClass; use ReflectionMethod; /** * @coversNothing */ -class ProjectCodeTest extends PHPUnit_Framework_TestCase +class ProjectCodeTest extends BaseTestCase { private static $readmeContent; private static $assertDocComment;