Skip to content

Commit db71398

Browse files
author
Aidas Klimas
committed
fix tests
1 parent 24ba9ac commit db71398

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

test/Unit/FileTest.php

+5-6
Original file line numberDiff line numberDiff line change
@@ -245,8 +245,6 @@ public function testFile_deleteChunks()
245245
*/
246246
public function testFile_saveChunk()
247247
{
248-
//// Setup test
249-
250248
// Setup temporary file
251249
$tmpDir = new vfsStreamDirectory('tmp');
252250
$tmpFile = vfsStream::newFile('tmpFile');
@@ -257,18 +255,19 @@ public function testFile_saveChunk()
257255

258256
// Mock File to use rename instead of move_uploaded_file
259257
$request = new Request($this->requestArr, $this->filesArr['file']);
260-
$file = $this->createMock('Flow\File'); //, ['_move_uploaded_file'], [$this->config, $request]);
258+
$file = $this->createPartialMock(File::class, ['_move_uploaded_file']);
261259
$file->expects($this->once())
262260
->method('_move_uploaded_file')
263-
->will($this->returnCallback(static function ($filename, $destination) {
261+
->willReturnCallback(static function (string $filename, string $destination): bool {
264262
return rename($filename, $destination);
265-
}));
263+
});
264+
$file->__construct($this->config, $request);
265+
266266

267267
// Expected destination file
268268
$expDstFile = $this->vfs->url().DIRECTORY_SEPARATOR.sha1($request->getIdentifier()).'_1';
269269

270270
//// Accrual test
271-
272271
$this->assertFalse(file_exists($expDstFile));
273272
$this->assertTrue(file_exists($tmpFile->url()));
274273

test/Unit/FustyRequestTest.php

+4-5
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,6 @@ public function testFustyRequest_construct()
7171

7272
public function testFustyRequest_ValidateUpload()
7373
{
74-
//// Setup test
75-
7674
$firstChunk = vfsStream::newFile('temp_file');
7775
$firstChunk->setContent('1234567890');
7876
$this->vfs->addChild($firstChunk);
@@ -94,14 +92,15 @@ public function testFustyRequest_ValidateUpload()
9492
$config = new Config();
9593
$config->setTempDir($this->vfs->url());
9694

97-
$file = $this->createMock('Flow\File');//, ['_move_uploaded_file'], [$config, $fustyRequest]);
95+
$file = $this->createPartialMock(File::class, ['_move_uploaded_file']);
96+
$file->__construct($config, $fustyRequest);
9897

9998
/** @noinspection PhpUndefinedMethodInspection */
10099
$file->expects($this->once())
101100
->method('_move_uploaded_file')
102-
->will($this->returnCallback(static function ($filename, $destination) {
101+
->willReturnCallback(static function ($filename, $destination) {
103102
return rename($filename, $destination);
104-
}));
103+
});
105104

106105
//// Actual test
107106

0 commit comments

Comments
 (0)