Skip to content

Commit f270bf7

Browse files
greg0iredbu
authored andcommitted
Use phpunit 7 signatures
1 parent faee7d8 commit f270bf7

File tree

7 files changed

+31
-30
lines changed

7 files changed

+31
-30
lines changed

.travis.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,19 +30,15 @@ env:
3030
global:
3131
- SYMFONY_DEPRECATIONS_HELPER="/.*each.*/"
3232
- SYMFONY_PHPUNIT_DIR=.phpunit SYMFONY_PHPUNIT_REMOVE="symfony/yaml"
33-
- SYMFONY_PHPUNIT_VERSION=5.7
33+
- SYMFONY_PHPUNIT_VERSION=7.3
3434
- TEST_INSTALLATION=false
3535

3636
matrix:
3737
include:
3838
- php: 7.2
3939
env: STABILITY=dev SYMFONY_VERSION=4.0.*
40-
- php: 5.6
40+
- php: 7.1
4141
env: COMPOSER_FLAGS="--prefer-lowest" SYMFONY_VERSION=2.8.* SYMFONY_DEPRECATIONS_HELPER=weak
42-
- php: 7.0
43-
env: STABILITY=dev SYMFONY_VERSION=3.3.*
44-
- php: 7.0
45-
env: STABILITY=dev SYMFONY_VERSION=3.4.*
4642
- php: 7.1
4743
env: STABILITY=dev SYMFONY_VERSION=3.3.*
4844
- php: 7.1

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
}
1010
],
1111
"require": {
12-
"php": "^5.6 || ^7.0",
12+
"php": "^7.1",
1313
"doctrine/common": "^2.7",
1414
"doctrine/data-fixtures": "^1.2",
1515
"doctrine/doctrine-bundle": "^1.8 || ^2.0",

src/Phpunit/DatabaseTestListener.php

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
use PHPUnit\Framework\AssertionFailedError;
1616
use PHPUnit\Framework\Test;
1717
use PHPUnit\Framework\TestListener;
18+
use PHPUnit\Framework\TestSuite;
1819
use PHPUnit\Framework\Warning;
1920
use Symfony\Component\Process\PhpExecutableFinder;
2021
use Symfony\Component\Process\Process;
@@ -56,31 +57,31 @@ public function getProcess($arguments)
5657
return new Process($arguments);
5758
}
5859

59-
public function addError(Test $test, \Exception $e, $time)
60+
public function addError(Test $test, \Throwable $e, float $time): void
6061
{
6162
}
6263

63-
public function addFailure(Test $test, AssertionFailedError $e, $time)
64+
public function addFailure(Test $test, AssertionFailedError $e, float $time): void
6465
{
6566
}
6667

67-
public function addWarning(Test $test, Warning $e, $time)
68+
public function addWarning(Test $test, Warning $e, float $time): void
6869
{
6970
}
7071

71-
public function addIncompleteTest(Test $test, \Exception $e, $time)
72+
public function addIncompleteTest(Test $test, \Throwable $e, float $time): void
7273
{
7374
}
7475

75-
public function addSkippedTest(Test $test, \Exception $e, $time)
76+
public function addSkippedTest(Test $test, \Throwable $e, float $time): void
7677
{
7778
}
7879

79-
public function addRiskyTest(Test $test, \Exception $e, $time)
80+
public function addRiskyTest(Test $test, \Throwable $e, float $time): void
8081
{
8182
}
8283

83-
public function startTest(Test $test)
84+
public function startTest(Test $test): void
8485
{
8586
switch (static::$currentSuite->getName()) {
8687
case 'orm':
@@ -103,11 +104,11 @@ public function startTest(Test $test)
103104
$purger->purge();
104105
}
105106

106-
public function endTest(Test $test, $time)
107+
public function endTest(Test $test, float $time): void
107108
{
108109
}
109110

110-
public function startTestSuite(TestSuite $suite)
111+
public function startTestSuite(TestSuite $suite): void
111112
{
112113
static::$currentSuite = $suite;
113114

@@ -206,7 +207,7 @@ private function setUpOrmDatabase($suite)
206207
echo '[ORM]'.PHP_EOL;
207208
}
208209

209-
public function endTestSuite(TestSuite $suite)
210+
public function endTestSuite(TestSuite $suite): void
210211
{
211212
if (!in_array($suite->getName(), ['phpcr', 'orm'])) {
212213
return;

src/Unit/Constraint/SchemaAcceptsXml.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Symfony\Cmf\Component\Testing\Unit\Constraint;
1313

14-
use PHPUnit\Framework\Constraint;
14+
use PHPUnit\Framework\Constraint\Constraint;
1515

1616
class SchemaAcceptsXml extends Constraint
1717
{
@@ -26,7 +26,7 @@ public function __construct($xml)
2626
$this->xml = $xml;
2727
}
2828

29-
public function matches($schemaFile)
29+
public function matches($schemaFile): bool
3030
{
3131
foreach ($this->xml as $id => $dom) {
3232
$configElement = $dom->getElementsByTagName('config');
@@ -50,24 +50,24 @@ public function matches($schemaFile)
5050
return true;
5151
}
5252

53-
public function count()
53+
public function count(): int
5454
{
5555
return count($this->xml);
5656
}
5757

58-
public function toString()
58+
public function toString(): string
5959
{
6060
}
6161

62-
protected function failureDescription($schemaFile)
62+
protected function failureDescription($schemaFile): string
6363
{
6464
return sprintf(
6565
'Xml is accepted by the XML schema "%s"',
6666
$schemaFile
6767
);
6868
}
6969

70-
protected function additionalFailureDescription($schema)
70+
protected function additionalFailureDescription($schema): string
7171
{
7272
$str = "\n".$this->xml[$this->failingElement]->saveXml()."\n\n";
7373

src/Unit/XmlSchemaTestCase.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
namespace Symfony\Cmf\Component\Testing\Unit;
1313

14-
use PHPUnit\Framework\Constraint;
14+
use PHPUnit\Framework\Constraint\LogicalNot;
1515
use PHPUnit\Framework\TestCase;
1616

1717
abstract class XmlSchemaTestCase extends TestCase
@@ -25,7 +25,7 @@ public static function assertSchemaRefusesXml($xmlDoms, $schemaPath, $message =
2525
{
2626
return self::assertThat(
2727
$schemaPath,
28-
new Constraint\Not(self::getSchemaAcceptsXmlConstraint($xmlDoms)),
28+
new LogicalNot(self::getSchemaAcceptsXmlConstraint($xmlDoms)),
2929
$message
3030
);
3131
}

tests/Functional/BaseTestCaseTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@ public function provideTestDb()
8484
public function testDb($dbName, $expected)
8585
{
8686
if (null === $expected) {
87-
$this->setExpectedException('InvalidArgumentException', $dbName.'" does not exist');
87+
$this->expectException('InvalidArgumentException');
88+
$this->expectExceptionMessage($dbName.'" does not exist');
8889
}
8990

9091
$res = $this->testCase->getDbManager($dbName);

tests/Phpunit/DatabaseTestListenerTest.php

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ protected function setUp()
3333

3434
public function testPhpcrTestSuite()
3535
{
36-
$suite = $this->createMock('TestSuite');
36+
$suite = $this->createMock(TestSuite::class);
3737
$suite->expects($this->any())
3838
->method('getName')
3939
->willReturn('phpcr');
@@ -47,9 +47,12 @@ public function testPhpcrTestSuite()
4747
$this->assertContains('[PHPCR]', ob_get_clean());
4848
}
4949

50+
/**
51+
* @doesNotPerformAssertions
52+
*/
5053
public function testFallsBackToOldInitDbalCommand()
5154
{
52-
$suite = $this->createMock('TestSuite');
55+
$suite = $this->createMock(TestSuite::class);
5356
$suite->expects($this->any())
5457
->method('getName')
5558
->willReturn('phpcr');
@@ -65,7 +68,7 @@ public function testFallsBackToOldInitDbalCommand()
6568

6669
public function testOrmTestSuite()
6770
{
68-
$suite = $this->createMock('TestSuite');
71+
$suite = $this->createMock(TestSuite::class);
6972
$suite->expects($this->any())
7073
->method('getName')
7174
->willReturn('orm');
@@ -83,7 +86,7 @@ public function testOrmTestSuite()
8386
public function testUnknownTestSuite()
8487
{
8588
$this->markTestSkipped('We have to rewrite that test code or delete it.');
86-
$suite = $this->createMock('TestSuite');
89+
$suite = $this->createMock(TestSuite::class);
8790
$suite->expects($this->any())
8891
->method('getName')
8992
->willReturn('not orm or phpcr tests');

0 commit comments

Comments
 (0)