Esempio n. 1
0
 public function getFilename()
 {
     if (!$this->id) {
         throw new InvalidArgumentException('Can not generate filename without id property.');
     }
     return Application_Model_EnvironmentPeer::generateFilenameForEnvId($this->id);
 }
Esempio n. 2
0
 public function putAction()
 {
     $regex = $this->getInvokeArg('bootstrap')->getOption('paramregex');
     if (preg_match($regex['envid'], $this->_getParam('id')) === 0) {
         throw new Exception('Illegal Environment Id.');
     }
     $id = $this->_getParam('id');
     $environment = Application_Model_EnvironmentPeer::getEnvironmentFromJsonFile('php://input');
     $content = $environment->content;
     $envConfig = $this->getInvokeArg('bootstrap')->getOption('environment');
     if (is_array($envConfig) && array_key_exists('addUsernameFromEnv', $envConfig)) {
         if ($envConfig['addUsernameFromEnv'] != '' && getenv($envConfig['addUsernameFromEnv']) != '') {
             if ($environment->by != getenv($envConfig['addUsernameFromEnv'])) {
                 $environment->by .= ' (' . getenv($envConfig['addUsernameFromEnv']) . ')';
             }
         }
     }
     $environment->save();
     $data = $this->getEmptyResult();
     $environment = Application_Model_EnvironmentPeer::getEnvironment($id);
     $environment->content = $content;
     $data['results'] = $environment;
     $this->getResponse()->setBody(json_encode($data));
     $this->getResponse()->setHttpResponseCode(200);
 }
Esempio n. 3
0
 public function testGetAllEnvironments()
 {
     $envs = Application_Model_EnvironmentPeer::getAllEnvironments();
     $this->assertEquals(array($this->expected01, $this->expected02, $this->expected03, $this->expected04), $envs);
 }