mirror of
https://codeberg.org/demostf/api.git
synced 2026-06-03 09:54:17 +02:00
remove demo file if saving fails
This commit is contained in:
parent
86ffe80044
commit
eb3c909a93
3 changed files with 37 additions and 4 deletions
|
|
@ -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()));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue