forked from webmozarts/assert
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Fix nightly builds by allowing later phpunit versions
- Loading branch information
1 parent
4950625
commit 255fb9e
Showing
5 changed files
with
49 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,7 +16,6 @@ | |
use Exception; | ||
use Error; | ||
use LogicException; | ||
use PHPUnit_Framework_TestCase; | ||
use RuntimeException; | ||
use stdClass; | ||
use Webmozart\Assert\Assert; | ||
|
@@ -26,7 +25,7 @@ | |
* | ||
* @author Bernhard Schussek <[email protected]> | ||
*/ | ||
class AssertTest extends PHPUnit_Framework_TestCase | ||
class AssertTest extends BaseTestCase | ||
{ | ||
private static $resource; | ||
|
||
|
@@ -359,7 +358,7 @@ public function getTests() | |
// no tests for readable()/writable() for now | ||
array('classExists', array(__CLASS__), true), | ||
array('classExists', array(__NAMESPACE__.'\Foobar'), false), | ||
array('subclassOf', array(__CLASS__, 'PHPUnit_Framework_TestCase'), true), | ||
array('subclassOf', array(__CLASS__, 'Webmozart\Assert\Tests\BaseTestCase'), true), | ||
array('subclassOf', array(__CLASS__, 'stdClass'), false), | ||
array('interfaceExists', array('\Countable'), true), | ||
array('interfaceExists', array(__CLASS__), false), | ||
|
@@ -506,6 +505,7 @@ public function testAssert($method, $args, $success, $multibyte = false, $minVer | |
} | ||
|
||
call_user_func_array(array('Webmozart\Assert\Assert', $method), $args); | ||
$this->addToAssertionCount(1); | ||
} | ||
|
||
/** | ||
|
@@ -527,6 +527,7 @@ public function testNullOr($method, $args, $success, $multibyte = false, $minVer | |
} | ||
|
||
call_user_func_array(array('Webmozart\Assert\Assert', 'nullOr'.ucfirst($method)), $args); | ||
$this->addToAssertionCount(1); | ||
} | ||
|
||
/** | ||
|
@@ -535,6 +536,7 @@ public function testNullOr($method, $args, $success, $multibyte = false, $minVer | |
public function testNullOrAcceptsNull($method) | ||
{ | ||
call_user_func(array('Webmozart\Assert\Assert', 'nullOr'.ucfirst($method)), null); | ||
$this->addToAssertionCount(1); | ||
} | ||
|
||
/** | ||
|
@@ -559,6 +561,7 @@ public function testAllArray($method, $args, $success, $multibyte = false, $minV | |
array_unshift($args, array($arg)); | ||
|
||
call_user_func_array(array('Webmozart\Assert\Assert', 'all'.ucfirst($method)), $args); | ||
$this->addToAssertionCount(1); | ||
} | ||
|
||
/** | ||
|
@@ -583,6 +586,7 @@ public function testAllTraversable($method, $args, $success, $multibyte = false, | |
array_unshift($args, new ArrayIterator(array($arg))); | ||
|
||
call_user_func_array(array('Webmozart\Assert\Assert', 'all'.ucfirst($method)), $args); | ||
$this->addToAssertionCount(1); | ||
} | ||
|
||
public function getStringConversions() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
namespace Webmozart\Assert\Tests; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* This class allows us to be compatible with multiple PHPUnit versions. | ||
*/ | ||
class BaseTestCase extends TestCase | ||
{ | ||
/** | ||
* The setExpectedException got removed in later phpunit versions, | ||
* and instead it got split up into three functions. | ||
* | ||
* So if the newer functions exist we call those where needed, and otherwise | ||
* we just use the original function. | ||
* | ||
* @param string $exceptionName | ||
* @param string $exceptionMessage | ||
* @param int $exceptionCode | ||
*/ | ||
public function setExpectedException($exceptionName, $exceptionMessage = '', $exceptionCode = null) { | ||
if (method_exists($this, 'expectException')) { | ||
$this->expectException($exceptionName); | ||
if($exceptionMessage) { | ||
$this->expectExceptionMessage($exceptionMessage); | ||
} | ||
if( $exceptionCode) { | ||
$this->expectExceptionCode($exceptionCode); | ||
} | ||
return; | ||
} | ||
parent::setExpectedException($exceptionName, $exceptionMessage, $exceptionCode); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters