Skip to content

Commit faee7d8

Browse files
greg0iredbu
authored andcommitted
Use namespaced versions of phpunit classes
Hopefully this should make this package compatible with phpunit 7
1 parent f729513 commit faee7d8

File tree

7 files changed

+36
-22
lines changed

7 files changed

+36
-22
lines changed

src/Phpunit/DatabaseTestListener.php

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,15 @@
1212
namespace Symfony\Cmf\Component\Testing\Phpunit;
1313

1414
use Doctrine\Common\DataFixtures\Purger;
15+
use PHPUnit\Framework\AssertionFailedError;
16+
use PHPUnit\Framework\Test;
17+
use PHPUnit\Framework\TestListener;
18+
use PHPUnit\Framework\Warning;
1519
use Symfony\Component\Process\PhpExecutableFinder;
1620
use Symfony\Component\Process\Process;
1721
use Symfony\Component\Process\ProcessUtils;
1822

19-
class DatabaseTestListener implements \PHPUnit_Framework_TestListener
23+
class DatabaseTestListener implements TestListener
2024
{
2125
protected static $currentSuite;
2226

@@ -52,31 +56,31 @@ public function getProcess($arguments)
5256
return new Process($arguments);
5357
}
5458

55-
public function addError(\PHPUnit_Framework_Test $test, \Exception $e, $time)
59+
public function addError(Test $test, \Exception $e, $time)
5660
{
5761
}
5862

59-
public function addFailure(\PHPUnit_Framework_Test $test, \PHPUnit_Framework_AssertionFailedError $e, $time)
63+
public function addFailure(Test $test, AssertionFailedError $e, $time)
6064
{
6165
}
6266

63-
public function addWarning(\PHPUnit_Framework_Test $test, \PHPUnit_Framework_Warning $e, $time)
67+
public function addWarning(Test $test, Warning $e, $time)
6468
{
6569
}
6670

67-
public function addIncompleteTest(\PHPUnit_Framework_Test $test, \Exception $e, $time)
71+
public function addIncompleteTest(Test $test, \Exception $e, $time)
6872
{
6973
}
7074

71-
public function addSkippedTest(\PHPUnit_Framework_Test $test, \Exception $e, $time)
75+
public function addSkippedTest(Test $test, \Exception $e, $time)
7276
{
7377
}
7478

75-
public function addRiskyTest(\PHPUnit_Framework_Test $test, \Exception $e, $time)
79+
public function addRiskyTest(Test $test, \Exception $e, $time)
7680
{
7781
}
7882

79-
public function startTest(\PHPUnit_Framework_Test $test)
83+
public function startTest(Test $test)
8084
{
8185
switch (static::$currentSuite->getName()) {
8286
case 'orm':
@@ -99,11 +103,11 @@ public function startTest(\PHPUnit_Framework_Test $test)
99103
$purger->purge();
100104
}
101105

102-
public function endTest(\PHPUnit_Framework_Test $test, $time)
106+
public function endTest(Test $test, $time)
103107
{
104108
}
105109

106-
public function startTestSuite(\PHPUnit_Framework_TestSuite $suite)
110+
public function startTestSuite(TestSuite $suite)
107111
{
108112
static::$currentSuite = $suite;
109113

@@ -202,7 +206,7 @@ private function setUpOrmDatabase($suite)
202206
echo '[ORM]'.PHP_EOL;
203207
}
204208

205-
public function endTestSuite(\PHPUnit_Framework_TestSuite $suite)
209+
public function endTestSuite(TestSuite $suite)
206210
{
207211
if (!in_array($suite->getName(), ['phpcr', 'orm'])) {
208212
return;

src/Unit/Constraint/SchemaAcceptsXml.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,9 @@
1111

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

14-
class SchemaAcceptsXml extends \PHPUnit_Framework_Constraint
14+
use PHPUnit\Framework\Constraint;
15+
16+
class SchemaAcceptsXml extends Constraint
1517
{
1618
protected $xml;
1719

src/Unit/XmlSchemaTestCase.php

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

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

14-
abstract class XmlSchemaTestCase extends \PHPUnit_Framework_TestCase
14+
use PHPUnit\Framework\Constraint;
15+
use PHPUnit\Framework\TestCase;
16+
17+
abstract class XmlSchemaTestCase extends TestCase
1518
{
1619
public static function assertSchemaAcceptsXml($xmlDoms, $schemaPath, $message = '')
1720
{
@@ -22,7 +25,7 @@ public static function assertSchemaRefusesXml($xmlDoms, $schemaPath, $message =
2225
{
2326
return self::assertThat(
2427
$schemaPath,
25-
new \PHPUnit_Framework_Constraint_Not(self::getSchemaAcceptsXmlConstraint($xmlDoms)),
28+
new Constraint\Not(self::getSchemaAcceptsXmlConstraint($xmlDoms)),
2629
$message
2730
);
2831
}

tests/Functional/BaseTestCaseTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,14 @@
1212
namespace Symfony\Cmf\Component\Testing\Tests\Functional;
1313

1414
use Doctrine\Bundle\PHPCRBundle\Test\RepositoryManager;
15+
use PHPUnit\Framework\TestCase;
1516
use Symfony\Bundle\FrameworkBundle\Client;
1617
use Symfony\Cmf\Component\Testing\Functional\DbManager\PHPCR;
1718
use Symfony\Cmf\Component\Testing\Tests\Fixtures\TestTestCase;
1819
use Symfony\Component\DependencyInjection\ContainerInterface;
1920
use Symfony\Component\HttpKernel\KernelInterface;
2021

21-
class BaseTestCaseTest extends \PHPUnit_Framework_TestCase
22+
class BaseTestCaseTest extends TestCase
2223
{
2324
private $container;
2425

tests/HttpKernel/TestKernelTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@
1313

1414
use Doctrine\Bundle\DoctrineBundle\DoctrineBundle;
1515
use Doctrine\Bundle\PHPCRBundle\DoctrinePHPCRBundle;
16+
use PHPUnit\Framework\TestCase;
1617
use Symfony\Bundle\FrameworkBundle\FrameworkBundle;
1718
use Symfony\Bundle\SecurityBundle\SecurityBundle;
1819
use Symfony\Bundle\TwigBundle\TwigBundle;
1920
use Symfony\Component\HttpKernel\Kernel;
2021

21-
class TestKernelTest extends \PHPUnit_Framework_TestCase
22+
class TestKernelTest extends TestCase
2223
{
2324
/**
2425
* @var Kernel

tests/Phpunit/DatabaseTestListenerTest.php

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

1212
namespace Symfony\Cmf\Component\Testing\Tests\Phpunit;
1313

14+
use PHPUnit\Framework\TestCase;
15+
use PHPUnit\Framework\TestSuite;
1416
use Symfony\Cmf\Component\Testing\Phpunit\DatabaseTestListener;
1517

16-
class DatabaseTestListenerTest extends \PHPUnit_Framework_TestCase
18+
class DatabaseTestListenerTest extends TestCase
1719
{
1820
protected $listener;
1921

@@ -31,7 +33,7 @@ protected function setUp()
3133

3234
public function testPhpcrTestSuite()
3335
{
34-
$suite = $this->createMock('PHPUnit_Framework_TestSuite');
36+
$suite = $this->createMock('TestSuite');
3537
$suite->expects($this->any())
3638
->method('getName')
3739
->willReturn('phpcr');
@@ -47,7 +49,7 @@ public function testPhpcrTestSuite()
4749

4850
public function testFallsBackToOldInitDbalCommand()
4951
{
50-
$suite = $this->createMock('PHPUnit_Framework_TestSuite');
52+
$suite = $this->createMock('TestSuite');
5153
$suite->expects($this->any())
5254
->method('getName')
5355
->willReturn('phpcr');
@@ -63,7 +65,7 @@ public function testFallsBackToOldInitDbalCommand()
6365

6466
public function testOrmTestSuite()
6567
{
66-
$suite = $this->createMock('PHPUnit_Framework_TestSuite');
68+
$suite = $this->createMock('TestSuite');
6769
$suite->expects($this->any())
6870
->method('getName')
6971
->willReturn('orm');
@@ -81,7 +83,7 @@ public function testOrmTestSuite()
8183
public function testUnknownTestSuite()
8284
{
8385
$this->markTestSkipped('We have to rewrite that test code or delete it.');
84-
$suite = $this->createMock('PHPUnit_Framework_TestSuite');
86+
$suite = $this->createMock('TestSuite');
8587
$suite->expects($this->any())
8688
->method('getName')
8789
->willReturn('not orm or phpcr tests');

tests/Unit/Constraint/SchemaAcceptsXmlTest.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@
1111

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

14+
use PHPUnit\Framework\TestCase;
1415
use Symfony\Cmf\Component\Testing\Unit\Constraint\SchemaAcceptsXml;
1516

16-
class SchemaAcceptsXmlTest extends \PHPUnit_Framework_TestCase
17+
class SchemaAcceptsXmlTest extends TestCase
1718
{
1819
public function testCount()
1920
{

0 commit comments

Comments
 (0)