Skip to content

Commit

Permalink
Merge pull request #21 from clue-labs/tests
Browse files Browse the repository at this point in the history
Use PSR-4 autoloader and proper namespace for tests
  • Loading branch information
clue authored Dec 27, 2016
2 parents 6a46050 + 768cd2c commit 65a899f
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 14 deletions.
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
"psr-4": { "React\\Promise\\Timer\\": "src/" },
"files": [ "src/functions.php" ]
},
"autoload-dev": {
"psr-4": { "React\\Tests\\Promise\\Timer\\": "tests/" }
},
"require": {
"php": ">=5.3",
"react/event-loop": "~0.4.0|~0.3.0",
Expand Down
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>

<phpunit bootstrap="tests/bootstrap.php"
<phpunit bootstrap="vendor/autoload.php"
colors="true"
convertErrorsToExceptions="true"
convertNoticesToExceptions="true"
Expand Down
10 changes: 10 additions & 0 deletions tests/CallableStub.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?php

namespace React\Tests\Promise\Timer;

class CallableStub
{
public function __invoke()
{
}
}
3 changes: 2 additions & 1 deletion tests/FunctionRejectTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?php

namespace React\Tests\Promise\Timer;

use React\Promise\Timer;
use React\Promise\CancellablePromiseInterface;

class FunctionRejectTest extends TestCase
{
Expand Down
3 changes: 2 additions & 1 deletion tests/FunctionResolveTest.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?php

namespace React\Tests\Promise\Timer;

use React\Promise\Timer;
use React\Promise\CancellablePromiseInterface;

class FunctionResolveTest extends TestCase
{
Expand Down
2 changes: 2 additions & 0 deletions tests/FunctionTimeoutTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

namespace React\Tests\Promise\Timer;

use React\Promise\Timer;
use React\Promise;

Expand Down
15 changes: 4 additions & 11 deletions tests/bootstrap.php → tests/TestCase.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
<?php

use React\EventLoop\Factory;
namespace React\Tests\Promise\Timer;

require __DIR__ . '/../vendor/autoload.php';
use React\EventLoop\Factory;
use PHPUnit_Framework_TestCase;

class TestCase extends PHPUnit_Framework_TestCase
{
Expand Down Expand Up @@ -40,10 +41,9 @@ protected function expectCallableNever()
*/
protected function createCallableMock()
{
return $this->getMock('CallableStub');
return $this->getMock('React\Tests\Promise\Timer\CallableStub');
}


protected function expectPromiseRejected($promise)
{
return $promise->then($this->expectCallableNever(), $this->expectCallableOnce());
Expand All @@ -59,10 +59,3 @@ protected function expectPromisePending($promise)
return $promise->then($this->expectCallableNever(), $this->expectCallableNever());
}
}

class CallableStub
{
public function __invoke()
{
}
}
2 changes: 2 additions & 0 deletions tests/TimeoutExceptionTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

namespace React\Tests\Promise\Timer;

use React\Promise\Timer\TimeoutException;

class TimeoutExceptionTest extends TestCase
Expand Down

0 comments on commit 65a899f

Please sign in to comment.