diff options
Diffstat (limited to 'tests/lib/SimpleSAML/StoreTest.php')
-rw-r--r-- | tests/lib/SimpleSAML/StoreTest.php | 68 |
1 files changed, 40 insertions, 28 deletions
diff --git a/tests/lib/SimpleSAML/StoreTest.php b/tests/lib/SimpleSAML/StoreTest.php index 2165bb4..6fd9650 100644 --- a/tests/lib/SimpleSAML/StoreTest.php +++ b/tests/lib/SimpleSAML/StoreTest.php @@ -1,14 +1,19 @@ <?php -/* - * This file is part of the sgomezsimplesamlphp. + +namespace SimpleSAML\Test; + +use \SimpleSAML_Configuration as Configuration; +use \SimpleSAML\Store; + +/** + * Tests for the Store abstract class. * - * (c) Sergio Gómez <sergio@uco.es> + * For the full copyright and license information, please view the LICENSE file that was distributed with this source + * code. * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. + * @author Sergio Gómez <sergio@uco.es> + * @package simplesamlphp/simplesamlphp */ - - class StoreTest extends \PHPUnit_Framework_TestCase { /** @@ -17,108 +22,115 @@ class StoreTest extends \PHPUnit_Framework_TestCase */ public function defaultStore() { - \SimpleSAML_Configuration::loadFromArray(array( + Configuration::loadFromArray(array( ), '[ARRAY]', 'simplesaml'); - $store = \SimpleSAML\Store::getInstance(); + $store = Store::getInstance(); $this->assertEquals(false, $store); } + /** * @covers \SimpleSAML\Store::getInstance * @test */ public function phpSessionStore() { - \SimpleSAML_Configuration::loadFromArray(array( + Configuration::loadFromArray(array( ), '[ARRAY]', 'simplesaml'); - $store = \SimpleSAML\Store::getInstance(); + $store = Store::getInstance(); $this->assertEquals(false, $store); } + /** * @covers \SimpleSAML\Store::getInstance * @test */ public function memcacheStore() { - \SimpleSAML_Configuration::loadFromArray(array( + Configuration::loadFromArray(array( 'store.type' => 'memcache', ), '[ARRAY]', 'simplesaml'); - $store = \SimpleSAML\Store::getInstance(); + $store = Store::getInstance(); $this->assertInstanceOf('\SimpleSAML\Store\Memcache', $store); } + /** - * @covers SimpleSAML\Store::getInstance + * @covers \SimpleSAML\Store::getInstance * @test */ public function sqlStore() { - \SimpleSAML_Configuration::loadFromArray(array( + Configuration::loadFromArray(array( 'store.type' => 'sql', 'store.sql.dsn' => 'sqlite::memory:', 'store.sql.prefix' => 'phpunit_', ), '[ARRAY]', 'simplesaml'); - $store = \SimpleSAML\Store::getInstance(); + $store = Store::getInstance(); $this->assertInstanceOf('SimpleSAML\Store\SQL', $store); } + /** - * @covers SimpleSAML\Store::getInstance + * @covers \SimpleSAML\Store::getInstance * @test */ public function pathStore() { - \SimpleSAML_Configuration::loadFromArray(array( + Configuration::loadFromArray(array( 'store.type' => '\SimpleSAML\Store\SQL', 'store.sql.dsn' => 'sqlite::memory:', 'store.sql.prefix' => 'phpunit_', ), '[ARRAY]', 'simplesaml'); - $store = \SimpleSAML\Store::getInstance(); + $store = Store::getInstance(); $this->assertInstanceOf('SimpleSAML\Store\SQL', $store); } + /** - * @covers SimpleSAML\Store::getInstance - * @expectedException SimpleSAML\Error\CriticalConfigurationError + * @covers \SimpleSAML\Store::getInstance + * @expectedException \SimpleSAML\Error\CriticalConfigurationError * @test */ public function notFoundStoreException() { - \SimpleSAML_Configuration::loadFromArray(array( + Configuration::loadFromArray(array( 'store.type' => '\Test\SimpleSAML\Store\Dummy', 'store.sql.dsn' => 'sqlite::memory:', 'store.sql.prefix' => 'phpunit_', ), '[ARRAY]', 'simplesaml'); - $store = \SimpleSAML\Store::getInstance(); + Store::getInstance(); } - + + protected function tearDown() { - $config = SimpleSAML_Configuration::getInstance(); - $store = \SimpleSAML\Store::getInstance(); + $config = Configuration::getInstance(); + $store = Store::getInstance(); $this->clearInstance($config, '\SimpleSAML_Configuration'); $this->clearInstance($store, '\SimpleSAML\Store'); } + protected function clearInstance($service, $className) { - $reflectedClass = new ReflectionClass($className); + $reflectedClass = new \ReflectionClass($className); $reflectedInstance = $reflectedClass->getProperty('instance'); $reflectedInstance->setAccessible(true); $reflectedInstance->setValue($service, null); $reflectedInstance->setAccessible(false); } -}
\ No newline at end of file +} |