getParam() public method

Gets a param from the container or a default value.
public getParam ( string $id, mixed $default = null ) : mixed
$id string
$default mixed
return mixed
Esempio n. 1
0
 /**
  * Adds autoloaders that can handle the class name extensions specified in each
  * phpspec suite.
  *
  * @param $container
  */
 private function setupAutoloaders(ServiceContainer $container)
 {
     $suites = $container->getParam('suites');
     foreach ($suites as $suite => $config) {
         $srcPath = array_key_exists('src_path', $config) ? $config['src_path'] : 'src';
         $extension = array_key_exists('src_extension', $config) ? $config['src_extension'] : '.php';
         spl_autoload_register(function ($class_name) use($srcPath, $extension) {
             $filename = $srcPath . "/" . preg_replace('/\\\\/', '/', $class_name) . $extension;
             if (file_exists($filename)) {
                 require_once $filename;
             }
         });
     }
 }
Esempio n. 2
0
 /**
  * set global fuel setting
  *  $_SERVER[
  *   [doc_root] => ../../
  *   [app_path] => fuel/app
  *   [core_path] => fuel/core
  *   [package_path] => fuel/packages
  *   [vendor_path] => fuel/vendor
  *   [FUEL_ENV] => test
  *  ]
  * and
  * load bootstrap;
  * @param ServiceContainer $container
  */
 protected function loadPhpunitConfiguration(ServiceContainer $container)
 {
     try {
         $file = $container->getParam('phpunit.xml', self::DEFAULTPATH_PHPUNITXML);
         $config = PHPUnit_Util_Configuration::getInstance($file);
         $config->handlePHPConfiguration();
         $configures = $config->getPHPUnitConfiguration();
         if (file_exists($configures['bootstrap'])) {
             include_once $configures['bootstrap'];
         }
     } catch (\Exception $e) {
         echo "can't find phpunit.xml\n";
     }
 }
Esempio n. 3
0
 /**
  * @param ServiceContainer $container
  */
 public function load(ServiceContainer $container)
 {
     /** @var IO $io */
     $io = $container->get('console.io');
     if (!extension_loaded('xdebug')) {
         $io->writeln('<fg=white;bg=red>Code coverage disabled (missing xdebug extension)</>');
         return;
     }
     $container->setShared('event_dispatcher.listeners.addvilz_code_coverage', function (ServiceContainer $container) use($io) {
         $defaults = ['max_specs' => 1];
         $options = array_merge($defaults, $container->getParam('phpspec_cover', []));
         $listener = new Listener(new \PHP_CodeCoverage(), $io, new Reporter(new OutputFormatter($io->isDecorated())), $options['max_specs']);
         register_shutdown_function([$listener, 'shutdown']);
         return $listener;
     });
 }
 public function load(ServiceContainer $container)
 {
     $container->setShared('event_dispatcher.listeners.environment', function ($container) {
         return new ServerEnvListener($container->getParam('server_env'));
     });
 }
 function it_should_return_the_filter_methods_list_for_no_filters(ServiceContainer $serviceContainer)
 {
     $paramFilterList = ['static' => false, 'public' => false, 'protected' => false, 'private' => false, 'abstract' => false, 'final' => false];
     $serviceContainer->getParam('brobdingnagian')->willReturn(array('filter-methods' => $paramFilterList));
     $this->getFilterMethods()->shouldReturn(null);
 }
 function it_should_return_the_configured_number_of_traits(ServiceContainer $serviceContainer)
 {
     $serviceContainer->getParam('brobdingnagian')->willReturn(array('number-of-traits' => 3));
     $this->getNumberOfTraits()->shouldReturn(3);
 }
 /**
  * {@inheritDoc}
  */
 public function load(ServiceContainer $container)
 {
     $container->setShared('code_coverage.filter', function () {
         return new \PHP_CodeCoverage_Filter();
     });
     $container->setShared('code_coverage', function ($container) {
         return new \PHP_CodeCoverage(null, $container->get('code_coverage.filter'));
     });
     $container->setShared('code_coverage.options', function ($container) {
         $options = $container->getParam('code_coverage');
         if (!isset($options['format'])) {
             $options['format'] = array('html');
         } elseif (!is_array($options['format'])) {
             $options['format'] = (array) $options['format'];
         }
         if (isset($options['output'])) {
             if (!is_array($options['output']) && count($options['format']) == 1) {
                 $format = $options['format'][0];
                 $options['output'] = array($format => $options['output']);
             }
         }
         if (!isset($options['show_uncovered_files'])) {
             $options['show_uncovered_files'] = true;
         }
         if (!isset($options['lower_upper_bound'])) {
             $options['lower_upper_bound'] = 35;
         }
         if (!isset($options['high_lower_bound'])) {
             $options['high_lower_bound'] = 70;
         }
         return $options;
     });
     $container->setShared('code_coverage.reports', function ($container) {
         $options = $container->get('code_coverage.options');
         $reports = array();
         foreach ($options['format'] as $format) {
             switch ($format) {
                 case 'clover':
                     $reports['clover'] = new \PHP_CodeCoverage_Report_Clover();
                     break;
                 case 'php':
                     $reports['php'] = new \PHP_CodeCoverage_Report_PHP();
                     break;
                 case 'text':
                     $reports['text'] = new \PHP_CodeCoverage_Report_Text($options['lower_upper_bound'], $options['high_lower_bound'], $options['show_uncovered_files'], false);
                     break;
                 case 'xml':
                     $reports['xml'] = new \PHP_CodeCoverage_Report_XML();
                     break;
                 case 'crap4j':
                     $reports['crap4j'] = new \PHP_CodeCoverage_Report_Crap4j();
                     break;
                 case 'html':
                     $reports['html'] = new \PHP_CodeCoverage_Report_HTML();
                     break;
             }
         }
         $container->setParam('code_coverage', $options);
         return $reports;
     });
     $container->setShared('event_dispatcher.listeners.code_coverage', function ($container) {
         $listener = new CodeCoverageListener($container->get('code_coverage'), $container->get('code_coverage.reports'));
         $listener->setIO($container->get('console.io'));
         $listener->setOptions($container->getParam('code_coverage', array()));
         return $listener;
     });
 }
 /**
  * @param ServiceContainer $serviceContainer
  */
 public function __construct(ServiceContainer $serviceContainer)
 {
     $this->input = $serviceContainer->get('console.input');
     $this->params = $serviceContainer->getParam('brobdingnagian');
 }
Esempio n. 9
0
 function let(ServiceContainer $container)
 {
     $container->setShared(Argument::cetera())->willReturn();
     $container->addConfigurator(Argument::any())->willReturn();
     $container->getParam(Argument::cetera())->willReturn();
 }