Skip to content

Commit ca3a95b

Browse files
committed
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.
1 parent a538e19 commit ca3a95b

12 files changed

Lines changed: 83 additions & 8 deletions

phpunit.xml.dist

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
3+
<phpunit backupGlobals="false"
4+
backupStaticAttributes="false"
5+
colors="true"
6+
convertErrorsToExceptions="true"
7+
convertNoticesToExceptions="true"
8+
convertWarningsToExceptions="true"
9+
processIsolation="false"
10+
stopOnFailure="false"
11+
syntaxCheck="false"
12+
bootstrap="tests/bootstrap.php"
13+
>
14+
<testsuites>
15+
<testsuite name="React Test Suite">
16+
<directory>./tests/</directory>
17+
</testsuite>
18+
</testsuites>
19+
20+
<filter>
21+
<whitelist>
22+
<directory>./src/</directory>
23+
</whitelist>
24+
</filter>
25+
</phpunit>

tests/BufferTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace React\Tests\Stream;
44

55
use React\Stream\Buffer;
6-
use React\Tests\Socket\TestCase;
76

87
class BufferTest extends TestCase
98
{

tests/BufferedSinkTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use React\Stream\BufferedSink;
66
use React\Stream\ReadableStream;
7-
use React\Tests\Socket\TestCase;
87

98
/**
109
* @covers React\Stream\BufferedSink

tests/CallableStub.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace React\Tests\Stream;
4+
5+
class CallableStub
6+
{
7+
public function __invoke()
8+
{
9+
}
10+
}

tests/CompositeStreamTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use React\Stream\CompositeStream;
66
use React\Stream\ReadableStream;
77
use React\Stream\WritableStream;
8-
use React\Tests\Socket\TestCase;
98

109
/**
1110
* @covers React\Stream\CompositeStream

tests/ReadableStreamTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace React\Tests\Stream;
44

55
use React\Stream\ReadableStream;
6-
use React\Tests\Socket\TestCase;
76

87
class ReadableStreamTest extends TestCase
98
{

tests/StreamTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace React\Tests\Stream;
44

55
use React\Stream\Stream;
6-
use React\Tests\Socket\TestCase;
76

87
class StreamTest extends TestCase
98
{

tests/TestCase.php

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
<?php
2+
3+
namespace React\Tests\Stream;
4+
5+
class TestCase extends \PHPUnit_Framework_TestCase
6+
{
7+
protected function expectCallableExactly($amount)
8+
{
9+
$mock = $this->createCallableMock();
10+
$mock
11+
->expects($this->exactly($amount))
12+
->method('__invoke');
13+
14+
return $mock;
15+
}
16+
17+
protected function expectCallableOnce()
18+
{
19+
$mock = $this->createCallableMock();
20+
$mock
21+
->expects($this->once())
22+
->method('__invoke');
23+
24+
return $mock;
25+
}
26+
27+
protected function expectCallableNever()
28+
{
29+
$mock = $this->createCallableMock();
30+
$mock
31+
->expects($this->never())
32+
->method('__invoke');
33+
34+
return $mock;
35+
}
36+
37+
protected function createCallableMock()
38+
{
39+
return $this->getMock('React\Tests\Stream\CallableStub');
40+
}
41+
}

tests/ThroughStreamTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use React\Stream\ReadableStream;
66
use React\Stream\ThroughStream;
7-
use React\Tests\Socket\TestCase;
87

98
/**
109
* @covers React\Stream\ThroughStream

tests/UtilTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use React\Stream\Buffer;
66
use React\Stream\ReadableStream;
77
use React\Stream\Util;
8-
use React\Tests\Socket\TestCase;
98

109
/**
1110
* @covers React\Stream\Util

0 commit comments

Comments
 (0)