예제 #1
0
 /**
  * Create MySQL databases, users and grant permissions.
  */
 public function createDatabases()
 {
     /** @var $dbs MysqlDatabase[] */
     $dbs = $this->_getRepository()->findAll();
     foreach ($dbs as $db) {
         $userModel = new MysqlUserModel();
         $userModel->setUsername($db->getName())->setPassword($this->_cryptservice->decrypt($db->getPassword()));
         $dbModel = new MysqlDatabaseModel();
         $dbModel->setName($db->getName())->setUsers(array($userModel));
         if ($this->_mysqladmin->checkUserExists($userModel)) {
             $this->_mysqladmin->setUserPassword($userModel);
         } else {
             $this->_mysqladmin->createUser($userModel);
         }
         if (!$this->_mysqladmin->checkDatabaseExists($dbModel)) {
             $this->_mysqladmin->createDatabase($dbModel);
             $this->_mysqladmin->grantPermissionsOnDatabase($dbModel);
         }
     }
 }
예제 #2
0
 /**
  * Expect exception on invalid decrypted data.
  *
  * @expectedException \Jeboehm\Lampcp\CoreBundle\Exception\WrongEncryptionKeyException
  */
 public function testDecryptFailure()
 {
     $this->_cs->decrypt(rand(0, 9999));
 }