public function tearDown() { // Remove / clear test database $db = phpillowConnection::getInstance(); try { $db->delete('/test'); } catch (phpillowResponseNotFoundErrorException $e) { /* Ignore */ } phpillowConnectionTestHelper::reset(); }
public function testGetNonExistentConnection() { // To be dependant from test which has been run earlier phpillowConnectionTestHelper::reset(); try { phpillowConnection::getInstance(); $this->fail('Expected phpillowConnectionException.'); } catch (phpillowConnectionException $e) { /* Expected exception */ } }
/** * Reset database depending on provided options * * @param array $options * @return void */ public static function resetDatabase(array $options = array()) { phpillowConnectionTestHelper::reset(); // Initialize wanted connection handler $handler = isset($options['handler']) ? $options['handler'] : 'phpillowConnection'; call_user_func(array($handler, 'createInstance')); $db = phpillowConnection::getInstance(); try { $db->delete('/test'); } catch (Exception $e) { /* Ignored */ } if (isset($options['database'])) { // Create test database phpillowConnection::setDatabase($options['database']); $db = phpillowConnection::getInstance(); $db->put('/' . $options['database']); } else { // Reset all connection settings in the end phpillowConnectionTestHelper::reset(); } }
public static function reset() { self::$instance = null; self::$database = null; }
public function testDeleteDocumentMultipleRevisions() { phpillowConnection::createInstance(); phpillowConnection::setDatabase('test'); // Create test database $db = phpillowConnection::getInstance(); $db->put('/test'); // Add document to fetch $author = phpillowManager::createDocument('user'); $author->login = '******'; $author->save(); $doc = phpillowManager::fetchDocument('user', 'user-kore'); $doc->name = 'Kore'; $doc->save(); // Test delete phpillowManager::deleteDocument('user', 'user-kore'); try { $user = phpillowManager::fetchDocument('user', 'user-kore'); $this->fail('Expected phpillowResponseNotFoundErrorException.'); } catch (phpillowResponseNotFoundErrorException $e) { /* Expected exception */ } // Remove / clear test database $db = phpillowConnection::getInstance(); $db->delete('/test'); phpillowConnectionTestHelper::reset(); }