diff --git a/tests/lib/SimpleSAML/Store/RedisTest.php b/tests/lib/SimpleSAML/Store/RedisTest.php index 9625027c6a11ed8e6bcdf9e37265768a2b38a25f..13897a991a11f8ca302ab22c2c4ef0fad4b578d9 100644 --- a/tests/lib/SimpleSAML/Store/RedisTest.php +++ b/tests/lib/SimpleSAML/Store/RedisTest.php @@ -17,7 +17,7 @@ use SimpleSAML\Store; * For the full copyright and license information, please view the LICENSE file that was distributed with this source * code. * - * @covers \SimpleSAML\Store\Redis + * @covers \SimpleSAML\Store\RedisStore * @package simplesamlphp/simplesamlphp */ class RedisTest extends TestCase @@ -25,8 +25,8 @@ class RedisTest extends TestCase /** @var \PHPUnit\Framework\MockObject\MockObject */ protected MockObject $mocked_redis; - /** @var \SimpleSAML\Store\Redis */ - protected Store\Redis $redis; + /** @var \SimpleSAML\Store\RedisStore */ + protected Store\RedisStore $redis; /** @var array */ protected array $config; @@ -63,7 +63,7 @@ class RedisTest extends TestCase ->will($this->returnCallback($nop)); /** @var \Predis\Client $this->mocked_redis */ - $this->redis = new Store\Redis($this->mocked_redis); + $this->redis = new Store\RedisStore($this->mocked_redis); } @@ -118,13 +118,13 @@ class RedisTest extends TestCase 'store.redis.prefix' => 'phpunit_', ], '[ARRAY]', 'simplesaml'); - /** @var \SimpleSAML\Store\Redis $store */ - $store = Store::getInstance(); + /** @var \SimpleSAML\Store\RedisStore $store */ + $store = StoreFactory::getInstance(); - $this->assertInstanceOf(Store\Redis::class, $store); + $this->assertInstanceOf(Store\RedisStore::class, $store); $this->clearInstance($config, Configuration::class); - $this->clearInstance($store, Store::class); +// $this->clearInstance($store, Store::class); } @@ -139,13 +139,13 @@ class RedisTest extends TestCase 'store.redis.password' => 'password', ], '[ARRAY]', 'simplesaml'); - /** @var \SimpleSAML\Store\Redis $store */ - $store = Store::getInstance(); + /** @var \SimpleSAML\Store\RedisStore $store */ + $store = StoreFactory::getInstance(); - $this->assertInstanceOf(Store\Redis::class, $store); + $this->assertInstanceOf(Store\RedisStore::class, $store); $this->clearInstance($config, Configuration::class); - $this->clearInstance($store, Store::class); +// $this->clearInstance($store, Store::class); } @@ -221,7 +221,7 @@ class RedisTest extends TestCase /** - * @param \SimpleSAML\Configuration|\SimpleSAML\Store $service + * @param \SimpleSAML\Configuration|\SimpleSAML\Store\StoreInterface $service * @param class-string $className */ protected function clearInstance($service, string $className): void diff --git a/tests/lib/SimpleSAML/Store/SQLTest.php b/tests/lib/SimpleSAML/Store/SQLTest.php index 14358f87f29af74bba2c91e6ff884fd90955c03c..c6d6696bd896735f26962d98a563fff3d4dffebd 100644 --- a/tests/lib/SimpleSAML/Store/SQLTest.php +++ b/tests/lib/SimpleSAML/Store/SQLTest.php @@ -8,6 +8,7 @@ use PHPUnit\Framework\TestCase; use ReflectionClass; use SimpleSAML\Configuration; use SimpleSAML\Store; +use SimpleSAML\Store\StoreFactory; /** * Tests for the SQL store. @@ -15,7 +16,7 @@ use SimpleSAML\Store; * For the full copyright and license information, please view the LICENSE file that was distributed with this source * code. * - * @covers \SimpleSAML\Store\SQL + * @covers \SimpleSAML\Store\SQLStore * * @package simplesamlphp/simplesamlphp */ @@ -38,7 +39,7 @@ class SQLTest extends TestCase */ public function SQLInstance(): void { - $store = Store::getInstance(); + $store = StoreFactory::getInstance(); $this->assertInstanceOf(Store\SQL::class, $store); } @@ -49,8 +50,8 @@ class SQLTest extends TestCase */ public function kvstoreTableVersion(): void { - /** @var \SimpleSAML\Store\SQL $store */ - $store = Store::getInstance(); + /** @var \SimpleSAML\Store\SQLStore $store */ + $store = StoreFactory::getInstance(); $version = $store->getTableVersion('kvstore'); @@ -63,8 +64,8 @@ class SQLTest extends TestCase */ public function newTableVersion(): void { - /** @var \SimpleSAML\Store\SQL $store */ - $store = Store::getInstance(); + /** @var \SimpleSAML\Store\SQLStore $store */ + $store = StoreFactory::getInstance(); $version = $store->getTableVersion('test'); @@ -77,8 +78,8 @@ class SQLTest extends TestCase */ public function testSetTableVersion(): void { - /** @var \SimpleSAML\Store\SQL $store */ - $store = Store::getInstance(); + /** @var \SimpleSAML\Store\SQLStore $store */ + $store = StoreFactory::getInstance(); $store->setTableVersion('kvstore', 2); $version = $store->getTableVersion('kvstore'); @@ -92,8 +93,8 @@ class SQLTest extends TestCase */ public function testGetEmptyData(): void { - /** @var \SimpleSAML\Store\SQL $store */ - $store = Store::getInstance(); + /** @var \SimpleSAML\Store\SQLStore $store */ + $store = StoreFactory::getInstance(); $value = $store->get('test', 'foo'); @@ -106,8 +107,8 @@ class SQLTest extends TestCase */ public function testInsertData(): void { - /** @var \SimpleSAML\Store\SQL $store */ - $store = Store::getInstance(); + /** @var \SimpleSAML\Store\SQLStore $store */ + $store = StoreFactory::getInstance(); $store->set('test', 'foo', 'bar'); $value = $store->get('test', 'foo'); @@ -121,8 +122,8 @@ class SQLTest extends TestCase */ public function testOverwriteData(): void { - /** @var \SimpleSAML\Store\SQL $store */ - $store = Store::getInstance(); + /** @var \SimpleSAML\Store\SQLStore $store */ + $store = StoreFactory::getInstance(); $store->set('test', 'foo', 'bar'); $store->set('test', 'foo', 'baz'); @@ -137,8 +138,8 @@ class SQLTest extends TestCase */ public function testDeleteData(): void { - /** @var \SimpleSAML\Store\SQL $store */ - $store = Store::getInstance(); + /** @var \SimpleSAML\Store\SQLStore $store */ + $store = StoreFactory::getInstance(); $store->set('test', 'foo', 'bar'); $store->delete('test', 'foo'); @@ -153,8 +154,8 @@ class SQLTest extends TestCase */ public function testVeryLongKey(): void { - /** @var \SimpleSAML\Store\SQL $store */ - $store = Store::getInstance(); + /** @var \SimpleSAML\Store\SQLStore $store */ + $store = StoreFactory::getInstance(); $key = str_repeat('x', 100); $store->set('test', $key, 'bar'); @@ -171,16 +172,16 @@ class SQLTest extends TestCase { $config = Configuration::getInstance(); - /** @var \SimpleSAML\Store\SQL $store */ - $store = Store::getInstance(); + /** @var \SimpleSAML\Store\SQLStore $store */ + $store = StoreFactory::getInstance(); $this->clearInstance($config, Configuration::class); - $this->clearInstance($store, Store::class); +// $this->clearInstance($store, Store\SQL::class); } /** - * @param \SimpleSAML\Configuration|\SimpleSAML\Store $service + * @param \SimpleSAML\Configuration|\SimpleSAML\Store\StoreInterface $service * @param class-string $className */ protected function clearInstance($service, string $className): void diff --git a/tests/lib/SimpleSAML/StoreTest.php b/tests/lib/SimpleSAML/StoreTest.php index 8f278eb6e008c519ea35ff33d5270410316c208d..967bec43a8bb3155c931003ddd1c6dded33fb3ec 100644 --- a/tests/lib/SimpleSAML/StoreTest.php +++ b/tests/lib/SimpleSAML/StoreTest.php @@ -9,15 +9,15 @@ use ReflectionClass; use SimpleSAML\Configuration; use SimpleSAML\Error\CriticalConfigurationError; use SimpleSAML\Store; +use SimpleSAML\Store\StoreFactory; /** - * Tests for the Store abstract class. + * Tests for the StoreFactory class. * * For the full copyright and license information, please view the LICENSE file that was * distributed with this source code. * - * @covers \SimpleSAML\Store - * + * @covers \SimpleSAML\Store\StoreFactory * @package simplesamlphp/simplesamlphp */ class StoreTest extends TestCase @@ -30,7 +30,7 @@ class StoreTest extends TestCase Configuration::loadFromArray([], '[ARRAY]', 'simplesaml'); /** @var false $store */ - $store = Store::getInstance(); + $store = StoreFactory::getInstance(); $this->assertFalse($store); } @@ -44,7 +44,7 @@ class StoreTest extends TestCase Configuration::loadFromArray([], '[ARRAY]', 'simplesaml'); /** @var false $store */ - $store = Store::getInstance(); + $store = StoreFactory::getInstance(); $this->assertFalse($store); } @@ -59,9 +59,9 @@ class StoreTest extends TestCase 'store.type' => 'memcache', ], '[ARRAY]', 'simplesaml'); - $store = Store::getInstance(); + $store = StoreFactory::getInstance(); - $this->assertInstanceOf(Store\Memcache::class, $store); + $this->assertInstanceOf(Store\MemcacheStore::class, $store); } @@ -76,9 +76,9 @@ class StoreTest extends TestCase 'store.sql.prefix' => 'phpunit_', ], '[ARRAY]', 'simplesaml'); - $store = Store::getInstance(); + $store = StoreFactory::getInstance(); - $this->assertInstanceOf(Store\SQL::class, $store); + $this->assertInstanceOf(Store\SQLStore::class, $store); } @@ -88,14 +88,14 @@ class StoreTest extends TestCase public function pathStore(): void { Configuration::loadFromArray([ - 'store.type' => '\SimpleSAML\Store\SQL', + 'store.type' => '\SimpleSAML\Store\SQLStore', 'store.sql.dsn' => 'sqlite::memory:', 'store.sql.prefix' => 'phpunit_', ], '[ARRAY]', 'simplesaml'); - $store = Store::getInstance(); + $store = StoreFactory::getInstance(); - $this->assertInstanceOf(Store\SQL::class, $store); + $this->assertInstanceOf(Store\SQLStore::class, $store); } @@ -111,7 +111,7 @@ class StoreTest extends TestCase 'store.sql.prefix' => 'phpunit_', ], '[ARRAY]', 'simplesaml'); - Store::getInstance(); + StoreFactory::getInstance(); } @@ -120,16 +120,15 @@ class StoreTest extends TestCase protected function tearDown(): void { $config = Configuration::getInstance(); - /** @var \SimpleSAML\Store $store */ - $store = Store::getInstance(); + /** @var \SimpleSAML\Store\StoreInterface $store */ + $store = StoreFactory::getInstance(); $this->clearInstance($config, Configuration::class); - $this->clearInstance($store, Store::class); } /** - * @param \SimpleSAML\Configuration|\SimpleSAML\Store $service + * @param \SimpleSAML\Configuration|\SimpleSAML\Store\StoreInterface $service * @param class-string $className */ protected function clearInstance($service, string $className): void diff --git a/tests/modules/saml/lib/IdP/SQLNameIDTest.php b/tests/modules/saml/lib/IdP/SQLNameIDTest.php index e33bd604e99d487a7202c8728a0aa8aa76b24ce7..c2c849ee29ad52a75a70e22438830851e41f6fcc 100644 --- a/tests/modules/saml/lib/IdP/SQLNameIDTest.php +++ b/tests/modules/saml/lib/IdP/SQLNameIDTest.php @@ -10,6 +10,7 @@ use SimpleSAML\Configuration; use SimpleSAML\Error; use SimpleSAML\Module\saml\IdP\SQLNameID; use SimpleSAML\Store; +use SimpleSAML\Store\StoreFactory; /** * Test for the SQLNameID helper class. @@ -45,10 +46,10 @@ class SQLNameIDTest extends TestCase ], '[ARRAY]', 'simplesaml'); $this->addGetDelete(); $config = Configuration::getInstance(); - /** @var \SimpleSAML\Store $store */ - $store = Store::getInstance(); + /** @var \SimpleSAML\Store\StoreInterface $store */ + $store = StoreFactory::getInstance(); $this->clearInstance($config, Configuration::class); - $this->clearInstance($store, Store::class); + $this->clearInstance($store, Store\SQLStore::class); } @@ -61,15 +62,15 @@ class SQLNameIDTest extends TestCase Configuration::loadFromArray([ 'store.type' => 'memcache', ], '[ARRAY]', 'simplesaml'); - $store = Store::getInstance(); - $this->assertInstanceOf(Store\Memcache::class, $store); + $store = StoreFactory::getInstance(); + $this->assertInstanceOf(Store\MemcacheStote::class, $store); $this->expectException(Error\Exception::class); $this->addGetDelete(); $config = Configuration::getInstance(); - /** @var \SimpleSAML\Store $store */ + /** @var \SimpleSAML\Store\StoreInterface $store */ $store = Store::getInstance(); $this->clearInstance($config, Configuration::class); - $this->clearInstance($store, Store::class); + $this->clearInstance($store, Store\MemcacheStore::class); } @@ -98,7 +99,7 @@ class SQLNameIDTest extends TestCase /** - * @param \SimpleSAML\Configuration|\SimpleSAML\Store $service + * @param \SimpleSAML\Configuration|\SimpleSAML\Store\StoreInterface $service * @param class-string $className */ protected function clearInstance($service, string $className): void