1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Partnermarketing\FileSystemBundle\Tests\Unit\ServerFileSystem; |
4
|
|
|
|
5
|
|
|
use Partnermarketing\FileSystemBundle\ServerFileSystem\ServerFileSystem; |
6
|
|
|
|
7
|
|
|
class ServerFileSystemTest extends \PHPUnit_Framework_TestCase |
8
|
|
|
{ |
9
|
|
|
public function testGetFilesInDirectory() |
10
|
|
|
{ |
11
|
|
|
$files = ServerFileSystem::getFilesInDirectory(__DIR__); |
12
|
|
|
|
13
|
|
|
$this->assertCount(1, $files); |
14
|
|
|
} |
15
|
|
|
|
16
|
|
|
public function testGetFilesInDirectoryIsRecursiveAndAlphabetical() |
17
|
|
|
{ |
18
|
|
|
$files = ServerFileSystem::getFilesInDirectory(__DIR__ . '/../'); |
19
|
|
|
|
20
|
|
|
$this->assertCount(6, $files); |
21
|
|
|
$this->assertStringEndsWith('Unit/Adapter/LocalStorageTest.php', $files[0]); |
22
|
|
|
$this->assertStringEndsWith('Unit/Factory/FileSystemFactoryTest.php', $files[3]); |
23
|
|
|
} |
24
|
|
|
|
25
|
|
|
public function testDeleteFilesInDirectoryRecursively() |
26
|
|
|
{ |
27
|
|
|
$dir = __DIR__ . '/deleteFilesInDirectoryRecursively/'; |
28
|
|
|
|
29
|
|
|
if (!is_dir($dir)) { |
30
|
|
|
mkdir($dir); |
31
|
|
|
} |
32
|
|
|
file_put_contents($dir . '1.txt', '1'); |
33
|
|
|
file_put_contents($dir . '2.txt', '2'); |
34
|
|
|
mkdir($dir . 'subdir'); |
35
|
|
|
file_put_contents($dir . 'subdir/3.txt', '3'); |
36
|
|
|
file_put_contents($dir . 'subdir/4.txt', '4'); |
37
|
|
|
|
38
|
|
|
$filesBefore = ServerFileSystem::getFilesInDirectory($dir); |
39
|
|
|
$this->assertCount(4, $filesBefore); |
40
|
|
|
|
41
|
|
|
$files = ServerFileSystem::deleteFilesInDirectoryRecursively($dir); |
|
|
|
|
42
|
|
|
|
43
|
|
|
$filesAfter = ServerFileSystem::getFilesInDirectory($dir); |
44
|
|
|
$this->assertCount(0, $filesAfter); |
45
|
|
|
} |
46
|
|
|
} |
47
|
|
|
|
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()
can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.