-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
57908af
commit 30238ff
Showing
8 changed files
with
94 additions
and
142 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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<!-- phpunit.xml configuration file for PHPUnit Versions older than 9.3 --> | ||
<phpunit bootstrap="vendor/autoload.php" colors="true"> | ||
<testsuites> | ||
<testsuite name="Flux test suite"> | ||
<directory>./tests/</directory> | ||
</testsuite> | ||
</testsuites> | ||
<filter> | ||
<whitelist> | ||
<directory>./src/</directory> | ||
</whitelist> | ||
</filter> | ||
</phpunit> |
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 |
---|---|---|
@@ -1,14 +1,15 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<phpunit bootstrap="vendor/autoload.php" colors="true"> | ||
<testsuites> | ||
<testsuite name="Flux test suite"> | ||
<directory>./tests/</directory> | ||
</testsuite> | ||
</testsuites> | ||
<filter> | ||
<whitelist> | ||
<directory>./src/</directory> | ||
</whitelist> | ||
</filter> | ||
<!-- phpunit.xml configuration file with new format for PHPUnit 9.3+ --> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" bootstrap="vendor/autoload.php" colors="true" cacheResult="false" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"> | ||
<coverage> | ||
<include> | ||
<directory>./src/</directory> | ||
</include> | ||
</coverage> | ||
<testsuites> | ||
<testsuite name="Flux test suite"> | ||
<directory>./tests/</directory> | ||
</testsuite> | ||
</testsuites> | ||
</phpunit> |
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,60 @@ | ||
<?php | ||
|
||
namespace Clue\Tests\React\Flux; | ||
|
||
use PHPUnit\Framework\TestCase as BaseTestCase; | ||
|
||
class TestCase extends BaseTestCase | ||
{ | ||
protected function expectCallableOnce() | ||
{ | ||
$mock = $this->createCallableMock(); | ||
$mock->expects($this->once())->method('__invoke'); | ||
|
||
return $mock; | ||
} | ||
|
||
protected function expectCallableOnceWith($param) | ||
{ | ||
$mock = $this->createCallableMock(); | ||
$mock->expects($this->once()) ->method('__invoke')->with($param); | ||
|
||
return $mock; | ||
} | ||
|
||
protected function expectCallableNever() | ||
{ | ||
$mock = $this->createCallableMock(); | ||
$mock->expects($this->never())->method('__invoke'); | ||
|
||
return $mock; | ||
} | ||
|
||
protected function createCallableMock() | ||
{ | ||
if (method_exists('PHPUnit\Framework\MockObject\MockBuilder', 'addMethods')) { | ||
// PHPUnit 9+ | ||
return $this->getMockBuilder('stdClass')->addMethods(array('__invoke'))->getMock(); | ||
} else { | ||
// legacy PHPUnit 4 - PHPUnit 8 | ||
return $this->getMockBuilder('stdClass')->setMethods(array('__invoke'))->getMock(); | ||
} | ||
} | ||
|
||
public function setExpectedException($exception, $exceptionMessage = '', $exceptionCode = null) | ||
{ | ||
if (method_exists($this, 'expectException')) { | ||
// PHPUnit 6+ | ||
$this->expectException($exception); | ||
if ($exceptionMessage !== '') { | ||
$this->expectExceptionMessage($exceptionMessage); | ||
} | ||
if ($exceptionCode !== null) { | ||
$this->expectExceptionCode($exceptionCode); | ||
} | ||
} else { | ||
// legacy PHPUnit 4 - PHPUnit 5 | ||
parent::setExpectedException($exception, $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
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