Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Removed some unused code Misc cleanup
- Loading branch information
Showing
14 changed files
with
597 additions
and
45 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
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
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,76 @@ | ||
<?php | ||
|
||
|
||
namespace Rx\Disposable; | ||
|
||
use Rx\TestCase; | ||
|
||
class BinaryDisposableTest extends TestCase | ||
{ | ||
/** | ||
* @test | ||
*/ | ||
public function it_disposes_the_binary_disposable() | ||
{ | ||
$disposed1 = false; | ||
|
||
$d1 = new CallbackDisposable(function () use (&$disposed1) { | ||
$disposed1 = true; | ||
}); | ||
|
||
$disposed2 = false; | ||
|
||
$d2 = new CallbackDisposable(function () use (&$disposed2) { | ||
$disposed2 = true; | ||
}); | ||
|
||
$disposable = new BinaryDisposable($d1, $d2); | ||
|
||
$this->assertFalse($disposed1); | ||
$this->assertFalse($disposed2); | ||
|
||
$disposable->dispose(); | ||
|
||
$this->assertTrue($disposed1); | ||
$this->assertTrue($disposed2); | ||
|
||
$this->assertTrue($disposable->isDisposed()); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function it_does_nothing_if_disposed_twice() | ||
{ | ||
$disposed1 = 0; | ||
|
||
$d1 = new CallbackDisposable(function () use (&$disposed1) { | ||
$disposed1++; | ||
}); | ||
|
||
$disposed2 = 0; | ||
|
||
$d2 = new CallbackDisposable(function () use (&$disposed2) { | ||
$disposed2++; | ||
}); | ||
|
||
$disposable = new BinaryDisposable($d1, $d2); | ||
|
||
$this->assertEquals(0, $disposed1); | ||
$this->assertEquals(0, $disposed2); | ||
|
||
$disposable->dispose(); | ||
|
||
$this->assertEquals(1, $disposed1); | ||
$this->assertEquals(1, $disposed2); | ||
|
||
$this->assertTrue($disposable->isDisposed()); | ||
|
||
$disposable->dispose(); | ||
|
||
$this->assertEquals(1, $disposed1); | ||
$this->assertEquals(1, $disposed2); | ||
|
||
$this->assertTrue($disposable->isDisposed()); | ||
} | ||
} |
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,68 @@ | ||
<?php | ||
|
||
|
||
namespace Rx\Disposable; | ||
|
||
use Rx\TestCase; | ||
use Rx\Testing\TestScheduler; | ||
|
||
class ScheduledDisposableTest extends TestCase | ||
{ | ||
/** | ||
* @test | ||
*/ | ||
public function it_disposes_the_scheduled_disposable() | ||
{ | ||
$disposed1 = false; | ||
|
||
$d1 = new CallbackDisposable(function () use (&$disposed1) { | ||
$disposed1 = true; | ||
}); | ||
|
||
$scheduler = new TestScheduler(); | ||
|
||
$disposable = new ScheduledDisposable($scheduler, $d1); | ||
|
||
$this->assertFalse($disposed1); | ||
|
||
$disposable->dispose(); | ||
|
||
$this->assertFalse($disposed1); | ||
|
||
$scheduler->start(); | ||
|
||
$this->assertTrue($disposed1); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function it_does_nothing_if_disposed_twice() | ||
{ | ||
$disposed1 = 0; | ||
|
||
$d1 = new CallbackDisposable(function () use (&$disposed1) { | ||
$disposed1++; | ||
}); | ||
|
||
$scheduler = new TestScheduler(); | ||
|
||
$disposable = new ScheduledDisposable($scheduler, $d1); | ||
|
||
$this->assertEquals(0, $disposed1); | ||
|
||
$disposable->dispose(); | ||
|
||
$this->assertEquals(0, $disposed1); | ||
|
||
$scheduler->start(); | ||
|
||
$this->assertEquals(1, $disposed1); | ||
|
||
$disposable->dispose(); | ||
|
||
$this->assertEquals(1, $disposed1); | ||
|
||
$scheduler->start(); | ||
} | ||
} |
Oops, something went wrong.