1
0
Fork 0
mirror of https://codeberg.org/demostf/api.git synced 2026-06-03 09:54:17 +02:00
api/test/Demo/DemoStoreTest.php
2017-07-30 15:07:18 +02:00

33 lines
1 KiB
PHP

<?php
declare(strict_types=1);
namespace Demostf\API\Test\Demo;
use Demostf\API\Demo\DemoStore;
use Demostf\API\Test\TestCase;
class DemoStoreTest extends TestCase {
public function testStore() {
$targetDir = tempnam(sys_get_temp_dir(), 'dummy_target_');
unlink($targetDir);
mkdir($targetDir);
$demoStore = new DemoStore($targetDir, 'static.example.com');
$file = tempnam(sys_get_temp_dir(), 'dummy_');
file_put_contents($file, 'foobar');
$storedDemo = $demoStore->store($file, 'foodemo.dem');
$this->assertStringEndsWith('/foodemo.dem', $storedDemo->getUrl());
$this->assertStringStartsWith('https://static.example.com/', $storedDemo->getUrl());
$this->assertEquals('static', $storedDemo->getBackend());
$this->assertStringEqualsFile($storedDemo->getPath(), 'foobar');
unlink($storedDemo->getPath());
rmdir(dirname($storedDemo->getPath()));
rmdir(dirname($storedDemo->getPath(), 2));
rmdir($targetDir);
}
}