Skip to content

Commit 8b65a2c

Browse files
authored
Merge pull request #3 from aik099/separate-abstract-class-declarations
Move out class declarations into separate files
2 parents 5cb2aa3 + 8c1a7e8 commit 8b65a2c

16 files changed

+351
-214
lines changed

src/PHPUnitCompat/AbstractTestCase.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,18 @@ protected function verifyMockeryExpectations()
138138

139139
}
140140

141-
if ( version_compare(\PHPUNIT_COMPAT_RUNNER_VERSION, '6.0.0', '<') ) {
141+
if ( version_compare(\PHPUNIT_COMPAT_RUNNER_VERSION, '5.0.0', '<') ) {
142+
require_once __DIR__ . '/AbstractTestCase4.php';
143+
}
144+
elseif ( version_compare(\PHPUNIT_COMPAT_RUNNER_VERSION, '6.0.0', '<') ) {
142145
require_once __DIR__ . '/AbstractTestCase5.php';
143146
}
144-
else {
147+
elseif ( version_compare(\PHPUNIT_COMPAT_RUNNER_VERSION, '7.0.0', '<') ) {
148+
require_once __DIR__ . '/AbstractTestCase6.php';
149+
}
150+
elseif ( version_compare(\PHPUNIT_COMPAT_RUNNER_VERSION, '8.0.0', '<') ) {
145151
require_once __DIR__ . '/AbstractTestCase7.php';
146152
}
153+
else {
154+
require_once __DIR__ . '/AbstractTestCase8.php';
155+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
/**
3+
* This file is part of the phpunit-mink library.
4+
* For the full copyright and license information, please view
5+
* the LICENSE file that was distributed with this source code.
6+
*
7+
* @copyright Alexander Obuhovich <[email protected]>
8+
* @link https://github.com/aik099/phpunit-mink
9+
*/
10+
11+
namespace ConsoleHelpers\PHPUnitCompat;
12+
13+
14+
use PHPUnit\Framework\TestCase;
15+
16+
/**
17+
* Implementation for PHPUnit 4
18+
*/
19+
abstract class AbstractTestCase extends TestCase
20+
{
21+
22+
use TAbstractTestCaseBody;
23+
24+
/**
25+
* @inheritDoc
26+
*/
27+
protected function onNotSuccessfulTest(\Exception $e)
28+
{
29+
$this->onNotSuccessfulTestCompat($e);
30+
31+
parent::onNotSuccessfulTest($e);
32+
}
33+
34+
}

src/PHPUnitCompat/AbstractTestCase5.php

Lines changed: 11 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -13,47 +13,22 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515

16-
// @codeCoverageIgnoreStart
17-
if ( version_compare(\PHPUNIT_COMPAT_RUNNER_VERSION, '5.0.0', '<') ) {
18-
/**
19-
* Implementation for PHPUnit 4
20-
*/
21-
abstract class AbstractTestCase extends TestCase
22-
{
23-
24-
use TAbstractTestCaseBody;
25-
26-
/**
27-
* @inheritDoc
28-
*/
29-
protected function onNotSuccessfulTest(\Exception $e)
30-
{
31-
$this->onNotSuccessfulTestCompat($e);
16+
/**
17+
* Implementation for PHPUnit 5
18+
*/
19+
abstract class AbstractTestCase extends TestCase
20+
{
3221

33-
parent::onNotSuccessfulTest($e);
34-
}
22+
use TAbstractTestCaseBody;
3523

36-
}
37-
}
38-
elseif ( version_compare(\PHPUNIT_COMPAT_RUNNER_VERSION, '6.0.0', '<') ) {
3924
/**
40-
* Implementation for PHPUnit 5
25+
* @inheritDoc
4126
*/
42-
abstract class AbstractTestCase extends TestCase
27+
protected function onNotSuccessfulTest($e)
4328
{
29+
$this->onNotSuccessfulTestCompat($e);
4430

45-
use TAbstractTestCaseBody;
46-
47-
/**
48-
* @inheritDoc
49-
*/
50-
protected function onNotSuccessfulTest($e)
51-
{
52-
$this->onNotSuccessfulTestCompat($e);
53-
54-
parent::onNotSuccessfulTest($e);
55-
}
56-
31+
parent::onNotSuccessfulTest($e);
5732
}
33+
5834
}
59-
// @codeCoverageIgnoreEnd
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
/**
3+
* This file is part of the phpunit-mink library.
4+
* For the full copyright and license information, please view
5+
* the LICENSE file that was distributed with this source code.
6+
*
7+
* @copyright Alexander Obuhovich <[email protected]>
8+
* @link https://github.com/aik099/phpunit-mink
9+
*/
10+
11+
namespace ConsoleHelpers\PHPUnitCompat;
12+
13+
14+
use PHPUnit\Framework\TestCase;
15+
16+
/**
17+
* Implementation for PHPUnit 6
18+
*/
19+
abstract class AbstractTestCase extends TestCase
20+
{
21+
22+
use TAbstractTestCaseBody;
23+
24+
/**
25+
* @inheritDoc
26+
*/
27+
protected function onNotSuccessfulTest(\Throwable $t)
28+
{
29+
$this->onNotSuccessfulTestCompat($t);
30+
31+
parent::onNotSuccessfulTest($t);
32+
}
33+
34+
}

src/PHPUnitCompat/AbstractTestCase7.php

Lines changed: 10 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -13,66 +13,22 @@
1313

1414
use PHPUnit\Framework\TestCase;
1515

16-
if ( version_compare(\PHPUNIT_COMPAT_RUNNER_VERSION, '7.0.0', '<') ) { // @codeCoverageIgnore
17-
/**
18-
* Implementation for PHPUnit 6
19-
*/
20-
abstract class AbstractTestCase extends TestCase
21-
{
22-
23-
use TAbstractTestCaseBody;
24-
25-
/**
26-
* @inheritDoc
27-
*/
28-
protected function onNotSuccessfulTest(\Throwable $t)
29-
{
30-
$this->onNotSuccessfulTestCompat($t);
16+
/**
17+
* Implementation for PHPUnit 7
18+
*/
19+
abstract class AbstractTestCase extends TestCase
20+
{
3121

32-
parent::onNotSuccessfulTest($t);
33-
}
22+
use TAbstractTestCaseBody;
3423

35-
}
36-
}
37-
elseif ( version_compare(\PHPUNIT_COMPAT_RUNNER_VERSION, '8.0.0', '<') ) {
3824
/**
39-
* Implementation for PHPUnit 7
25+
* @inheritDoc
4026
*/
41-
abstract class AbstractTestCase extends TestCase
27+
protected function onNotSuccessfulTest(\Throwable $t)/* The :void return type declaration that should be here would cause a BC issue */
4228
{
29+
$this->onNotSuccessfulTestCompat($t);
4330

44-
use TAbstractTestCaseBody;
45-
46-
/**
47-
* @inheritDoc
48-
*/
49-
protected function onNotSuccessfulTest(\Throwable $t)/* The :void return type declaration that should be here would cause a BC issue */
50-
{
51-
$this->onNotSuccessfulTestCompat($t);
52-
53-
parent::onNotSuccessfulTest($t);
54-
}
55-
31+
parent::onNotSuccessfulTest($t);
5632
}
57-
}
58-
else {
59-
/**
60-
* Implementation for PHPUnit 8+
61-
*/
62-
abstract class AbstractTestCase extends TestCase
63-
{
64-
65-
use TAbstractTestCaseBody;
66-
67-
/**
68-
* @inheritDoc
69-
*/
70-
protected function onNotSuccessfulTest(\Throwable $t): void
71-
{
72-
$this->onNotSuccessfulTestCompat($t);
7333

74-
parent::onNotSuccessfulTest($t);
75-
}
76-
77-
}
7834
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?php
2+
/**
3+
* This file is part of the phpunit-mink library.
4+
* For the full copyright and license information, please view
5+
* the LICENSE file that was distributed with this source code.
6+
*
7+
* @copyright Alexander Obuhovich <[email protected]>
8+
* @link https://github.com/aik099/phpunit-mink
9+
*/
10+
11+
namespace ConsoleHelpers\PHPUnitCompat;
12+
13+
14+
use PHPUnit\Framework\TestCase;
15+
16+
/**
17+
* Implementation for PHPUnit 8+
18+
*/
19+
abstract class AbstractTestCase extends TestCase
20+
{
21+
22+
use TAbstractTestCaseBody;
23+
24+
/**
25+
* @inheritDoc
26+
*/
27+
protected function onNotSuccessfulTest(\Throwable $t): void
28+
{
29+
$this->onNotSuccessfulTestCompat($t);
30+
31+
parent::onNotSuccessfulTest($t);
32+
}
33+
34+
}

src/PHPUnitCompat/AbstractTestSuite.php

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,18 @@ protected function tearDownCompat()
5050

5151
}
5252

53-
54-
if ( version_compare(\PHPUNIT_COMPAT_RUNNER_VERSION, '6.0.0', '<') ) {
53+
if ( version_compare(\PHPUNIT_COMPAT_RUNNER_VERSION, '5.0.0', '<') ) {
54+
require_once __DIR__ . '/AbstractTestSuite4.php';
55+
}
56+
elseif ( version_compare(\PHPUNIT_COMPAT_RUNNER_VERSION, '6.0.0', '<') ) {
5557
require_once __DIR__ . '/AbstractTestSuite5.php';
5658
}
57-
else {
59+
elseif ( version_compare(\PHPUNIT_COMPAT_RUNNER_VERSION, '7.0.0', '<') ) {
60+
require_once __DIR__ . '/AbstractTestSuite6.php';
61+
}
62+
elseif ( version_compare(\PHPUNIT_COMPAT_RUNNER_VERSION, '8.0.0', '<') ) {
5863
require_once __DIR__ . '/AbstractTestSuite7.php';
5964
}
65+
else {
66+
require_once __DIR__ . '/AbstractTestSuite8.php';
67+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
/**
3+
* This file is part of the phpunit-mink library.
4+
* For the full copyright and license information, please view
5+
* the LICENSE file that was distributed with this source code.
6+
*
7+
* @copyright Alexander Obuhovich <[email protected]>
8+
* @link https://github.com/aik099/phpunit-mink
9+
*/
10+
11+
namespace ConsoleHelpers\PHPUnitCompat;
12+
13+
14+
use PHPUnit\Framework\TestSuite;
15+
16+
/**
17+
* Implementation for PHPUnit 4
18+
*/
19+
abstract class AbstractTestSuite extends TestSuite
20+
{
21+
22+
use TAbstractTestSuiteBody;
23+
24+
/**
25+
* @inheritDoc
26+
*/
27+
public function run(\PHPUnit_Framework_TestResult $result = null)
28+
{
29+
return $this->runCompat($result);
30+
}
31+
32+
/**
33+
* @inheritDoc
34+
*/
35+
protected function tearDown()
36+
{
37+
$this->tearDownCompat();
38+
}
39+
40+
}

src/PHPUnitCompat/AbstractTestSuite5.php

Lines changed: 16 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -13,57 +13,28 @@
1313

1414
use PHPUnit\Framework\TestSuite;
1515

16-
if ( version_compare(\PHPUNIT_COMPAT_RUNNER_VERSION, '5.0.0', '<') ) {
16+
/**
17+
* Implementation for PHPUnit 5
18+
*/
19+
abstract class AbstractTestSuite extends TestSuite
20+
{
21+
22+
use TAbstractTestSuiteBody;
23+
1724
/**
18-
* Implementation for PHPUnit 4
25+
* @inheritDoc
1926
*/
20-
abstract class AbstractTestSuite extends TestSuite
27+
public function run(\PHPUnit_Framework_TestResult $result = null)
2128
{
22-
23-
use TAbstractTestSuiteBody;
24-
25-
/**
26-
* @inheritDoc
27-
*/
28-
public function run(\PHPUnit_Framework_TestResult $result = null)
29-
{
30-
return $this->runCompat($result);
31-
}
32-
33-
/**
34-
* @inheritDoc
35-
*/
36-
protected function tearDown()
37-
{
38-
$this->tearDownCompat();
39-
}
40-
29+
return $this->runCompat($result);
4130
}
42-
}
43-
elseif ( version_compare(\PHPUNIT_COMPAT_RUNNER_VERSION, '6.0.0', '<') ) {
31+
4432
/**
45-
* Implementation for PHPUnit 5
33+
* @inheritDoc
4634
*/
47-
abstract class AbstractTestSuite extends TestSuite
35+
protected function tearDown()
4836
{
49-
50-
use TAbstractTestSuiteBody;
51-
52-
/**
53-
* @inheritDoc
54-
*/
55-
public function run(\PHPUnit_Framework_TestResult $result = null)
56-
{
57-
return $this->runCompat($result);
58-
}
59-
60-
/**
61-
* @inheritDoc
62-
*/
63-
protected function tearDown()
64-
{
65-
$this->tearDownCompat();
66-
}
67-
37+
$this->tearDownCompat();
6838
}
39+
6940
}

0 commit comments

Comments
 (0)