/** * Sets up the fixture, for example, opens a network connection. * This method is called before a test is executed. * * @access protected */ protected function setUp() { $this->object = new CryptoQuery(); $this->confObj = new Conf(); $keyFilePath = ROOT_PATH . '/lib/confs/cryptokeys/key.ohrm'; if (!file_exists($keyFilePath)) { $this->keyFileExists = false; // Means a key file has not been been created at the installer KeyHandler::createKey(); } }
/** * @todo Implement testDeleteKey(). */ public function testDeleteKey() { // When key is not available try { KeyHandler::deleteKey(); } catch (Exception $e) { $this->assertEquals(KeyHandlerException::KEY_DOES_NOT_EXIST, $e->getCode()); } // When key is existing $filePath = ROOT_PATH . '/lib/confs/cryptokeys/key.ohrm'; $this->assertTrue(KeyHandler::createKey()); $this->assertTrue(KeyHandler::deleteKey()); $this->assertFalse(file_exists($filePath)); // When key is existing, but cannot be deleted $this->assertTrue(KeyHandler::createKey()); system("chmod 000 {$filePath}"); try { KeyHandler::deleteKey(); } catch (Exception $e) { $this->assertEquals(KeyHandlerException::KEY_DELETION_FAILIURE, $e->getCode()); } }