1 | <?php |
||
13 | class FileTest extends PHPUnit_Framework_TestCase |
||
14 | { |
||
15 | private $fileSystem; |
||
16 | |||
17 | /** |
||
18 | * FileTest constructor. |
||
19 | */ |
||
20 | public function __construct() |
||
24 | |||
25 | public function testGetFile() |
||
26 | { |
||
27 | $nonExistingFile = ASSETS_DIR . 'iDoNotExist.txt'; |
||
28 | $existingFile = ASSETS_DIR . 'report.csv'; |
||
29 | $onlineFile = 'http://google.com/test.txt'; |
||
30 | $file = ASSETS_DIR . 'example.txt'; |
||
31 | |||
32 | $mock = new MockHandler([new Response(200, [])]); |
||
33 | $handler = HandlerStack::create($mock); |
||
34 | $client = new Client(['handler' => $handler]); |
||
35 | $fileHelper = new File($client); |
||
36 | |||
37 | $result = $fileHelper->copyFile($nonExistingFile); |
||
38 | $this->assertFalse($result); |
||
39 | |||
40 | $result = $fileHelper->copyFile($existingFile); |
||
41 | $this->assertEquals($existingFile, $result); |
||
42 | |||
43 | $result = $fileHelper->copyFile($existingFile, $file); |
||
44 | $this->assertEquals($file, $result); |
||
45 | $this->fileSystem->remove($file); |
||
46 | |||
47 | $result = $fileHelper->copyFile($onlineFile, $file); |
||
48 | $this->assertEquals($file, $result); |
||
49 | |||
50 | $this->fileSystem->remove($file); |
||
51 | } |
||
52 | |||
53 | public function testDownload() |
||
70 | |||
71 | /** |
||
72 | * @expectedException \Exception |
||
73 | */ |
||
74 | public function testDownloadThrowsException() |
||
81 | |||
82 | public function testIsZipFile() |
||
89 | |||
90 | public function testUnZip() |
||
106 | |||
107 | /** |
||
108 | * @expectedException \Exception |
||
109 | */ |
||
110 | public function testCorruptUnZip() |
||
116 | } |
||
117 |