From b5dfb01dc54a652ad6d08f212cb20e54cb0b5e61 Mon Sep 17 00:00:00 2001 From: "Bernd.Rederlechner@t-systems.com" Date: Tue, 11 May 2021 16:58:37 +0000 Subject: [PATCH] Add lacking cleanup for some objects created. Signed-off-by: Bernd.Rederlechner@t-systems.com --- .../lib/Files/ObjectStore/ObjectStoreTest.php | 3 +++ tests/lib/Files/ObjectStore/S3Test.php | 18 ++++++++++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/tests/lib/Files/ObjectStore/ObjectStoreTest.php b/tests/lib/Files/ObjectStore/ObjectStoreTest.php index 4ec44eb410..88317c0a24 100644 --- a/tests/lib/Files/ObjectStore/ObjectStoreTest.php +++ b/tests/lib/Files/ObjectStore/ObjectStoreTest.php @@ -123,5 +123,8 @@ abstract class ObjectStoreTest extends TestCase { $this->assertTrue($instance->objectExists('target')); $this->assertEquals('foobar', stream_get_contents($instance->readObject('target'))); + + $instance->deleteObject('source'); + $instance->deleteObject('target'); } } diff --git a/tests/lib/Files/ObjectStore/S3Test.php b/tests/lib/Files/ObjectStore/S3Test.php index c047735eaa..e729e869bc 100644 --- a/tests/lib/Files/ObjectStore/S3Test.php +++ b/tests/lib/Files/ObjectStore/S3Test.php @@ -81,6 +81,8 @@ class S3Test extends ObjectStoreTest { $result = $s3->readObject('multiparttest'); $this->assertEquals(file_get_contents(__FILE__), stream_get_contents($result)); + + $s3->deleteObject('multiparttest'); } public function testSeek() { @@ -97,6 +99,8 @@ class S3Test extends ObjectStoreTest { fseek($read, 100, SEEK_CUR); $this->assertEquals(substr($data, 210, 100), fread($read, 100)); + + $instance->deleteObject('seek'); } function assertNoUpload($objectUrn) { @@ -110,19 +114,21 @@ class S3Test extends ObjectStoreTest { $this->assertArrayNotHasKey('Uploads', $uploads); } - public function testMultipartException() { + public function testEmptyUpload() { //$this->expectException(S3MultipartUploadException::class); $s3 = $this->getInstance(); // create an empty stream and check that it fits to the // pre-conditions in writeObject for the empty case - $stupidStream = fopen("php://memory", "r"); - fwrite($stupidStream, NULL); + $emptyStream = fopen("php://memory", "r"); + fwrite($emptyStream, NULL); - $s3->writeObject('stupidstream', $stupidStream); + $s3->writeObject('emptystream', $emptyStream); // this method intendedly produces an S3Exception - $this->assertNoUpload('stupidstream'); - } + $this->assertNoUpload('emptystream'); + $this->assertTrue($s3->objectExists('emptystream')); + $s3->deleteObject('emptystream'); + } }