mirror of
https://github.com/danog/psalm.git
synced 2025-01-21 21:31:13 +01:00
Update PHPUnit (#888)
* upgrade phpunit, test with low and high deps * work around possibly-anonymous test cases introduced by newer PHPUnit * Alternative TestCase::getName() nullability workaround Previous workaround was failing due to PHP warnings on 7.1 or 7.2 (depending on specific signature). There's just no signature that would be working for all 4 variants of (ver / dep) matrix. * don't disable xdebug if it's not enabled * allowed 7.0/high to fail until PHPUnit 6.5.10 is released see sebastianbergmann/phpunit#3209
This commit is contained in:
parent
4172952e8b
commit
c1e21fcf5d
26
.travis.yml
26
.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
|
||||
|
@ -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"
|
||||
|
@ -110,7 +110,7 @@ class DocumentationTest extends TestCase
|
||||
*/
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -33,7 +33,7 @@ class FileManipulationTest extends TestCase
|
||||
*/
|
||||
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.');
|
||||
|
@ -41,7 +41,7 @@ class FileReferenceTest extends TestCase
|
||||
*/
|
||||
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.');
|
||||
|
@ -4,6 +4,7 @@ namespace Psalm\Tests;
|
||||
use PHPUnit\Framework\TestCase as BaseTestCase;
|
||||
use Psalm\Checker\FileChecker;
|
||||
use Psalm\Checker\ProjectChecker;
|
||||
use RuntimeException;
|
||||
|
||||
class TestCase extends BaseTestCase
|
||||
{
|
||||
@ -99,4 +100,13 @@ class TestCase extends BaseTestCase
|
||||
);
|
||||
$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;
|
||||
}
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ trait FileCheckerInvalidCodeParseTestTrait
|
||||
*/
|
||||
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();
|
||||
}
|
||||
|
||||
|
@ -26,7 +26,7 @@ trait FileCheckerValidCodeParseTestTrait
|
||||
*/
|
||||
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.');
|
||||
|
@ -40,7 +40,7 @@ class UnusedCodeTest extends TestCase
|
||||
*/
|
||||
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 @@ class UnusedCodeTest extends TestCase
|
||||
*/
|
||||
public function testInvalidCode($code, $error_message, $error_levels = [])
|
||||
{
|
||||
if (strpos($this->getName(), 'SKIPPED-') !== false) {
|
||||
if (strpos($this->getTestName(), 'SKIPPED-') !== false) {
|
||||
$this->markTestSkipped();
|
||||
}
|
||||
|
||||
|
@ -40,7 +40,7 @@ class UnusedVariableTest extends TestCase
|
||||
*/
|
||||
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 @@ class UnusedVariableTest extends TestCase
|
||||
*/
|
||||
public function testInvalidCode($code, $error_message, $error_levels = [])
|
||||
{
|
||||
if (strpos($this->getName(), 'SKIPPED-') !== false) {
|
||||
if (strpos($this->getTestName(), 'SKIPPED-') !== false) {
|
||||
$this->markTestSkipped();
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user