|
|
@@ -1,4 +1,5 @@
|
|
|
<?php
|
|
|
+
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
namespace App\Tests\Unit\Service\Utils;
|
|
|
@@ -10,7 +11,8 @@ use PHPUnit\Framework\MockObject\MockObject;
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
use Symfony\Component\Config\FileLocator;
|
|
|
|
|
|
-class TestableFileUtils extends FileUtils {
|
|
|
+class TestableFileUtils extends FileUtils
|
|
|
+{
|
|
|
public function makePath(string $path): Path
|
|
|
{
|
|
|
return parent::makePath($path);
|
|
|
@@ -32,7 +34,8 @@ class FileUtilsTest extends TestCase
|
|
|
->getMock();
|
|
|
}
|
|
|
|
|
|
- public function testGetMimeTypeFromExt() {
|
|
|
+ public function testGetMimeTypeFromExt()
|
|
|
+ {
|
|
|
$fileUtils = $this->getMockFor('getMimeTypeFromExt');
|
|
|
|
|
|
$this->assertEquals(
|
|
|
@@ -51,7 +54,8 @@ class FileUtilsTest extends TestCase
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- public function testGetMimeTypeFromFilename() {
|
|
|
+ public function testGetMimeTypeFromFilename()
|
|
|
+ {
|
|
|
$fileUtils = $this->getMockFor('guessMimeTypeFromFilename');
|
|
|
|
|
|
$fileUtils->method('getMimeTypeFromExt')->with('png')->willReturn('image/png');
|
|
|
@@ -62,7 +66,8 @@ class FileUtilsTest extends TestCase
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- public function testIsImage() {
|
|
|
+ public function testIsImage()
|
|
|
+ {
|
|
|
$fileUtils = $this->getMockFor('isImage');
|
|
|
|
|
|
// has a registered mimetype
|
|
|
@@ -89,7 +94,8 @@ class FileUtilsTest extends TestCase
|
|
|
$this->assertFalse($fileUtils->isImage($file3));
|
|
|
}
|
|
|
|
|
|
- public function testGetTempFilename() {
|
|
|
+ public function testGetTempFilename()
|
|
|
+ {
|
|
|
$fileUtils = $this->getMockFor('getTempFilename');
|
|
|
|
|
|
$tempDirPath = $this->getMockBuilder(Path::class)->disableOriginalConstructor()->getMock();
|
|
|
@@ -103,7 +109,8 @@ class FileUtilsTest extends TestCase
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- public function testGetTempFilenameWithPrefix() {
|
|
|
+ public function testGetTempFilenameWithPrefix()
|
|
|
+ {
|
|
|
$fileUtils = $this->getMockFor('getTempFilename');
|
|
|
|
|
|
$tempDirPath = $this->getMockBuilder(Path::class)->disableOriginalConstructor()->getMock();
|
|
|
@@ -117,7 +124,8 @@ class FileUtilsTest extends TestCase
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- public function testRmIfExist() {
|
|
|
+ public function testRmIfExist()
|
|
|
+ {
|
|
|
$fileUtils = $this->getMockFor('rmIfExist');
|
|
|
|
|
|
$myPath = '/path/to/something';
|
|
|
@@ -130,7 +138,8 @@ class FileUtilsTest extends TestCase
|
|
|
$fileUtils->rmIfExist($myPath);
|
|
|
}
|
|
|
|
|
|
- public function testGetFileContent() {
|
|
|
+ public function testGetFileContent()
|
|
|
+ {
|
|
|
$fileUtils = $this->getMockFor('getFileContent');
|
|
|
|
|
|
$myPath = '/path/to/something';
|
|
|
@@ -143,7 +152,8 @@ class FileUtilsTest extends TestCase
|
|
|
$this->assertEquals('my content', $fileUtils->getFileContent($myPath));
|
|
|
}
|
|
|
|
|
|
- public function testLocate() {
|
|
|
+ public function testLocate()
|
|
|
+ {
|
|
|
$fileUtils = $this->getMockFor('locate');
|
|
|
|
|
|
$fileLocator = $this->getMockBuilder(FileLocator::class)->disableOriginalConstructor()->getMock();
|
|
|
@@ -162,7 +172,8 @@ class FileUtilsTest extends TestCase
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- public function testLocateNotFound() {
|
|
|
+ public function testLocateNotFound()
|
|
|
+ {
|
|
|
$fileUtils = $this->getMockFor('locate');
|
|
|
|
|
|
$fileLocator = $this->getMockBuilder(FileLocator::class)->disableOriginalConstructor()->getMock();
|
|
|
@@ -181,7 +192,8 @@ class FileUtilsTest extends TestCase
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- public function testList() {
|
|
|
+ public function testList()
|
|
|
+ {
|
|
|
$fileUtils = $this->getMockFor('list');
|
|
|
|
|
|
$path = $this->getMockBuilder(Path::class)->disableOriginalConstructor()->getMock();
|
|
|
@@ -206,7 +218,8 @@ class FileUtilsTest extends TestCase
|
|
|
);
|
|
|
}
|
|
|
|
|
|
- public function testListWithGlob() {
|
|
|
+ public function testListWithGlob()
|
|
|
+ {
|
|
|
$fileUtils = $this->getMockFor('list');
|
|
|
|
|
|
$path = $this->getMockBuilder(Path::class)->disableOriginalConstructor()->getMock();
|
|
|
@@ -230,6 +243,4 @@ class FileUtilsTest extends TestCase
|
|
|
$fileUtils->list('/home', '*.pdf')
|
|
|
);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
}
|