コード例 #1
0
ファイル: Metadata.php プロジェクト: patrickpreuss/Braintacle
 /**
  * Set attributes from given package
  *
  * Attributes are populated with values from the given package and
  * hardcoded defaults.
  *
  * @param array $data Package data
  */
 public function setPackageData($data)
 {
     $node = $this->createElement('DOWNLOAD');
     $node->setAttribute('ID', $data['Id']);
     $node->setAttribute('PRI', $data['Priority']);
     $node->setAttribute('ACT', strtoupper($data['DeployAction']));
     $node->setAttribute('DIGEST', $data['Hash']);
     $node->setAttribute('PROTO', 'HTTP');
     $node->setAttribute('FRAGS', $data['NumFragments']);
     $node->setAttribute('DIGEST_ALGO', 'SHA1');
     $node->setAttribute('DIGEST_ENCODE', 'Hexa');
     $node->setAttribute('PATH', $data['DeployAction'] == 'store' ? $data['ActionParam'] : '');
     $node->setAttribute('NAME', $data['DeployAction'] == 'launch' ? $data['ActionParam'] : '');
     $node->setAttribute('COMMAND', $data['DeployAction'] == 'execute' ? $data['ActionParam'] : '');
     $node->setAttribute('NOTIFY_USER', $data['Warn'] ? '1' : '0');
     $node->setAttribute('NOTIFY_TEXT', $this->_escapeMessage($data['WarnMessage']));
     $node->setAttribute('NOTIFY_COUNTDOWN', $data['WarnCountdown']);
     $node->setAttribute('NOTIFY_CAN_ABORT', $data['WarnAllowAbort'] ? '1' : '0');
     $node->setAttribute('NOTIFY_CAN_DELAY', $data['WarnAllowDelay'] ? '1' : '0');
     $node->setAttribute('NEED_DONE_ACTION', $data['PostInstMessage'] ? '1' : '0');
     $node->setAttribute('NEED_DONE_ACTION_TEXT', $this->_escapeMessage($data['PostInstMessage']));
     $node->setAttribute('GARDEFOU', 'rien');
     if ($this->hasChildNodes()) {
         $this->replaceChild($node, $this->firstChild);
     } else {
         $this->appendChild($node);
     }
     if (!\Library\Application::isProduction()) {
         $this->forceValid();
     }
 }
コード例 #2
0
 /**
  * Tests for environment detection methods
  * 
  * The tests cover getEnvironment(), isProduction(), isDevelopment() and
  * isTest() with all relevant values for the APPLICATION_ENV environment
  * variable.
  */
 public function testEnvironment()
 {
     // Assume that the tests have been invoked with APPLICATION_ENV set to
     // "test". Otherwise the tests might be incomplete.
     $this->assertEquals('test', getenv('APPLICATION_ENV'));
     $this->assertEquals('test', Application::getEnvironment());
     $this->assertFalse(Application::isProduction());
     $this->assertTrue(Application::isDevelopment());
     $this->assertTrue(Application::isTest());
     // Unset APPLICATION_ENV, equivalent to "production"
     putenv('APPLICATION_ENV');
     $this->assertEquals('production', Application::getEnvironment());
     $this->assertTrue(Application::isProduction());
     $this->assertFalse(Application::isDevelopment());
     $this->assertFalse(Application::isTest());
     // Test "development" environment
     putenv('APPLICATION_ENV=development');
     $this->assertEquals('development', Application::getEnvironment());
     $this->assertFalse(Application::isProduction());
     $this->assertTrue(Application::isDevelopment());
     $this->assertFalse(Application::isTest());
     // Test invalid environment. Ensure that the variable is reset to its
     // default in either case.
     putenv('APPLICATION_ENV=invalid');
     try {
         Application::getEnvironment();
     } catch (\DomainException $expected) {
         $invalidEnvironmmentDetected = true;
     }
     // Reset to default.
     putenv('APPLICATION_ENV=test');
     if (!isset($invalidEnvironmmentDetected)) {
         $this->fail('Invalid environment was undetected.');
     }
 }
コード例 #3
0
ファイル: index.php プロジェクト: patrickpreuss/Braintacle
/**
 * All interaction with the user agent starts with this script.
 *
 * Copyright (C) 2011-2015 Holger Schletz <*****@*****.**>
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the Free
 * Software Foundation; either version 2 of the License, or (at your option)
 * any later version.
 *
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
 * more details.
 *
 * You should have received a copy of the GNU General Public License along with
 * this program; if not, write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */
// Set up PHP environment. The error configuration is done as early as possible.
error_reporting(-1);
require_once '../module/Library/Application.php';
if (\Library\Application::isProduction()) {
    ini_set('display_errors', false);
    ini_set('display_startup_errors', false);
} else {
    ini_set('display_errors', true);
    ini_set('display_startup_errors', true);
}
\Library\Application::init('Console');