Skip to content

Commit

Permalink
fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Aidas Klimas committed Dec 9, 2024
1 parent 24ba9ac commit db71398
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
11 changes: 5 additions & 6 deletions test/Unit/FileTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,6 @@ public function testFile_deleteChunks()
*/
public function testFile_saveChunk()
{
//// Setup test

// Setup temporary file
$tmpDir = new vfsStreamDirectory('tmp');
$tmpFile = vfsStream::newFile('tmpFile');
Expand All @@ -257,18 +255,19 @@ public function testFile_saveChunk()

// Mock File to use rename instead of move_uploaded_file
$request = new Request($this->requestArr, $this->filesArr['file']);
$file = $this->createMock('Flow\File'); //, ['_move_uploaded_file'], [$this->config, $request]);
$file = $this->createPartialMock(File::class, ['_move_uploaded_file']);
$file->expects($this->once())
->method('_move_uploaded_file')
->will($this->returnCallback(static function ($filename, $destination) {
->willReturnCallback(static function (string $filename, string $destination): bool {
return rename($filename, $destination);
}));
});
$file->__construct($this->config, $request);


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

//// Accrual test

$this->assertFalse(file_exists($expDstFile));
$this->assertTrue(file_exists($tmpFile->url()));

Expand Down
9 changes: 4 additions & 5 deletions test/Unit/FustyRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ public function testFustyRequest_construct()

public function testFustyRequest_ValidateUpload()
{
//// Setup test

$firstChunk = vfsStream::newFile('temp_file');
$firstChunk->setContent('1234567890');
$this->vfs->addChild($firstChunk);
Expand All @@ -94,14 +92,15 @@ public function testFustyRequest_ValidateUpload()
$config = new Config();
$config->setTempDir($this->vfs->url());

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

/** @noinspection PhpUndefinedMethodInspection */
$file->expects($this->once())
->method('_move_uploaded_file')
->will($this->returnCallback(static function ($filename, $destination) {
->willReturnCallback(static function ($filename, $destination) {
return rename($filename, $destination);
}));
});

//// Actual test

Expand Down

0 comments on commit db71398

Please sign in to comment.