예제 #1
0
 public function testOnlyInstatiatedOnce()
 {
     I18n::setLocale('en');
     $this->setExpectedException('RuntimeException', 'Class ' . get_class(I18n::getInstance()) . ' already initialized');
     $newI18n = new I18n();
 }
예제 #2
0
파일: Juriya.php 프로젝트: nurcahyo/juriya
 /**
  * Framework instantiation
  *
  * @param  array  Framework configuration
  * @return void
  * @throws object RuntimeException
  */
 public function __construct($config = array())
 {
     // Main framework instance only instantiated once
     if (is_null(static::$instance)) {
         // Get configuration value and set main properties
         foreach (array('modules', 'packages', 'routes') as $property) {
             if (isset($config[$property]) && $config[$property] instanceof Collection) {
                 ${$property} = $config[$property];
             } else {
                 ${$property} = new Collection();
             }
         }
         $this->modules = $modules;
         $this->packages = $packages;
         $this->routes = $routes;
         static::$instance = $this;
         // Framework depedency packages
         // @codeCoverageIgnoreStart
         if (PEAR_INSTALLED) {
             $this->registerPearPackage('Symfony');
             $this->registerPearPackage('PHPUnit');
         } else {
             $this->registerPearPackage('Symfony', TRUE);
             $this->registerPearPackage('PHPUnit', TRUE);
         }
         // @codeCoverageIgnoreEnd
         $locale = I18n::getInstance()->setLocale('en');
     } else {
         throw new \RuntimeException(I18n::translate('class_already_initialized', __CLASS__));
     }
 }