-
-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make components' tests run on their own and from main repo.
Each component has dedicated test config and bootstrap. Duplication of parts of the skeleton is not ideal, but helps to reduce dependencies between each test suite. Also, this eases the future subtree split.
- Loading branch information
Showing
10 changed files
with
168 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
|
||
<phpunit backupGlobals="false" | ||
backupStaticAttributes="false" | ||
colors="true" | ||
convertErrorsToExceptions="true" | ||
convertNoticesToExceptions="true" | ||
convertWarningsToExceptions="true" | ||
processIsolation="false" | ||
stopOnFailure="false" | ||
syntaxCheck="false" | ||
bootstrap="tests/bootstrap.php" | ||
> | ||
<testsuites> | ||
<testsuite name="React 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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<?php | ||
|
||
namespace React\Tests\Http; | ||
|
||
class CallableStub | ||
{ | ||
public function __invoke() | ||
{ | ||
} | ||
} |
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,63 @@ | ||
<?php | ||
|
||
namespace React\Tests\Http; | ||
|
||
use Evenement\EventEmitter; | ||
use React\Socket\ConnectionInterface; | ||
use React\Stream\WritableStreamInterface; | ||
use React\Stream\Util; | ||
|
||
class ConnectionStub extends EventEmitter implements ConnectionInterface | ||
{ | ||
private $data = ''; | ||
|
||
public function isReadable() | ||
{ | ||
return true; | ||
} | ||
|
||
public function isWritable() | ||
{ | ||
return true; | ||
} | ||
|
||
public function pause() | ||
{ | ||
} | ||
|
||
public function resume() | ||
{ | ||
} | ||
|
||
public function pipe(WritableStreamInterface $dest, array $options = array()) | ||
{ | ||
Util::pipe($this, $dest, $options); | ||
|
||
return $dest; | ||
} | ||
|
||
public function write($data) | ||
{ | ||
$this->data .= $data; | ||
|
||
return true; | ||
} | ||
|
||
public function end($data = null) | ||
{ | ||
} | ||
|
||
public function close() | ||
{ | ||
} | ||
|
||
public function getData() | ||
{ | ||
return $this->data; | ||
} | ||
|
||
public function getRemoteAddress() | ||
{ | ||
return '127.0.0.1'; | ||
} | ||
} |
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
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,22 @@ | ||
<?php | ||
|
||
namespace React\Tests\Http; | ||
|
||
use Evenement\EventEmitter; | ||
use React\Socket\ServerInterface; | ||
|
||
class ServerStub extends EventEmitter implements ServerInterface | ||
{ | ||
public function listen($port, $host = '127.0.0.1') | ||
{ | ||
} | ||
|
||
public function getPort() | ||
{ | ||
return 80; | ||
} | ||
|
||
public function shutdown() | ||
{ | ||
} | ||
} |
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,41 @@ | ||
<?php | ||
|
||
namespace React\Tests\Http; | ||
|
||
class TestCase extends \PHPUnit_Framework_TestCase | ||
{ | ||
protected function expectCallableExactly($amount) | ||
{ | ||
$mock = $this->createCallableMock(); | ||
$mock | ||
->expects($this->exactly($amount)) | ||
->method('__invoke'); | ||
|
||
return $mock; | ||
} | ||
|
||
protected function expectCallableOnce() | ||
{ | ||
$mock = $this->createCallableMock(); | ||
$mock | ||
->expects($this->once()) | ||
->method('__invoke'); | ||
|
||
return $mock; | ||
} | ||
|
||
protected function expectCallableNever() | ||
{ | ||
$mock = $this->createCallableMock(); | ||
$mock | ||
->expects($this->never()) | ||
->method('__invoke'); | ||
|
||
return $mock; | ||
} | ||
|
||
protected function createCallableMock() | ||
{ | ||
return $this->getMock('React\Tests\Http\CallableStub'); | ||
} | ||
} |
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,7 @@ | ||
<?php | ||
|
||
$loader = @include __DIR__ . '/../vendor/autoload.php'; | ||
if (!$loader) { | ||
$loader = require __DIR__ . '/../../../vendor/autoload.php'; | ||
} | ||
$loader->addPsr4('React\\Tests\\Http\\', __DIR__); |