2014-09-07 00:33:46 +02:00
|
|
|
<?php
|
|
|
|
namespace Szurubooru\Tests\Services;
|
2014-10-08 14:47:47 +02:00
|
|
|
use Szurubooru\Helpers\HttpHelper;
|
|
|
|
use Szurubooru\Services\FileService;
|
|
|
|
use Szurubooru\Tests\AbstractTestCase;
|
2014-09-07 00:33:46 +02:00
|
|
|
|
2014-10-08 14:47:47 +02:00
|
|
|
final class FileServiceTest extends AbstractTestCase
|
2014-09-07 00:33:46 +02:00
|
|
|
{
|
|
|
|
public function testSaving()
|
|
|
|
{
|
2014-09-09 17:49:19 +02:00
|
|
|
$testDirectory = $this->createTestDirectory();
|
2014-09-17 14:32:26 +02:00
|
|
|
$configMock = $this->mockConfig(null, $testDirectory);
|
2014-10-08 14:47:47 +02:00
|
|
|
$httpHelper = $this->mock(HttpHelper::class);
|
|
|
|
$fileService = new FileService($configMock, $httpHelper);
|
2014-09-15 11:38:24 +02:00
|
|
|
$fileService->save('dog.txt', 'awesome dog');
|
2014-09-07 00:33:46 +02:00
|
|
|
$expected = 'awesome dog';
|
2014-09-09 17:49:19 +02:00
|
|
|
$actual = file_get_contents($testDirectory . DIRECTORY_SEPARATOR . 'dog.txt');
|
2014-09-07 00:33:46 +02:00
|
|
|
$this->assertEquals($expected, $actual);
|
|
|
|
}
|
2014-09-15 11:38:24 +02:00
|
|
|
|
|
|
|
public function testDownload()
|
|
|
|
{
|
|
|
|
$configMock = $this->mockConfig();
|
2014-10-08 14:47:47 +02:00
|
|
|
$httpHelper = $this->mock(HttpHelper::class);
|
|
|
|
$fileService = new FileService($configMock, $httpHelper);
|
2014-09-15 11:38:24 +02:00
|
|
|
$content = $fileService->download('http://modernseoul.files.wordpress.com/2012/04/korean-alphabet-chart-modern-seoul.jpg');
|
|
|
|
$this->assertGreaterThan(0, strlen($content));
|
|
|
|
}
|
2014-09-07 00:33:46 +02:00
|
|
|
}
|