Exemplo n.º 1
0
 /**
  * It should automatically switch to the travis logger if the
  * CONTINUOUS_INTEGRATION environment variable is set.
  */
 public function testTravisLogger()
 {
     putenv('CONTINUOUS_INTEGRATION=1');
     $container = new Container(['PhpBench\\Extension\\CoreExtension'], ['path' => 'hello', 'config_path' => '/path/to/phpbench.json']);
     $container->init();
     $this->assertEquals('travis', $container->getParameter('progress'));
 }
Exemplo n.º 2
0
 public function load(Container $container)
 {
     if (!class_exists(Version::class)) {
         throw new \RuntimeException('The DBAL extension requires the "doctrine/dbal" package. Run `composer require --dev "doctrine/dbal"`');
     }
     $container->register('storage.driver.dbal.connection', function (Container $container) {
         static $connection;
         if ($connection) {
             return $connection;
         }
         $params = $container->getParameter('storage.dbal.connection');
         if (isset($params['path'])) {
             $params['path'] = PhpBench::normalizePath($params['path']);
         }
         $connection = DriverManager::getConnection($params);
         return $connection;
     });
     $container->register('storage.driver.dbal.connection_manager', function (Container $container) {
         return new Storage\Driver\Dbal\ConnectionManager($container->get('storage.driver.dbal.connection'));
     });
     $container->register('storage.driver.dbal', function (Container $container) {
         return new Storage\Driver\DbalDriver($container->get('storage.driver.dbal.loader'), $container->get('storage.driver.dbal.persister'), $container->get('storage.driver.dbal.repository'));
     }, ['storage_driver' => ['name' => 'dbal']]);
     $container->register('storage.driver.dbal.persister', function (Container $container) {
         return new Storage\Driver\Dbal\Persister($container->get('storage.driver.dbal.connection_manager'));
     });
     $container->register('storage.driver.dbal.loader', function (Container $container) {
         return new Storage\Driver\Dbal\Loader($container->get('storage.driver.dbal.repository'));
     });
     $container->register('storage.driver.dbal.visitor.token_value', function (Container $container) {
         return new Storage\Driver\Dbal\Visitor\TokenValueVisitor($container->get('storage.uuid_resolver'));
     });
     $container->register('storage.driver.dbal.repository', function (Container $container) {
         return new Storage\Driver\Dbal\Repository($container->get('storage.driver.dbal.connection_manager'), $container->get('storage.driver.dbal.visitor.token_value'));
     });
     $container->register('command.dbal.migrate', function (Container $container) {
         return new MigrateCommand($container->get('storage.driver.dbal.connection'));
     }, ['console.command' => []]);
 }
Exemplo n.º 3
0
 public function load(Container $container)
 {
     $container->register('xdebug.command.profile', function (Container $container) {
         return new ProfileCommand($container->get('console.command.handler.runner'), $container->get('xdebug.command.handler.output_dir'));
     }, ['console.command' => []]);
     $container->register('xdebug.command.trace', function (Container $container) {
         return new TraceCommand($container->get('console.command.handler.runner'), $container->get('xdebug.renderer.trace'), $container->get('xdebug.command.handler.output_dir'));
     }, ['console.command' => []]);
     $container->register('xdebug.command.handler.output_dir', function (Container $container) {
         return new OutputDirHandler($container->getParameter('xdebug.output_dir'));
     });
     $container->register('benchmark.executor.xdebug_profile', function (Container $container) {
         return new ProfileExecutor($container->get('benchmark.remote.launcher'));
     }, ['benchmark_executor' => ['name' => 'xdebug_profile']]);
     $container->register('xdebug.executor.xdebug_trace', function (Container $container) {
         return new TraceExecutor($container->get('benchmark.remote.launcher'));
     }, ['benchmark_executor' => ['name' => 'xdebug_trace']]);
     $container->register('xdebug.renderer.trace', function (Container $container) {
         return new TraceRenderer($container->get('phpbench.formatter'));
     });
     $container->mergeParameter('executors', require_once __DIR__ . '/config/executors.php');
     $container->mergeParameter('reports', require_once __DIR__ . '/config/generators.php');
 }
Exemplo n.º 4
0
 private function relativizeConfigPath(Container $container)
 {
     if (null === ($path = $container->getParameter('path'))) {
         return;
     }
     if (substr($path, 0, 1) === '/') {
         return;
     }
     $container->setParameter('path', sprintf('%s/%s', dirname($container->getParameter('config_path')), $path));
 }
Exemplo n.º 5
0
 public function load(Container $container)
 {
     $container->register('foobar', function ($container) {
         $stdClass = new \stdClass();
         $stdClass->foobar = $container->getParameter('foo');
         return $stdClass;
     });
 }