public function testCreate() { $config = new Config(); $context = new Context(null, $config); $this->assertNull($context->getHomeDirectory()); $this->assertSame($config, $context->getConfig()); $this->assertNull($context->getConfigFile()); $this->assertInstanceOf('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface', $context->getEventDispatcher()); }
/** * Starts the service container. */ public function start() { if ($this->started) { throw new LogicException('Puli is already started'); } if (null !== $this->rootDir) { $this->context = $this->createProjectContext($this->rootDir, $this->env); $bootstrapFile = $this->context->getConfig()->get(Config::BOOTSTRAP_FILE); // Run the project's bootstrap file to enable project-specific // autoloading if (null !== $bootstrapFile) { // Backup autoload functions of the PHAR $autoloadFunctions = spl_autoload_functions(); foreach ($autoloadFunctions as $autoloadFunction) { spl_autoload_unregister($autoloadFunction); } // Add project-specific autoload functions require_once Path::makeAbsolute($bootstrapFile, $this->rootDir); // Prepend autoload functions of the PHAR again // This is needed if the user specific autoload functions were // added with $prepend=true (as done by Composer) // Classes in the PHAR should always take precedence for ($i = count($autoloadFunctions) - 1; $i >= 0; --$i) { spl_autoload_register($autoloadFunctions[$i], true, true); } } } else { $this->context = $this->createGlobalContext(); } $this->dispatcher = $this->context->getEventDispatcher(); $this->started = true; // Start plugins once the container is running if ($this->rootDir && $this->pluginsEnabled) { $this->activatePlugins(); } }
/** * Starts the service container. */ public function start() { if ($this->started) { throw new LogicException('Puli is already started'); } if ($this->rootDir) { $this->context = $this->createProjectContext($this->rootDir, $this->env); $bootstrapFile = $this->context->getConfig()->get(Config::BOOTSTRAP_FILE); // Run the project's bootstrap file to enable project-specific // autoloading if (null !== $bootstrapFile) { require_once Path::makeAbsolute($bootstrapFile, $this->rootDir); } } else { $this->context = $this->createGlobalContext(); } $this->dispatcher = $this->context->getEventDispatcher(); $this->started = true; // Start plugins once the container is running if ($this->rootDir && $this->pluginsEnabled) { $this->activatePlugins(); } }