Skip to content

Commit

Permalink
Add support for PHP 8 + PHPUnit 9 (#295)
Browse files Browse the repository at this point in the history
* Add support for PHP 8 + PHPUnit 9

* Add PHPUnit 4.8 workarounds

* Do --ignore-platform-reqs on PHP 8

* Skip failing test due to missing get_debug_type()
  • Loading branch information
sanmai committed Sep 25, 2020
1 parent 1bd927e commit 32094f4
Show file tree
Hide file tree
Showing 23 changed files with 236 additions and 191 deletions.
2 changes: 2 additions & 0 deletions .php_cs.dist
Expand Up @@ -31,6 +31,8 @@ return PhpCsFixer\Config::create()
'phpdoc_add_missing_param_annotation' => true,
'phpdoc_order' => true,
'phpdoc_types_order' => true,
'php_unit_expectation' => ['target' => '5.2'],
'php_unit_no_expectation_annotation' => true,
'semicolon_after_instruction' => true,
'single_line_throw' => false,
'strict_comparison' => true,
Expand Down
2 changes: 2 additions & 0 deletions .travis.yml
Expand Up @@ -17,6 +17,8 @@ jobs:
env: SYMFONY_VERSION="^5.0" MIN_STABILITY=dev
- php: 7.4
env: CHECKS=yes
- php: nightly
env: 'COMPOSER_FLAGS="--ignore-platform-reqs"'

cache:
directories:
Expand Down
5 changes: 3 additions & 2 deletions composer.json
Expand Up @@ -30,7 +30,7 @@
}
],
"require": {
"php": "^5.5 || ^7.0",
"php": "^5.5 || ^7.0 || ^8.0",
"ext-json": "*",
"ext-simplexml": "*",
"guzzlehttp/guzzle": "^6.0 || ^7.0",
Expand All @@ -41,7 +41,8 @@
"symfony/yaml": "^2.0.5 || ^3.0 || ^4.0 || ^5.0"
},
"require-dev": {
"phpunit/phpunit": "^4.8.35 || ^5.4.3 || ^6.0 || ^7.0"
"phpunit/phpunit": "^4.8.35 || ^5.4.3 || ^6.0 || ^7.0 || ^8.0 || ^9.0",
"sanmai/phpunit-legacy-adapter": "^6.1 || ^8.0"
},
"suggest": {
"symfony/http-kernel": "Allows Symfony integration"
Expand Down
32 changes: 17 additions & 15 deletions tests/Bundle/CoverallsBundle/Api/JobsTest.php
Expand Up @@ -19,19 +19,6 @@
*/
class JobsTest extends ProjectTestCase
{
protected function setUp()
{
$this->setUpDir(realpath(__DIR__ . '/../../..'));
}

protected function tearDown()
{
$this->rmFile($this->jsonPath);
$this->rmFile($this->cloverXmlPath);
$this->rmDir($this->logsDir);
$this->rmDir($this->buildDir);
}

// getJsonFile()

/**
Expand Down Expand Up @@ -457,10 +444,11 @@ public function shouldNotSendJobIfTestEnv()

/**
* @test
* @expectedException \RuntimeException
*/
public function throwRuntimeExceptionIfInvalidEnv()
{
$this->expectException(\RuntimeException::class);

$server = [];

$object = $this->createJobsNeverSend();
Expand All @@ -475,10 +463,11 @@ public function throwRuntimeExceptionIfInvalidEnv()

/**
* @test
* @expectedException \RuntimeException
*/
public function throwRuntimeExceptionIfNoSourceFiles()
{
$this->expectException(\RuntimeException::class);

$server = [];
$server['TRAVIS'] = true;
$server['TRAVIS_BUILD_NUMBER'] = '12345';
Expand All @@ -495,6 +484,19 @@ public function throwRuntimeExceptionIfNoSourceFiles()
->send();
}

protected function legacySetUp()
{
$this->setUpDir(realpath(__DIR__ . '/../../..'));
}

protected function legacyTearDown()
{
$this->rmFile($this->jsonPath);
$this->rmFile($this->cloverXmlPath);
$this->rmDir($this->logsDir);
$this->rmDir($this->buildDir);
}

/**
* @return Jobs
*/
Expand Down
Expand Up @@ -13,11 +13,6 @@
*/
class CiEnvVarsCollectorTest extends ProjectTestCase
{
protected function setUp()
{
$this->setUpDir(realpath(__DIR__ . '/../../..'));
}

// collect()

/**
Expand Down Expand Up @@ -360,6 +355,11 @@ public function shouldHaveReadEnvAfterCollectUnsupportedEnvVars(CiEnvVarsCollect
$this->assertArrayHasKey('COVERALLS_REPO_TOKEN', $readEnv);
}

protected function legacySetUp()
{
$this->setUpDir(realpath(__DIR__ . '/../../..'));
}

/**
* @return Configuration
*/
Expand Down
Expand Up @@ -20,13 +20,6 @@ class CloverXmlCoverageCollectorTest extends ProjectTestCase
*/
private $object;

protected function setUp()
{
$this->setUpDir(realpath(__DIR__ . '/../../..'));

$this->object = new CloverXmlCoverageCollector();
}

// getJsonFile()

/**
Expand Down Expand Up @@ -171,6 +164,13 @@ public function shouldCollectSourceFileTest2UnderRootDir(JsonFile $jsonFile)
$this->assertSourceFileTest2UnderRootDir($sourceFiles[$path2]);
}

protected function legacySetUp()
{
$this->setUpDir(realpath(__DIR__ . '/../../..'));

$this->object = new CloverXmlCoverageCollector();
}

/**
* @return \SimpleXMLElement
*/
Expand Down
13 changes: 8 additions & 5 deletions tests/Bundle/CoverallsBundle/Collector/GitInfoCollectorTest.php
Expand Up @@ -7,14 +7,14 @@
use PhpCoveralls\Bundle\CoverallsBundle\Entity\Git\Git;
use PhpCoveralls\Bundle\CoverallsBundle\Entity\Git\Remote;
use PhpCoveralls\Component\System\Git\GitCommand;
use PHPUnit\Framework\TestCase;
use PhpCoveralls\Tests\ProjectTestCase;

/**
* @covers \PhpCoveralls\Bundle\CoverallsBundle\Collector\GitInfoCollector
*
* @author Kitamura Satoshi <with.no.parachute@gmail.com>
*/
class GitInfoCollectorTest extends TestCase
class GitInfoCollectorTest extends ProjectTestCase
{
/**
* @var array
Expand Down Expand Up @@ -78,10 +78,11 @@ public function shouldCollect()

/**
* @test
* @expectedException \RuntimeException
*/
public function throwRuntimeExceptionIfCurrentBranchNotFound()
{
$this->expectException(\RuntimeException::class);

$getBranchesValue = [
' master',
];
Expand All @@ -96,10 +97,11 @@ public function throwRuntimeExceptionIfCurrentBranchNotFound()

/**
* @test
* @expectedException \RuntimeException
*/
public function throwRuntimeExceptionIfHeadCommitIsInvalid()
{
$this->expectException(\RuntimeException::class);

$getHeadCommitValue = [];
$gitCommand = $this->createGitCommandStubCalledHeadCommit($this->getBranchesValue, $getHeadCommitValue);

Expand All @@ -112,10 +114,11 @@ public function throwRuntimeExceptionIfHeadCommitIsInvalid()

/**
* @test
* @expectedException \RuntimeException
*/
public function throwRuntimeExceptionIfRemoteIsInvalid()
{
$this->expectException(\RuntimeException::class);

$getRemotesValue = [];
$gitCommand = $this->createGitCommandStubWith($this->getBranchesValue, $this->getHeadCommitValue, $getRemotesValue);

Expand Down
32 changes: 17 additions & 15 deletions tests/Bundle/CoverallsBundle/Command/CoverallsJobsCommandTest.php
Expand Up @@ -14,19 +14,6 @@
*/
class CoverallsJobsCommandTest extends ProjectTestCase
{
protected function setUp()
{
$this->setUpDir(realpath(__DIR__ . '/../../..'));
}

protected function tearDown()
{
$this->rmFile($this->cloverXmlPath);
$this->rmFile($this->jsonPath);
$this->rmDir($this->logsDir);
$this->rmDir($this->buildDir);
}

/**
* @test
*/
Expand Down Expand Up @@ -75,10 +62,11 @@ public function shouldExecuteCoverallsJobsCommand()

/**
* @test
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
*/
public function shouldExecuteCoverallsJobsCommandWithWrongRootDir()
{
$this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class);

$this->makeProjectDir(null, $this->logsDir);
$this->dumpCloverXml();

Expand Down Expand Up @@ -142,10 +130,11 @@ public function shouldExecuteCoverallsJobsCommandWithRootDirOverride()

/**
* @test
* @expectedException \Symfony\Component\Config\Definition\Exception\InvalidConfigurationException
*/
public function shouldExecuteCoverallsJobsCommandThrowInvalidConfigurationException()
{
$this->expectException(\Symfony\Component\Config\Definition\Exception\InvalidConfigurationException::class);

$this->makeProjectDir(null, $this->logsDir);
$this->dumpCloverXml();

Expand All @@ -172,6 +161,19 @@ public function shouldExecuteCoverallsJobsCommandThrowInvalidConfigurationExcept
);
}

protected function legacySetUp()
{
$this->setUpDir(realpath(__DIR__ . '/../../..'));
}

protected function legacyTearDown()
{
$this->rmFile($this->cloverXmlPath);
$this->rmFile($this->jsonPath);
$this->rmDir($this->logsDir);
$this->rmDir($this->buildDir);
}

/**
* @return string
*/
Expand Down
14 changes: 7 additions & 7 deletions tests/Bundle/CoverallsBundle/Config/ConfigurationTest.php
Expand Up @@ -3,25 +3,20 @@
namespace PhpCoveralls\Tests\Bundle\CoverallsBundle\Config;

use PhpCoveralls\Bundle\CoverallsBundle\Config\Configuration;
use PHPUnit\Framework\TestCase;
use PhpCoveralls\Tests\ProjectTestCase;

/**
* @covers \PhpCoveralls\Bundle\CoverallsBundle\Config\Configuration
*
* @author Kitamura Satoshi <with.no.parachute@gmail.com>
*/
class ConfigurationTest extends TestCase
class ConfigurationTest extends ProjectTestCase
{
/**
* @var Configuration
*/
private $object;

protected function setUp()
{
$this->object = new Configuration();
}

// hasRepoToken()
// getRepoToken()

Expand Down Expand Up @@ -426,4 +421,9 @@ public function shouldSetEnv()
$this->assertSame($same, $this->object);
$this->assertSame($expected, $this->object->getEnv());
}

protected function legacySetUp()
{
$this->object = new Configuration();
}
}

0 comments on commit 32094f4

Please sign in to comment.