Skip to content

Commit cd33ad2

Browse files
authored
Merge pull request #3 from legionth/update-unittests
Use Mockbuilder instead of getMock for PHPUnit tests
2 parents 6a33347 + 7e99672 commit cd33ad2

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

tests/LineReaderTest.php

+11-11
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class LineReaderTest extends TestCase
77
public function setUp()
88
{
99
$this->lineReader = new LineReader();
10-
10+
1111
$this->input = new ReadableStream();
1212
$this->input->pipe($this->lineReader);
1313
}
@@ -23,7 +23,7 @@ public function testMethodIsCalled()
2323
public function testSeperatedData()
2424
{
2525
$this->lineReader->on('data', $this->expectCallableOnceWith('helloworld' . PHP_EOL));
26-
26+
2727
$this->input->emit('data', array(
2828
'hello'
2929
));
@@ -35,7 +35,7 @@ public function testSeperatedData()
3535
public function testWithLineBreak()
3636
{
3737
$this->lineReader->on('data', $this->expectCallableOnceWith('hello' . PHP_EOL));
38-
38+
3939
$this->input->emit('data', array(
4040
'hello' . PHP_EOL . 'world'
4141
));
@@ -48,7 +48,7 @@ public function testDoubleLineBreak()
4848
'world' . PHP_EOL
4949
);
5050
$this->lineReader->on('data', $this->expectCallableConsecutive(2, $expectedValues));
51-
51+
5252
$this->input->emit('data', array(
5353
'hello' . PHP_EOL . 'world' . PHP_EOL
5454
));
@@ -69,10 +69,10 @@ public function testResumeStream()
6969

7070
public function testPipeStream()
7171
{
72-
$dest = $this->getMock('React\Stream\WritableStreamInterface');
73-
72+
$dest = $this->getMockBuilder('React\Stream\WritableStreamInterface')->getMock();
73+
7474
$ret = $this->lineReader->pipe($dest);
75-
75+
7676
$this->assertSame($dest, $ret);
7777
}
7878

@@ -92,15 +92,15 @@ public function testIsReadable()
9292
{
9393
$lineReader = new LineReader();
9494
$actual = $lineReader->isReadable();
95-
95+
9696
$this->assertTrue($actual);
9797
}
9898

9999
public function testIsWritable()
100100
{
101101
$lineReader = new LineReader();
102102
$actual = $lineReader->isWritable();
103-
103+
104104
$this->assertTrue($actual);
105105
}
106106

@@ -114,13 +114,13 @@ public function testStreamIsAlreadyClosed()
114114
private function expectCallableConsecutive($numberOfCalls, array $with)
115115
{
116116
$mock = $this->createCallableMock();
117-
117+
118118
for ($i = 0; $i < $numberOfCalls; $i ++) {
119119
$mock->expects($this->at($i))
120120
->method('__invoke')
121121
->with($this->equalTo($with[$i]));
122122
}
123-
123+
124124
return $mock;
125125
}
126126
}

tests/bootstrap.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ protected function expectCallableOnceParameter($type)
5353
*/
5454
protected function createCallableMock()
5555
{
56-
return $this->getMock('CallableStub');
56+
return $this->getMockBuilder('CallableStub')->getMock();
5757
}
5858
}
5959

0 commit comments

Comments
 (0)