/** * 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 KeyHandlerOld::createKey(); } }
/** * @todo Implement testDeleteKey(). */ public function testDeleteKey() { // When key is not available try { KeyHandlerOld::deleteKey(); } catch (Exception $e) { $this->assertEquals(KeyHandlerOldException::KEY_DOES_NOT_EXIST, $e->getCode()); } // When key is existing $filePath = ROOT_PATH . '/lib/confs/cryptokeys/key.ohrm'; $this->assertTrue(KeyHandlerOld::createKey()); $this->assertTrue(KeyHandlerOld::deleteKey()); $this->assertFalse(file_exists($filePath)); // When key is existing, but cannot be deleted $this->assertTrue(KeyHandlerOld::createKey()); system("chmod 000 {$filePath}"); try { KeyHandlerOld::deleteKey(); } catch (Exception $e) { $this->assertEquals(KeyHandlerOldException::KEY_DELETION_FAILIURE, $e->getCode()); } }