]> git.mxchange.org Git - friendica.git/commitdiff
Rename StorageTest with StorageTestCase
authorArt4 <art4@wlabs.de>
Sun, 15 Dec 2024 21:36:40 +0000 (21:36 +0000)
committerArt4 <art4@wlabs.de>
Sun, 15 Dec 2024 21:36:40 +0000 (21:36 +0000)
tests/StorageTestCase.php [new file with mode: 0644]
tests/src/Core/Storage/DatabaseStorageTest.php
tests/src/Core/Storage/FilesystemStorageTest.php
tests/src/Core/Storage/StorageTest.php [deleted file]

diff --git a/tests/StorageTestCase.php b/tests/StorageTestCase.php
new file mode 100644 (file)
index 0000000..8a2ffda
--- /dev/null
@@ -0,0 +1,93 @@
+<?php
+
+// Copyright (C) 2010-2024, the Friendica project
+// SPDX-FileCopyrightText: 2010-2024 the Friendica project
+//
+// SPDX-License-Identifier: AGPL-3.0-or-later
+
+namespace Friendica\Test;
+
+use Friendica\Core\Storage\Capability\ICanReadFromStorage;
+use Friendica\Core\Storage\Capability\ICanWriteToStorage;
+use Friendica\Core\Storage\Exception\ReferenceStorageException;
+use Friendica\Test\MockedTestCase;
+
+abstract class StorageTestCase extends MockedTestCase
+{
+       /** @return ICanWriteToStorage */
+       abstract protected function getInstance();
+
+       /**
+        * Test if the instance is "really" implementing the interface
+        */
+       public function testInstance()
+       {
+               $instance = $this->getInstance();
+               self::assertInstanceOf(ICanReadFromStorage::class, $instance);
+       }
+
+       /**
+        * Test basic put, get and delete operations
+        */
+       public function testPutGetDelete()
+       {
+               $instance = $this->getInstance();
+
+               $ref = $instance->put('data12345');
+               self::assertNotEmpty($ref);
+
+               self::assertEquals('data12345', $instance->get($ref));
+
+               $instance->delete($ref);
+       }
+
+       /**
+        * Test a delete with an invalid reference
+        */
+       public function testInvalidDelete()
+       {
+               self::expectException(ReferenceStorageException::class);
+
+               $instance = $this->getInstance();
+
+               $instance->delete(-1234456);
+       }
+
+       /**
+        * Test a get with an invalid reference
+        */
+       public function testInvalidGet()
+       {
+               self::expectException(ReferenceStorageException::class);
+
+               $instance = $this->getInstance();
+
+               $instance->get(-123456);
+       }
+
+       /**
+        * Test an update with a given reference
+        */
+       public function testUpdateReference()
+       {
+               $instance = $this->getInstance();
+
+               $ref = $instance->put('data12345');
+               self::assertNotEmpty($ref);
+
+               self::assertEquals('data12345', $instance->get($ref));
+
+               self::assertEquals($ref, $instance->put('data5432', $ref));
+               self::assertEquals('data5432', $instance->get($ref));
+       }
+
+       /**
+        * Test that an invalid update results in an insert
+        */
+       public function testInvalidUpdate()
+       {
+               $instance = $this->getInstance();
+
+               self::assertEquals(-123, $instance->put('data12345', -123));
+       }
+}
index 17660ceed210090f45c2b0d90e9765d0946e446f..ab3c514b1d6d25871038c46e5a1d213819571c77 100644 (file)
@@ -8,9 +8,10 @@
 namespace Friendica\Test\src\Core\Storage;
 
 use Friendica\Core\Storage\Type\Database;
+use Friendica\Test\StorageTestCase;
 use Friendica\Test\Util\CreateDatabaseTrait;
 
-class DatabaseStorageTest extends StorageTest
+class DatabaseStorageTest extends StorageTestCase
 {
        use CreateDatabaseTrait;
 
index 64bcb68a4a5ed3638c8095be41afaab08c564677..2d2cfa8d3a6335d15357dcf8bb8065e3f8a9f972 100644 (file)
@@ -10,10 +10,11 @@ namespace Friendica\Test\src\Core\Storage;
 use Friendica\Core\Storage\Exception\StorageException;
 use Friendica\Core\Storage\Type\Filesystem;
 use Friendica\Core\Storage\Type\FilesystemConfig;
+use Friendica\Test\StorageTestCase;
 use Friendica\Test\Util\VFSTrait;
 use org\bovigo\vfs\vfsStream;
 
-class FilesystemStorageTest extends StorageTest
+class FilesystemStorageTest extends StorageTestCase
 {
        use VFSTrait;
 
diff --git a/tests/src/Core/Storage/StorageTest.php b/tests/src/Core/Storage/StorageTest.php
deleted file mode 100644 (file)
index 9816db9..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-<?php
-
-// Copyright (C) 2010-2024, the Friendica project
-// SPDX-FileCopyrightText: 2010-2024 the Friendica project
-//
-// SPDX-License-Identifier: AGPL-3.0-or-later
-
-namespace Friendica\Test\src\Core\Storage;
-
-use Friendica\Core\Storage\Capability\ICanReadFromStorage;
-use Friendica\Core\Storage\Capability\ICanWriteToStorage;
-use Friendica\Core\Storage\Exception\ReferenceStorageException;
-use Friendica\Test\MockedTestCase;
-
-abstract class StorageTest extends MockedTestCase
-{
-       /** @return ICanWriteToStorage */
-       abstract protected function getInstance();
-
-       /**
-        * Test if the instance is "really" implementing the interface
-        */
-       public function testInstance()
-       {
-               $instance = $this->getInstance();
-               self::assertInstanceOf(ICanReadFromStorage::class, $instance);
-       }
-
-       /**
-        * Test basic put, get and delete operations
-        */
-       public function testPutGetDelete()
-       {
-               $instance = $this->getInstance();
-
-               $ref = $instance->put('data12345');
-               self::assertNotEmpty($ref);
-
-               self::assertEquals('data12345', $instance->get($ref));
-
-               $instance->delete($ref);
-       }
-
-       /**
-        * Test a delete with an invalid reference
-        */
-       public function testInvalidDelete()
-       {
-               self::expectException(ReferenceStorageException::class);
-
-               $instance = $this->getInstance();
-
-               $instance->delete(-1234456);
-       }
-
-       /**
-        * Test a get with an invalid reference
-        */
-       public function testInvalidGet()
-       {
-               self::expectException(ReferenceStorageException::class);
-
-               $instance = $this->getInstance();
-
-               $instance->get(-123456);
-       }
-
-       /**
-        * Test an update with a given reference
-        */
-       public function testUpdateReference()
-       {
-               $instance = $this->getInstance();
-
-               $ref = $instance->put('data12345');
-               self::assertNotEmpty($ref);
-
-               self::assertEquals('data12345', $instance->get($ref));
-
-               self::assertEquals($ref, $instance->put('data5432', $ref));
-               self::assertEquals('data5432', $instance->get($ref));
-       }
-
-       /**
-        * Test that an invalid update results in an insert
-        */
-       public function testInvalidUpdate()
-       {
-               $instance = $this->getInstance();
-
-               self::assertEquals(-123, $instance->put('data12345', -123));
-       }
-}