/**
  * Tests the protected method when passing the shared arg..
  *
  * @return  void
  *
  * @since   1.0
  */
 public function testProtectShared()
 {
     $this->fixture->protect('foo', function () {
         return new \stdClass();
     }, true);
     $dataStore = $this->readAttribute($this->fixture, 'dataStore');
     $this->assertTrue($dataStore['foo']['protected'], 'The protect convenience method sets items as protected.');
     $this->assertTrue($dataStore['foo']['shared'], 'The protected method does set shared when passed true as third arg.');
 }
 /**
  * @testdox A protected resource can not be extended
  * @expectedException \Joomla\DI\Exception\ProtectedKeyException
  */
 public function testExtendProtected()
 {
     $container = new Container();
     $container->protect('foo', function () {
         return new \stdClass();
     });
     $value = 42;
     $container->extend('foo', function ($shared) use($value) {
         $shared->value = $value;
         return $shared;
     });
 }
 /**
  * Registers the service provider with a DI container.
  *
  * @param   Container  $container  The DI container.
  *
  * @return  void
  *
  * @since   1.0
  */
 public function register(Container $container)
 {
     require_once JPATH_CONFIGURATION . '/configuration.php';
     $config = new Registry(new JConfig());
     // Set the error_reporting
     switch ($config->get('error_reporting')) {
         case 'default':
         case '-1':
             break;
         case 'none':
         case '0':
             error_reporting(0);
             break;
         case 'simple':
             error_reporting(E_ERROR | E_WARNING | E_PARSE);
             ini_set('display_errors', 1);
             break;
         case 'maximum':
             error_reporting(E_ALL);
             ini_set('display_errors', 1);
             break;
         case 'development':
             error_reporting(-1);
             ini_set('display_errors', 1);
             break;
         default:
             error_reporting($config->get('error_reporting'));
             ini_set('display_errors', 1);
             break;
     }
     JFactory::$config = $config;
     define('JDEBUG', $config->get('debug', false));
     $container->protect('config', function () use($config) {
         return $config;
     }, true);
 }
 /**
  * @testdox The convenience method protect() sets resources as shared when passed true as third arg
  */
 public function testProtectShared()
 {
     $container = new Container();
     $container->protect('foo', function () {
         return new \StdClass();
     }, true);
     $this->assertTrue($container->isShared('foo'));
     $this->assertTrue($container->isProtected('foo'));
 }