Skip to content

Commit

Permalink
💚 roolback test
Browse files Browse the repository at this point in the history
  • Loading branch information
matyo91 committed Apr 19, 2021
1 parent 4c2aaf6 commit ed42e05
Showing 1 changed file with 9 additions and 41 deletions.
50 changes: 9 additions & 41 deletions tests/EventLoopTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,18 @@

namespace M6WebTest\Tornado;

use M6Web\Tornado\Adapter\Common\Internal\FailingPromiseCollection;
use M6Web\Tornado\Adapter\Swoole\Internal\PromiseWrapper;
use M6Web\Tornado\Adapter\Swoole\Internal\SwoolePromise;
use M6Web\Tornado\Deferred;
use M6Web\Tornado\EventLoop;
use M6Web\Tornado\Promise;
use PHPUnit\Framework\TestCase;
use Swoole\Atomic;
use Swoole\Coroutine;
use Swoole\Event;

abstract class EventLoopTest extends TestCase
{
use EventLoopTest\AsyncTest;
//use EventLoopTest\StreamsTest;
//use EventLoopTest\PromiseAllTest;
//use EventLoopTest\PromiseForeachTest;
//use EventLoopTest\PromiseRaceTest;
use EventLoopTest\StreamsTest;
use EventLoopTest\PromiseAllTest;
use EventLoopTest\PromiseForeachTest;
use EventLoopTest\PromiseRaceTest;

abstract protected function createEventLoop(): EventLoop;

Expand Down Expand Up @@ -52,7 +46,7 @@ public function testIdle($expectedSequence = 'ABCABA')
{
$eventLoop = $this->createEventLoop();
$outputBuffer = '';
/*$createIdleGenerator = function (string $id, int $count) use ($eventLoop, &$outputBuffer): \Generator {
$createIdleGenerator = function (string $id, int $count) use ($eventLoop, &$outputBuffer): \Generator {
while ($count--) {
yield $eventLoop->idle();
$outputBuffer .= $id;
Expand All @@ -63,41 +57,15 @@ public function testIdle($expectedSequence = 'ABCABA')
$eventLoop->async($createIdleGenerator('A', 3)),
$eventLoop->async($createIdleGenerator('B', 2)),
$eventLoop->async($createIdleGenerator('C', 1))
);*/

Coroutine::create(function() use (&$outputBuffer) {
$outputBuffer .= "A"; print_r($outputBuffer."\n");
Coroutine::sleep(0.001);
$outputBuffer .= "A"; print_r($outputBuffer."\n");
Coroutine::sleep(0.001);
$outputBuffer .= "A"; print_r($outputBuffer."\n");
Coroutine::sleep(0.001);
});
Coroutine::create(function() use (&$outputBuffer) {
$outputBuffer .= "B"; print_r($outputBuffer."\n");
Coroutine::sleep(0.001);
$outputBuffer .= "B"; print_r($outputBuffer."\n");
Coroutine::sleep(0.001);
});
Coroutine::create(function() use (&$outputBuffer) {
$outputBuffer .= "C"; print_r($outputBuffer."\n");
Coroutine::sleep(0.001);
});
Event::wait();
/*while ($i !== 5) {
// @codeCoverageIgnoreStart
usleep(SwoolePromise::PROMISE_WAIT);
// @codeCoverageIgnoreEnd
}*/

//$eventLoop->wait($promise);
//$this->assertSame([null, null, null], $eventLoop->wait($promise));
);

$this->assertSame([null, null, null], $eventLoop->wait($promise));
$this->assertSame($expectedSequence, $outputBuffer);
}

public function testDelay()
{
$expectedDelay = 42;
$expectedDelay = 42; // ms
$eventLoop = $this->createEventLoop();

$promise = $eventLoop->delay($expectedDelay);
Expand Down

0 comments on commit ed42e05

Please sign in to comment.