Skip to content

Commit f2a4dfd

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 f186687 commit f2a4dfd

13 files changed

+58
-60
lines changed

.travis.yml

Lines changed: 0 additions & 2 deletions
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

Lines changed: 3 additions & 3 deletions
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
"autoload": {
2626
"psr-4": {
@@ -36,7 +36,7 @@
3636
"config": {
3737
"sort-packages": true,
3838
"platform": {
39-
"php": "5.4"
39+
"php": "5.6"
4040
}
4141
}
4242
}

tests/ChildProcess/AdapterTest.php

Lines changed: 5 additions & 5 deletions
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/FilesystemTest.php

Lines changed: 3 additions & 3 deletions
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

Lines changed: 1 addition & 1 deletion
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
]);

tests/Node/DirectoryTest.php

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public function testGetPath()
4141
public function testLs()
4242
{
4343
$path = '/home/foo/bar';
44-
$loop = $this->getMock('React\EventLoop\LoopInterface');
44+
$loop = $this->createMock('React\EventLoop\LoopInterface');
4545

4646
$filesystem = $this->mockAdapter($loop);
4747

@@ -62,11 +62,11 @@ public function testLs()
6262
public function testLsStream()
6363
{
6464
$path = '/home/foo/bar';
65-
$loop = $this->getMock('React\EventLoop\LoopInterface');
65+
$loop = $this->createMock('React\EventLoop\LoopInterface');
6666

6767
$filesystem = $this->mockAdapter($loop);
6868

69-
$lsStream = $this->getMock('React\Filesystem\ObjectStream');
69+
$lsStream = $this->createMock('React\Filesystem\ObjectStream');
7070

7171
$filesystem
7272
->expects($this->once())
@@ -125,7 +125,7 @@ public function testRemove()
125125
{
126126
$path = 'foo.bar';
127127
$filesystem = $this->mockAdapter();
128-
$promise = $this->getMock('React\Promise\PromiseInterface');
128+
$promise = $this->createMock('React\Promise\PromiseInterface');
129129

130130
$filesystem
131131
->expects($this->once())
@@ -139,11 +139,11 @@ public function testRemove()
139139
public function testSize()
140140
{
141141
$path = '/home/foo/bar';
142-
$loop = $this->getMock('React\EventLoop\LoopInterface');
142+
$loop = $this->createMock('React\EventLoop\LoopInterface');
143143

144144
$filesystem = $this->mockAdapter($loop);
145145

146-
$lsPromise = $this->getMock('React\Promise\PromiseInterface', [
146+
$lsPromise = $this->createMock('React\Promise\PromiseInterface', [
147147
'then',
148148
]);
149149

@@ -156,7 +156,7 @@ public function testSize()
156156
}))
157157
;
158158

159-
$directory = $this->getMock('React\Filesystem\Node\Directory', [
159+
$directory = $this->createMock('React\Filesystem\Node\Directory', [
160160
'ls',
161161
'processSizeContents',
162162
], [
@@ -175,7 +175,7 @@ public function testSize()
175175
->expects($this->once())
176176
->method('processSizeContents')
177177
->with('foo.bar', $this->isType('boolean'))
178-
->will($this->returnValue($this->getMock('React\Promise\PromiseInterface')))
178+
->will($this->returnValue($this->createMock('React\Promise\PromiseInterface')))
179179
;
180180

181181
$this->assertInstanceOf('React\Promise\PromiseInterface', $directory->size());
@@ -185,16 +185,16 @@ public function testChmodRecursive()
185185
{
186186
$filesystem = $this->mockAdapter();
187187

188-
$recursiveInvoker = $this->getMock('React\Filesystem\Node\RecursiveInvoker', [
188+
$recursiveInvoker = $this->createMock('React\Filesystem\Node\RecursiveInvoker', [
189189
'execute',
190190
], [
191-
$this->getMock('React\Filesystem\Node\DirectoryInterface', [], [
191+
$this->createMock('React\Filesystem\Node\DirectoryInterface', [], [
192192
'foo/bar/',
193193
Filesystem::createFromAdapter($filesystem),
194194
]),
195195
]);
196196

197-
$promise = $this->getMock('React\Promise\PromiseInterface');
197+
$promise = $this->createMock('React\Promise\PromiseInterface');
198198

199199
$recursiveInvoker
200200
->expects($this->once())
@@ -210,16 +210,16 @@ public function testChownRecursive()
210210
{
211211
$filesystem = $this->mockAdapter();
212212

213-
$recursiveInvoker = $this->getMock('React\Filesystem\Node\RecursiveInvoker', [
213+
$recursiveInvoker = $this->createMock('React\Filesystem\Node\RecursiveInvoker', [
214214
'execute',
215215
], [
216-
$this->getMock('React\Filesystem\Node\DirectoryInterface', [], [
216+
$this->createMock('React\Filesystem\Node\DirectoryInterface', [], [
217217
'foo/bar/',
218218
Filesystem::createFromAdapter($filesystem),
219219
]),
220220
]);
221221

222-
$promise = $this->getMock('React\Promise\PromiseInterface');
222+
$promise = $this->createMock('React\Promise\PromiseInterface');
223223

224224
$recursiveInvoker
225225
->expects($this->once())
@@ -235,16 +235,16 @@ public function testRemoveRecursive()
235235
{
236236
$filesystem = $this->mockAdapter();
237237

238-
$recursiveInvoker = $this->getMock('React\Filesystem\Node\RecursiveInvoker', [
238+
$recursiveInvoker = $this->createMock('React\Filesystem\Node\RecursiveInvoker', [
239239
'execute',
240240
], [
241-
$this->getMock('React\Filesystem\Node\DirectoryInterface', [], [
241+
$this->createMock('React\Filesystem\Node\DirectoryInterface', [], [
242242
'foo/bar/',
243243
Filesystem::createFromAdapter($filesystem),
244244
]),
245245
]);
246246

247-
$promise = $this->getMock('React\Promise\PromiseInterface');
247+
$promise = $this->createMock('React\Promise\PromiseInterface');
248248

249249
$recursiveInvoker
250250
->expects($this->once())
@@ -260,7 +260,7 @@ public function testCopy()
260260
{
261261
$filesystem = $this->mockAdapter();
262262

263-
$directoryFrom = $this->getMock('React\Filesystem\Node\Directory', [
263+
$directoryFrom = $this->createMock('React\Filesystem\Node\Directory', [
264264
'copyStreaming',
265265
], [
266266
'foo.bar',
@@ -338,7 +338,7 @@ public function testCopyStreamingABC()
338338
->will($this->returnValue(new FulfilledPromise()))
339339
;
340340

341-
$directoryFrom = $this->getMock('React\Filesystem\Node\Directory', [
341+
$directoryFrom = $this->createMock('React\Filesystem\Node\Directory', [
342342
'lsStreaming',
343343
], [
344344
'foo.bar',
@@ -358,7 +358,7 @@ public function testCopyStreamingABC()
358358
$returnedStream = $directoryFrom->copyStreaming($directoryTo);
359359
$this->assertInstanceOf('React\Filesystem\ObjectStream', $returnedStream);
360360

361-
$file = $this->getMock('React\Filesystem\Node\File', [
361+
$file = $this->createMock('React\Filesystem\Node\File', [
362362
'copyStreaming',
363363
], [
364364
'foo.bar',
@@ -378,7 +378,7 @@ public function testCopyStreamingABC()
378378
$file,
379379
]);
380380

381-
$directory = $this->getMock('React\Filesystem\Node\Directory', [
381+
$directory = $this->createMock('React\Filesystem\Node\Directory', [
382382
'copyStreaming',
383383
], [
384384
'foo.bar',

tests/Node/FileTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public function testRemove()
4343
{
4444
$path = 'foo.bar';
4545
$filesystem = $this->mockAdapter();
46-
$promise = $this->getMock('React\Promise\PromiseInterface');
46+
$promise = $this->createMock('React\Promise\PromiseInterface');
4747

4848
$filesystem
4949
->expects($this->once())
@@ -78,7 +78,7 @@ public function testExists()
7878
$path = 'foo.bar';
7979
$filesystem = $this->mockAdapter();
8080

81-
$file = $this->getMock('React\Filesystem\Node\File', [
81+
$file = $this->createMock('React\Filesystem\Node\File', [
8282
'stat',
8383
], [
8484
$path,
@@ -102,7 +102,7 @@ public function testDoesntExists()
102102
$path = 'foo.bar';
103103
$filesystem = $this->mockAdapter();
104104

105-
$file = $this->getMock('React\Filesystem\Node\File', [
105+
$file = $this->createMock('React\Filesystem\Node\File', [
106106
'stat',
107107
], [
108108
$path,
@@ -348,7 +348,7 @@ public function testTouch()
348348
->expects($this->once())
349349
->method('touch')
350350
->with($path)
351-
->will($this->returnValue($this->getMock('React\Promise\PromiseInterface')))
351+
->will($this->returnValue($this->createMock('React\Promise\PromiseInterface')))
352352
;
353353

354354
$this->assertInstanceOf('React\Promise\PromiseInterface', (new File($path, Filesystem::createFromAdapter($filesystem)))->touch());
@@ -358,7 +358,7 @@ public function testCopy()
358358
{
359359
$filesystem = $this->mockAdapter();
360360

361-
$fileFrom = $this->getMock('React\Filesystem\Node\File', [
361+
$fileFrom = $this->createMock('React\Filesystem\Node\File', [
362362
'copyStreaming',
363363
], [
364364
'foo.bar',
@@ -392,7 +392,7 @@ public function testCopyDirectory()
392392
{
393393
$filesystem = $this->mockAdapter();
394394

395-
$file = $this->getMock('React\Filesystem\Node\File', [
395+
$file = $this->createMock('React\Filesystem\Node\File', [
396396
'copyToFile',
397397
], [
398398
'foo.bar',

tests/Node/RecursiveInvokerTest.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,15 @@ public function testExecute()
1414
{
1515
$filesystem = $this->mockAdapter();
1616

17-
$node = $this->getMock('React\Filesystem\Node\Directory', [
17+
$node = $this->createMock('React\Filesystem\Node\Directory', [
1818
'ls',
1919
'chmod',
2020
], [
2121
'foo.bar',
2222
Filesystem::createFromAdapter($filesystem),
2323
]);
2424

25-
$promise = $this->getMock('React\Promise\PromiseInterface');
25+
$promise = $this->createMock('React\Promise\PromiseInterface');
2626

2727
$node
2828
->expects($this->once())
@@ -31,7 +31,7 @@ public function testExecute()
3131
->will($this->returnValue($promise))
3232
;
3333

34-
$fileDent = $this->getMock('React\Filesystem\Node\File', [
34+
$fileDent = $this->createMock('React\Filesystem\Node\File', [
3535
'chmod',
3636
], [
3737
'foo',
@@ -45,7 +45,7 @@ public function testExecute()
4545
->will($this->returnValue(new FulfilledPromise()))
4646
;
4747

48-
$directoryDent = $this->getMock('React\Filesystem\Node\Directory', [
48+
$directoryDent = $this->createMock('React\Filesystem\Node\Directory', [
4949
'chmodRecursive',
5050
], [
5151
'foo',
@@ -59,7 +59,7 @@ public function testExecute()
5959
->will($this->returnValue(new FulfilledPromise()))
6060
;
6161

62-
$finalPromise = $this->getMock('React\Promise\PromiseInterface');
62+
$finalPromise = $this->createMock('React\Promise\PromiseInterface');
6363

6464
$node
6565
->expects($this->once())

tests/ObjectStreamSinkTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class ObjectStreamSinkTest extends TestCase
99
{
1010
public function testSink()
1111
{
12-
$node = $this->getMock('React\Filesystem\Node\NodeInterface');
12+
$node = $this->createMock('React\Filesystem\Node\NodeInterface');
1313
$stream = new ObjectStream();
1414
$sink = ObjectStreamSink::promise($stream);
1515
$this->assertInstanceOf('React\Promise\PromiseInterface', $sink);

tests/ObjectStreamTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class ObjectStreamTest extends TestCase
99
{
1010
public function testObjectStream()
1111
{
12-
$node = $this->getMock('React\Filesystem\Node\NodeInterface');
12+
$node = $this->createMock('React\Filesystem\Node\NodeInterface');
1313
$stream = new ObjectStream();
1414

1515
$this->assertTrue($stream->isWritable());

0 commit comments

Comments
 (0)