Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update PHPUnit #888

Merged
merged 5 commits into from Jul 13, 2018
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
26 changes: 21 additions & 5 deletions .travis.yml
@@ -1,28 +1,44 @@
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:
- ./vendor

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
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion tests/DocumentationTest.php
Expand Up @@ -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();
}

Expand Down
2 changes: 1 addition & 1 deletion tests/FileManipulationTest.php
Expand Up @@ -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.');
Expand Down
2 changes: 1 addition & 1 deletion tests/FileReferenceTest.php
Expand Up @@ -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.');
Expand Down
10 changes: 10 additions & 0 deletions tests/TestCase.php
Expand Up @@ -4,6 +4,7 @@
use PHPUnit\Framework\TestCase as BaseTestCase;
use Psalm\Checker\FileChecker;
use Psalm\Checker\ProjectChecker;
use RuntimeException;

class TestCase extends BaseTestCase
{
Expand Down Expand Up @@ -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;
}
}
2 changes: 1 addition & 1 deletion tests/Traits/FileCheckerInvalidCodeParseTestTrait.php
Expand Up @@ -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();
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Traits/FileCheckerValidCodeParseTestTrait.php
Expand Up @@ -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.');
Expand Down
4 changes: 2 additions & 2 deletions tests/UnusedCodeTest.php
Expand Up @@ -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.');
Expand Down Expand Up @@ -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();
}

Expand Down
4 changes: 2 additions & 2 deletions tests/UnusedVariableTest.php
Expand Up @@ -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.');
Expand Down Expand Up @@ -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();
}

Expand Down