1
0
Fork 0
mirror of https://codeberg.org/demostf/api.git synced 2026-06-03 18:04:08 +02:00

remove demo file if saving fails

This commit is contained in:
Robin Appelman 2022-05-18 13:35:10 +02:00
commit eb3c909a93
3 changed files with 37 additions and 4 deletions

View file

@ -20,6 +20,8 @@ class DemoStoreTest extends TestCase {
$storedDemo = $demoStore->store($file, 'foodemo.dem');
$this->assertTrue(file_exists($storedDemo->getPath()));
$this->assertStringEndsWith('/foodemo.dem', $storedDemo->getUrl());
$this->assertStringStartsWith('https://static.example.com/', $storedDemo->getUrl());
$this->assertEquals('static', $storedDemo->getBackend());
@ -30,4 +32,23 @@ class DemoStoreTest extends TestCase {
rmdir(\dirname($storedDemo->getPath(), 2));
rmdir($targetDir);
}
public function testRemoveByName() {
$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->assertTrue(file_exists($storedDemo->getPath()));
$demoStore->removeByName('foodemo.dem');
$this->assertFalse(file_exists($storedDemo->getPath()));
}
}