Skip to content

Commit 2010a9b

Browse files
committed
Use createMock instead of getMock to mock an object
And drop old PHP versions that don't support the new mock method
1 parent 3b11da7 commit 2010a9b

15 files changed

+76
-78
lines changed

.travis.yml

-2
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,6 @@ cache:
55
- $HOME/.composer/cache/files
66

77
php:
8-
- 5.4
9-
- 5.5
108
- 5.6
119
- 7.0
1210
- 7.1

composer.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
}
1111
],
1212
"require": {
13-
"php": ">=5.4.0",
13+
"php": ">=5.6.0",
1414
"evenement/evenement": "^3.0 || ^2.0",
1515
"react/event-loop": "^1.0 || ^0.5 || ^0.4",
1616
"react/promise": "~2.2",
@@ -20,7 +20,7 @@
2020
},
2121
"require-dev": {
2222
"clue/block-react": "^1.1",
23-
"phpunit/phpunit": "^7.0 || ^6.0 || ^5.0 || ^4.8"
23+
"phpunit/phpunit": "^7.0 || ^6.0 || ^5.0"
2424
},
2525
"suggest": {
2626
"ext-eio": "^1.2"
@@ -39,7 +39,7 @@
3939
"config": {
4040
"sort-packages": true,
4141
"platform": {
42-
"php": "5.4"
42+
"php": "5.6"
4343
}
4444
}
4545
}

tests/ChildProcess/AdapterTest.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ public function testInterface()
2222
{
2323
$this->assertInstanceOf(
2424
'React\Filesystem\AdapterInterface',
25-
new Adapter($this->getMock('React\EventLoop\LoopInterface'), [
25+
new Adapter($this->createMock('React\EventLoop\LoopInterface'), [
2626
'pool' => [
2727
'class' => 'WyriHaximus\React\ChildProcess\Pool\Pool\Dummy',
2828
],
@@ -32,7 +32,7 @@ public function testInterface()
3232

3333
public function testGetLoop()
3434
{
35-
$loop = $this->getMock('React\EventLoop\LoopInterface');
35+
$loop = $this->createMock('React\EventLoop\LoopInterface');
3636
$filesystem = new Adapter($loop, [
3737
'pool' => [
3838
'class' => 'WyriHaximus\React\ChildProcess\Pool\Pool\Dummy',
@@ -43,7 +43,7 @@ public function testGetLoop()
4343

4444
public function testGetSetFilesystem()
4545
{
46-
$loop = $this->getMock('React\EventLoop\LoopInterface');
46+
$loop = $this->createMock('React\EventLoop\LoopInterface');
4747
$filesystem = new Adapter($loop, [
4848
'pool' => [
4949
'class' => 'WyriHaximus\React\ChildProcess\Pool\Pool\Dummy',
@@ -214,7 +214,7 @@ public function callFilesystemProvider()
214214
*/
215215
public function testCallFilesystem($method, $arguments, $mockArguments)
216216
{
217-
$loop = $this->getMock('React\EventLoop\LoopInterface');
217+
$loop = $this->createMock('React\EventLoop\LoopInterface');
218218
$filesystem = new Adapter($loop, [
219219
'pool' => [
220220
'class' => 'React\Tests\Filesystem\ChildProcess\SingletonPoolStub',
@@ -271,7 +271,7 @@ public function testLs()
271271

272272
public function testLsStream()
273273
{
274-
$loop = $this->getMock('React\EventLoop\LoopInterface');
274+
$loop = $this->createMock('React\EventLoop\LoopInterface');
275275
$adapter = new Adapter($loop, [
276276
'pool' => [
277277
'class' => 'React\Tests\Filesystem\ChildProcess\SingletonPoolStub',

tests/Eio/AdapterTest.php

+16-16
Original file line numberDiff line numberDiff line change
@@ -23,20 +23,20 @@ public function testInterface()
2323
{
2424
$this->assertInstanceOf(
2525
'React\Filesystem\AdapterInterface',
26-
new Adapter($this->getMock('React\EventLoop\LoopInterface'))
26+
new Adapter($this->createMock('React\EventLoop\LoopInterface'))
2727
);
2828
}
2929

3030
public function testGetLoop()
3131
{
32-
$loop = $this->getMock('React\EventLoop\LoopInterface');
32+
$loop = $this->createMock('React\EventLoop\LoopInterface');
3333
$filesystem = new Adapter($loop);
3434
$this->assertSame($loop, $filesystem->getLoop());
3535
}
3636

3737
public function testGetSetFilesystem()
3838
{
39-
$loop = $this->getMock('React\EventLoop\LoopInterface');
39+
$loop = $this->createMock('React\EventLoop\LoopInterface');
4040
$filesystem = new Adapter($loop, [
4141
'pool' => [
4242
'class' => 'WyriHaximus\React\ChildProcess\Pool\Pool\Dummy',
@@ -187,7 +187,7 @@ public function testCallFilesystemCalls($externalMethod, $internalMethod, $exter
187187

188188
$loop = Factory::create();
189189

190-
$filesystem = $this->getMock('React\Filesystem\Eio\Adapter', [
190+
$filesystem = $this->createMock('React\Filesystem\Eio\Adapter', [
191191
'callFilesystem',
192192
], [
193193
$loop,
@@ -207,11 +207,11 @@ public function testCallFilesystemCalls($externalMethod, $internalMethod, $exter
207207

208208
public function testHandleEvent()
209209
{
210-
$filesystem = $this->getMock('React\Filesystem\Eio\Adapter', [
210+
$filesystem = $this->createMock('React\Filesystem\Eio\Adapter', [
211211
'workPendingCount',
212212
'unregister',
213213
], [
214-
$this->getMock('React\EventLoop\LoopInterface'),
214+
$this->createMock('React\EventLoop\LoopInterface'),
215215
]);
216216

217217
$filesystem
@@ -239,11 +239,11 @@ public function testHandleEvent()
239239

240240
public function testHandleEventNothingToDo()
241241
{
242-
$filesystem = $this->getMock('React\Filesystem\Eio\Adapter', [
242+
$filesystem = $this->createMock('React\Filesystem\Eio\Adapter', [
243243
'workPendingCount',
244244
'unregister',
245245
], [
246-
$this->getMock('React\EventLoop\LoopInterface'),
246+
$this->createMock('React\EventLoop\LoopInterface'),
247247
]);
248248

249249
$filesystem
@@ -264,7 +264,7 @@ public function testHandleEventNothingToDo()
264264

265265
public function testExecuteDelayedCall()
266266
{
267-
$loop = $this->getMock('React\EventLoop\LoopInterface', [
267+
$loop = $this->createMock('React\EventLoop\LoopInterface', [
268268
'addReadStream',
269269
'addWriteStream',
270270
'removeReadStream',
@@ -323,7 +323,7 @@ public function testExecuteDelayedCall()
323323

324324
public function testExecuteDelayedCallFailed()
325325
{
326-
$loop = $this->getMock('React\EventLoop\LoopInterface', [
326+
$loop = $this->createMock('React\EventLoop\LoopInterface', [
327327
'addReadStream',
328328
'addWriteStream',
329329
'removeReadStream',
@@ -380,7 +380,7 @@ public function testExecuteDelayedCallFailed()
380380

381381
public function testExecuteDelayedCallFailedResult()
382382
{
383-
$loop = $this->getMock('React\EventLoop\LoopInterface', [
383+
$loop = $this->createMock('React\EventLoop\LoopInterface', [
384384
'addReadStream',
385385
'addWriteStream',
386386
'removeReadStream',
@@ -437,7 +437,7 @@ public function testExecuteDelayedCallFailedResult()
437437

438438
public function testUnregister()
439439
{
440-
$loop = $this->getMock('React\EventLoop\LoopInterface', [
440+
$loop = $this->createMock('React\EventLoop\LoopInterface', [
441441
'addReadStream',
442442
'addWriteStream',
443443
'removeReadStream',
@@ -456,7 +456,7 @@ public function testUnregister()
456456
'removeSignal',
457457
]);
458458

459-
$filesystem = $this->getMock('React\Filesystem\Eio\Adapter', [
459+
$filesystem = $this->createMock('React\Filesystem\Eio\Adapter', [
460460
'workPendingCount',
461461
], [
462462
$loop,
@@ -504,7 +504,7 @@ public function testUnregister()
504504

505505
public function testUnregisterInactive()
506506
{
507-
$loop = $this->getMock('React\EventLoop\LoopInterface', [
507+
$loop = $this->createMock('React\EventLoop\LoopInterface', [
508508
'addReadStream',
509509
'addWriteStream',
510510
'removeReadStream',
@@ -523,7 +523,7 @@ public function testUnregisterInactive()
523523
'removeSignal',
524524
]);
525525

526-
$filesystem = $this->getMock('React\Filesystem\Eio\Adapter', [
526+
$filesystem = $this->createMock('React\Filesystem\Eio\Adapter', [
527527
'workPendingCount',
528528
], [
529529
$loop,
@@ -558,7 +558,7 @@ public function testUnregisterInactive()
558558

559559
public function testWorkPendingCount()
560560
{
561-
$this->assertInternalType('int', (new Adapter($this->getMock('React\EventLoop\LoopInterface')))->workPendingCount());
561+
$this->assertInternalType('int', (new Adapter($this->createMock('React\EventLoop\LoopInterface')))->workPendingCount());
562562
}
563563

564564
public function testGetContents()

tests/Eio/ConstTypeDetectorTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function testDetect($const, $method)
3333
{
3434
$callbackFired = false;
3535

36-
$filesystem = Filesystem::create($this->getMock('React\EventLoop\LoopInterface'), [
36+
$filesystem = Filesystem::create($this->createMock('React\EventLoop\LoopInterface'), [
3737
'pool' => [
3838
'class' => 'WyriHaximus\React\ChildProcess\Pool\Pool\Dummy',
3939
],
@@ -55,7 +55,7 @@ public function testDetectUnknown()
5555
{
5656
$callbackFired = false;
5757

58-
$filesystem = Filesystem::create($this->getMock('React\EventLoop\LoopInterface'), [
58+
$filesystem = Filesystem::create($this->createMock('React\EventLoop\LoopInterface'), [
5959
'pool' => [
6060
'class' => 'WyriHaximus\React\ChildProcess\Pool\Pool\Dummy',
6161
],

tests/FilesystemTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public function testCreate()
1212
{
1313
$this->assertInstanceOf(
1414
'React\Filesystem\Filesystem',
15-
Filesystem::create($this->getMock('React\EventLoop\LoopInterface'), [
15+
Filesystem::create($this->createMock('React\EventLoop\LoopInterface'), [
1616
'pool' => [
1717
'class' => 'WyriHaximus\React\ChildProcess\Pool\Pool\Dummy',
1818
],
@@ -44,7 +44,7 @@ public function testFactory()
4444

4545
public function testFile()
4646
{
47-
$file = Filesystem::create($this->getMock('React\EventLoop\LoopInterface'), [
47+
$file = Filesystem::create($this->createMock('React\EventLoop\LoopInterface'), [
4848
'pool' => [
4949
'class' => 'WyriHaximus\React\ChildProcess\Pool\Pool\Dummy',
5050
],
@@ -55,7 +55,7 @@ public function testFile()
5555

5656
public function testDir()
5757
{
58-
$directory = Filesystem::create($this->getMock('React\EventLoop\LoopInterface'), [
58+
$directory = Filesystem::create($this->createMock('React\EventLoop\LoopInterface'), [
5959
'pool' => [
6060
'class' => 'WyriHaximus\React\ChildProcess\Pool\Pool\Dummy',
6161
],

tests/FlagResolverTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ class FlagResolverTest extends TestCase
77

88
public function testResolve()
99
{
10-
$resolver = $this->getMock('React\Filesystem\FlagResolver', [
10+
$resolver = $this->createMock('React\Filesystem\FlagResolver', [
1111
'defaultFlags',
1212
'flagMapping',
1313
]);

0 commit comments

Comments
 (0)