diff --git a/.travis.yml b/.travis.yml index a8d48d0c7ce..71e8d262882 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,14 +1,29 @@ language: php matrix: - include: + exclude: - php: 7.0 + env: DEPS="" COVERALLS=true - php: 7.1 + env: DEPS="" COVERALLS=true - php: 7.2 - env: COVERALLS=true + env: DEPS="" COVERALLS="" - php: nightly + env: DEPS="" COVERALLS=true allow_failures: - php: nightly + - php: 7.0 + env: DEPS="" COVERALLS="" +php: + - 7.0 + - 7.1 + - 7.2 + - nightly + +env: + - DEPS="--prefer-lowest --prefer-stable" COVERALLS="" + - DEPS="" COVERALLS="" + - DEPS="" COVERALLS=true cache: directories: @@ -16,13 +31,14 @@ cache: before_install: # determine INI file - - export INI=~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini + - export INI_DIR=~/.phpenv/versions/$(phpenv version-name)/etc/conf.d + - export INI=$INI_DIR/travis.ini # disable default memory limit - echo memory_limit = 2G >> $INI - - if [[ $COVERALLS = "" ]]; then phpenv config-rm xdebug.ini; fi + - if [[ $COVERALLS = "" && -f $INI_DIR/xdebug.ini ]]; then phpenv config-rm xdebug.ini; fi install: - - composer --prefer-source install + - composer --prefer-source $DEPS update script: - vendor/bin/phpunit diff --git a/composer.json b/composer.json index f159f2c117d..7e117b3e216 100644 --- a/composer.json +++ b/composer.json @@ -32,7 +32,7 @@ "optimize-autoloader": true }, "require-dev": { - "phpunit/phpunit": "^5.7.4", + "phpunit/phpunit": "^6.0 || ^7.0", "squizlabs/php_codesniffer": "^3.0", "php-coveralls/php-coveralls": "^2.0", "bamarni/composer-bin-plugin": "^1.2" diff --git a/tests/DocumentationTest.php b/tests/DocumentationTest.php index 2a7fd98cab6..46a2abb5548 100644 --- a/tests/DocumentationTest.php +++ b/tests/DocumentationTest.php @@ -110,7 +110,7 @@ public function testAllIssuesCovered() */ public function testInvalidCode($code, $error_message, $error_levels = [], $check_references = false) { - if (strpos($this->getName(), 'SKIPPED-') !== false) { + if (strpos($this->getTestName(), 'SKIPPED-') !== false) { $this->markTestSkipped(); } diff --git a/tests/FileManipulationTest.php b/tests/FileManipulationTest.php index efe0cddd71b..c80db7c4ccf 100644 --- a/tests/FileManipulationTest.php +++ b/tests/FileManipulationTest.php @@ -33,7 +33,7 @@ public function setUp() */ public function testValidCode($input_code, $output_code, $php_version, array $issues_to_fix, $safe_types) { - $test_name = $this->getName(); + $test_name = $this->getTestName(); if (strpos($test_name, 'PHP7-') !== false) { if (version_compare(PHP_VERSION, '7.0.0dev', '<')) { $this->markTestSkipped('Test case requires PHP 7.'); diff --git a/tests/FileReferenceTest.php b/tests/FileReferenceTest.php index a575d73962e..a4a5d11eb21 100644 --- a/tests/FileReferenceTest.php +++ b/tests/FileReferenceTest.php @@ -41,7 +41,7 @@ public function setUp() */ public function testValidCode($input_code, $symbol, $expected_locations) { - $test_name = $this->getName(); + $test_name = $this->getTestName(); if (strpos($test_name, 'PHP7-') !== false) { if (version_compare(PHP_VERSION, '7.0.0dev', '<')) { $this->markTestSkipped('Test case requires PHP 7.'); diff --git a/tests/TestCase.php b/tests/TestCase.php index 986ec2adc07..16e12dbb698 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -4,6 +4,7 @@ use PHPUnit\Framework\TestCase as BaseTestCase; use Psalm\Checker\FileChecker; use Psalm\Checker\ProjectChecker; +use RuntimeException; class TestCase extends BaseTestCase { @@ -99,4 +100,13 @@ public function analyzeFile($file_path, \Psalm\Context $context) ); $file_checker->analyze($context); } + protected function getTestName(bool $withDataSet = true): string + { + $name = parent::getName($withDataSet); + /** @psalm-suppress DocblockTypeContradiction PHPUnit 7 introduced nullable name */ + if (null === $name) { + throw new RuntimeException('anonymous test - shouldn\'t happen'); + } + return $name; + } } diff --git a/tests/Traits/FileCheckerInvalidCodeParseTestTrait.php b/tests/Traits/FileCheckerInvalidCodeParseTestTrait.php index ffac8a6a30c..77a2634a5d9 100644 --- a/tests/Traits/FileCheckerInvalidCodeParseTestTrait.php +++ b/tests/Traits/FileCheckerInvalidCodeParseTestTrait.php @@ -24,7 +24,7 @@ abstract public function providerFileCheckerInvalidCodeParse(); */ public function testInvalidCode($code, $error_message, $error_levels = [], $strict_mode = false) { - if (strpos($this->getName(), 'SKIPPED-') !== false) { + if (strpos($this->getTestName(), 'SKIPPED-') !== false) { $this->markTestSkipped(); } diff --git a/tests/Traits/FileCheckerValidCodeParseTestTrait.php b/tests/Traits/FileCheckerValidCodeParseTestTrait.php index 0594a51d982..abac5f4d557 100644 --- a/tests/Traits/FileCheckerValidCodeParseTestTrait.php +++ b/tests/Traits/FileCheckerValidCodeParseTestTrait.php @@ -26,7 +26,7 @@ abstract public function providerFileCheckerValidCodeParse(); */ public function testValidCode($code, $assertions = [], $error_levels = [], $scope_vars = []) { - $test_name = $this->getName(); + $test_name = $this->getTestName(); if (strpos($test_name, 'PHP7-') !== false) { if (version_compare(PHP_VERSION, '7.0.0dev', '<')) { $this->markTestSkipped('Test case requires PHP 7.'); diff --git a/tests/UnusedCodeTest.php b/tests/UnusedCodeTest.php index c8b631761f7..627957cc444 100644 --- a/tests/UnusedCodeTest.php +++ b/tests/UnusedCodeTest.php @@ -40,7 +40,7 @@ public function setUp() */ public function testValidCode($code, array $error_levels = []) { - $test_name = $this->getName(); + $test_name = $this->getTestName(); if (strpos($test_name, 'PHP7-') !== false) { if (version_compare(PHP_VERSION, '7.0.0dev', '<')) { $this->markTestSkipped('Test case requires PHP 7.'); @@ -81,7 +81,7 @@ public function testValidCode($code, array $error_levels = []) */ public function testInvalidCode($code, $error_message, $error_levels = []) { - if (strpos($this->getName(), 'SKIPPED-') !== false) { + if (strpos($this->getTestName(), 'SKIPPED-') !== false) { $this->markTestSkipped(); } diff --git a/tests/UnusedVariableTest.php b/tests/UnusedVariableTest.php index 36cd06bd577..fde78c9af85 100644 --- a/tests/UnusedVariableTest.php +++ b/tests/UnusedVariableTest.php @@ -40,7 +40,7 @@ public function setUp() */ public function testValidCode($code, array $error_levels = []) { - $test_name = $this->getName(); + $test_name = $this->getTestName(); if (strpos($test_name, 'PHP7-') !== false) { if (version_compare(PHP_VERSION, '7.0.0dev', '<')) { $this->markTestSkipped('Test case requires PHP 7.'); @@ -81,7 +81,7 @@ public function testValidCode($code, array $error_levels = []) */ public function testInvalidCode($code, $error_message, $error_levels = []) { - if (strpos($this->getName(), 'SKIPPED-') !== false) { + if (strpos($this->getTestName(), 'SKIPPED-') !== false) { $this->markTestSkipped(); }