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

Add support for PHP 8 + PHPUnit 9 #295

Merged
merged 4 commits into from
Sep 25, 2020
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
2 changes: 2 additions & 0 deletions .php_cs.dist
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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"'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

open question: what is failing without it ?

Copy link
Contributor Author

@sanmai sanmai Sep 25, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

phpunit/phpunit 9.3.9 requires phpspec/prophecy, but it is not installable on PHP 8.

Here's a relevant discussion with the man himself: phpspec/prophecy#491 (comment)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ack. thanks.


cache:
directories:
Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
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"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i do understand the need and the approach.
I'm still crying internally.

This comment was marked as resolved.

This comment was marked as resolved.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no worry, all good

},
"suggest": {
"symfony/http-kernel": "Allows Symfony integration"
Expand Down
32 changes: 17 additions & 15 deletions tests/Bundle/CoverallsBundle/Api/JobsTest.php
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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();
}
}