Skip to content

Commit

Permalink
Compatibility with php 5.3
Browse files Browse the repository at this point in the history
  • Loading branch information
petrgrishin committed Feb 18, 2015
1 parent b24deb2 commit 00dd45c
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions tests/unit/PipeTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,18 @@ class PipeTest extends PHPUnit_Framework_TestCase {
public function testPipe() {
$passable = 'test';
$i = 0;
PipeTest__Middleware::$run = function($_passable) use ($passable, &$i) {
$that = $this;
PipeTest__Middleware::$run = function($_passable) use ($passable, $that, &$i) {
$i = $i + 1;
$this->assertEquals($passable, $_passable);
$that->assertEquals($passable, $_passable);
};
$this->assertEquals(0, $i);
Pipe::create($passable)
->through(array('PipeTest__Middleware'))
->then(function ($_passable) use ($passable, &$i) {
->then(function ($_passable) use ($passable, $that, &$i) {
$this->assertEquals(1, $i);
$i = $i + 1;
$this->assertEquals($passable, $_passable);
$that->assertEquals($passable, $_passable);
});
$this->assertEquals(2, $i);
}
Expand All @@ -28,18 +29,19 @@ public function testPipeWithArguments() {
$passable = 'test';
$i = 0;
$argValue = 'argValue';
PipeTest__Middleware::$run = function($_passable, $arg1) use ($passable, $argValue, &$i) {
$that = $this;
PipeTest__Middleware::$run = function($_passable, $arg1) use ($passable, $that, $argValue, &$i) {
$i = $i + 1;
$this->assertEquals($passable, $_passable);
$this->assertEquals($argValue, $arg1);
$that->assertEquals($passable, $_passable);
$that->assertEquals($argValue, $arg1);
};
$this->assertEquals(0, $i);
Pipe::create($passable)
->through(array(array('PipeTest__Middleware', $argValue)))
->then(function ($_passable) use ($passable, &$i) {
$this->assertEquals(1, $i);
->then(function ($_passable) use ($passable, $that, &$i) {
$that->assertEquals(1, $i);
$i = $i + 1;
$this->assertEquals($passable, $_passable);
$that->assertEquals($passable, $_passable);
});
$this->assertEquals(2, $i);
}
Expand Down

0 comments on commit 00dd45c

Please sign in to comment.