Skip to content

Commit 563cf67

Browse files
committed
Add test namespaces and simplify test bootstrap logic
1 parent 86586b6 commit 563cf67

File tree

5 files changed

+28
-15
lines changed

5 files changed

+28
-15
lines changed

composer.json

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,14 @@
1111
}
1212
],
1313
"autoload": {
14-
"psr-4": {"React\\Datagram\\": "src"}
14+
"psr-4": {
15+
"React\\Datagram\\": "src"
16+
}
17+
},
18+
"autoload-dev": {
19+
"psr-4": {
20+
"React\\Tests\\Datagram\\": "tests"
21+
}
1522
},
1623
"require": {
1724
"php": ">=5.3",

phpunit.xml.dist

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22

3-
<phpunit colors="true" bootstrap="./tests/bootstrap.php">
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+
bootstrap="vendor/autoload.php"
12+
>
413
<testsuites>
514
<testsuite name="Datagram Test Suite">
615
<directory>./tests/</directory>

tests/FactoryTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
namespace React\Tests\Datagram;
4+
35
use React\Datagram\Socket;
46
use React\Datagram\Factory;
57
use Clue\React\Block;
@@ -13,7 +15,7 @@ class FactoryTest extends TestCase
1315

1416
public function setUp()
1517
{
16-
$this->loop = React\EventLoop\Factory::create();
18+
$this->loop = \React\EventLoop\Factory::create();
1719
$this->resolver = $this->createResolverMock();
1820
$this->factory = new Factory($this->loop, $this->resolver);
1921
}

tests/SocketTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<?php
22

3+
namespace React\Tests\Datagram;
4+
35
use React\Datagram\Socket;
46
use Clue\React\Block;
57

@@ -10,8 +12,8 @@ class SocketTest extends TestCase
1012

1113
public function setUp()
1214
{
13-
$this->loop = React\EventLoop\Factory::create();
14-
$this->factory = new React\Datagram\Factory($this->loop, $this->createResolverMock());
15+
$this->loop = \React\EventLoop\Factory::create();
16+
$this->factory = new \React\Datagram\Factory($this->loop, $this->createResolverMock());
1517
}
1618

1719
public function testCreateClientCloseWillNotBlock()
Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?php
22

3-
require __DIR__ . '/../vendor/autoload.php';
3+
namespace React\Tests\Datagram;
44

5-
abstract class TestCase extends PHPUnit_Framework_TestCase
5+
abstract class TestCase extends \PHPUnit_Framework_TestCase
66
{
77
protected function expectCallableOnce()
88
{
@@ -26,18 +26,11 @@ protected function expectCallableNever()
2626

2727
protected function createCallableMock()
2828
{
29-
return $this->getMockBuilder('CallableStub')->getMock();
29+
return $this->getMockBuilder('stdClass')->setMethods(array('__invoke'))->getMock();
3030
}
3131

3232
protected function createResolverMock()
3333
{
3434
return $this->getMockBuilder('React\Dns\Resolver\ResolverInterface')->getMock();
3535
}
3636
}
37-
38-
class CallableStub
39-
{
40-
public function __invoke()
41-
{
42-
}
43-
}

0 commit comments

Comments
 (0)