szurubooru/tests/Services/FileServiceTest.php

27 lines
1,005 B
PHP
Raw Normal View History

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