Ejemplo n.º 1
0
 protected function _getDb()
 {
     if (!$this->_db) {
         $this->_db = App::getMongoDB();
     }
     return $this->_db;
 }
Ejemplo n.º 2
0
 function initZend()
 {
     // Use ZF autoloader
     require_once 'Zend/Loader/Autoloader.php';
     Zend_Loader_Autoloader::getInstance();
     // Create application, bootstrap, and run
     $application = new Zend_Application(APPLICATION_ENV, APPLICATION_PATH . '/configs/application.ini');
     // Get the application factories helper
     require_once APPLICATION_PATH . '/App.php';
     App::init($application);
     $application->bootstrap();
     // Hack: Inject the bootstrap in the front controller instance to
     //       make the Zend_Application resources available to the Service layer
     $bootstrap = $application->getBootstrap();
     Zend_Controller_Front::getInstance()->setParam('bootstrap', $bootstrap);
     if (getenv('PHPUNIT_NOCLEAN') != 1) {
         // Dropping the database and loading the initial fixtures
         echo "Please, be patient. Loading fixtures in " . APPLICATION_ENV . " database. This may take some seconds...\n";
         $mongo = \App::getMongoDB();
         $mongo->drop();
         exec("APPLICATION_DB_PREFIX=\"" . APPLICATION_DB_PREFIX . "\" php " . APPLICATION_SCRIPTS_PATH . "/update.php --env " . APPLICATION_ENV);
         exec("APPLICATION_DB_PREFIX=\"" . APPLICATION_DB_PREFIX . "\" php " . APPLICATION_SCRIPTS_PATH . "/aclLoader.php --env testing --drop ");
         // Remove slots in fixtures, avoiding problems with indexes
         $mongo->steering->remove(array('resId' => array('$in' => array(15, 69))), array('justOne' => false));
         exec("APPLICATION_DB_PREFIX=\"" . APPLICATION_DB_PREFIX . "\" php " . APPLICATION_SCRIPTS_PATH . "/load.mongodb.php --env " . APPLICATION_ENV);
         exec("APPLICATION_DB_PREFIX=\"" . APPLICATION_DB_PREFIX . "\" php " . APPLICATION_SCRIPTS_PATH . "/load.brands.php --env " . APPLICATION_ENV);
     }
 }
 public function setUp()
 {
     $this->_db = App::getMongoDB();
     $this->_templateService = \Application\Service\TemplateService::getInstance();
     $this->_oldTariffTemplate = json_decode('{"_id":"4f0ef97096d52f505d000000","currency":"978","data":[],"defaultData":{"pool":false,"t6Q":"500","t6N":"1"},"defaultOrigVoice":{"pool":false,"t2N":"60","t2S":"100","t2Q":"100"},"defaultSms":{"pool":false,"t2N":"1","t2Q":"100"},"defaultTermVoice":{"pool":false,"t2N":"180","t2S":"300","t2Q":"300"},"description":"","modified":false,"name":"Zdef2D","organizationId":"provider-4ddd31cd0e49ad4073000002","origVoice":[{"pool":false,"t2N":"120","t2S":"200","t2Q":"200","zoneId":"-1","destinationId":"2"},{"pool":false,"t2N":"240","t2S":"400","t2Q":"400","zoneId":"2","destinationId":"-1"}],"sms":[{"pool":false,"t2N":"1","t2Q":"300","zoneId":"-1","destinationId":"3"},{"pool":false,"t2N":"1","t2Q":"400","zoneId":"2","destinationId":"-1"}],"termVoice":[{"pool":false,"t2N":"180","t2S":"300","t2Q":"300","zoneId":"2"}],"type":"tariffPlanService"}', true);
     $this->_db->templates->insert($this->_oldTariffTemplate);
 }
Ejemplo n.º 4
0
 public function getCollection()
 {
     static $collection;
     if (!isset($collection)) {
         $collection = new MongoCollection(\App::getMongoDB(), 'org_mock');
     }
     return $collection;
 }
 /**
  * List all MongoDB collections
  *
  * @param  string            $prefix Optional prefix matching
  * @return MongoCollection[]
  */
 public static function getCollections($prefix = null, $removePrefix = false)
 {
     $collections = \App::getMongoDB()->listCollections();
     $result = array();
     foreach ($collections as $k => $collection) {
         $name = $collection->getName();
         if (!$prefix || ($pos = strpos($name, $prefix)) === 0) {
             if ($removePrefix) {
                 $name = substr($name, strlen($prefix));
             }
             $result[] = $name;
         }
     }
     return $result;
 }
Ejemplo n.º 6
0
 /**
  * Run query and returns matches, or null if no matches are found.
  *
  * @param  String $value
  * @return Array  when matches are found.
  */
 protected function _query($value, $extraAttr = array())
 {
     $coll = App::getMongoDB()->selectCollection($this->getCollection());
     $doc = array($this->getAttribute() => $value) + $this->getDefaultAttributes() + $extraAttr;
     // Run query
     $result = $coll->findOne($doc);
     return $result ? true : false;
 }
Ejemplo n.º 7
0
 /**
  *
  * @param  type                     $userId
  * @return type
  * @throws InvalidArgumentException
  * @throws MongoException
  */
 public function getLastUsedPasswords($userId)
 {
     if (!$userId) {
         throw new InvalidArgumentException(get_class($this) . ": userId param not given <<");
     }
     try {
         $collection = new \MongoCollection(\App::getMongoDB(), 'user_password');
         $result = $collection->findOne(array('_id' => $userId));
         $result = $result ? parent::_mapMongoModelToModel($result) : array();
     } catch (\Exception $e) {
         throw new MongoException($e->getMessage());
     }
     return isset($result['passwords']) ? $result['passwords'] : array();
 }