Example #1
0
 /**
  * The default constructor.
  *
  * @param \TechDivision\Properties\Properties $defaults The properties we want want to use for intialization
  *
  * @return void
  */
 public function __construct(Properties $defaults = null)
 {
     // check if properties are passed
     if ($defaults != null) {
         // if yes set them
         parent::__construct($defaults->toArray());
     } else {
         parent::__construct();
     }
 }
 /**
  * Initialize the initial context with the values of the passed properties.
  *
  * @param \TechDivision\Properties\PropertiesInterface $properties The configuration properties
  */
 public function __construct(PropertiesInterface $properties = null)
 {
     // initialize the default properties if no ones has been passed
     if ($properties == null) {
         // initialize the default properties
         $properties = new Properties();
         foreach ($this->defaultProperties as $key => $value) {
             $properties->setProperty($key, $value);
         }
     }
     // inject the properties
     $this->injectProperties($properties);
     // create a factory for the lexer we use to parse the JNDI style bean names
     $factory = new UsingPregReplace(new LexerDataGenerator());
     // create the lexer instance and inject it
     $this->injectLexer($factory->createLexer(array('php' => InitialContext::T_SCHEME, 'global\\/([a-zA-Z0-9_-]+)' => InitialContext::T_GLOBAL_SCOPE, 'app' => InitialContext::T_APPLICATION_SCOPE, '\\:' => InitialContext::T_COLON, '\\/' => InitialContext::T_SEPARATOR, 'local|remote' => InitialContext::T_INTERFACE, '\\w+' => InitialContext::T_CLASS)));
 }
 /**
  * Checks if the resource identifier will be initialized propertly
  * from a URL with global scope and remote interface.
  *
  * @return void
  */
 public function testWithDefaultPropertiesPopulatedWithGlobalScopeAndRemoteInterface()
 {
     // create default properties
     $defaultProperties = new Properties();
     $defaultProperties->setProperty('indexFile', InitialContextTest::INDEX_FILE);
     $defaultProperties->setProperty('contextName', InitialContextTest::CONTEXT_NAME);
     $defaultProperties->setProperty('transport', InitialContextTest::TRANSPORT);
     // create the initial context initialized with the default properties
     $this->initialContext->injectProperties($defaultProperties);
     // populate the identifier with the data of the passed URL
     $resourceIdentifier = $this->initialContext->prepareResourceIdentifier(InitialContextTest::IDENTIFIER_GLOBAL_REMOTE);
     // check the data from the resource identifier
     $this->assertSame(InitialContextTest::INDEX_FILE, $resourceIdentifier->getIndexFile());
     $this->assertSame(InitialContextTest::CLASS_NAME, $resourceIdentifier->getClassName());
     $this->assertSame(InitialContextTest::CONTEXT_NAME, $resourceIdentifier->getContextName());
     $this->assertSame(InitialContextTest::TRANSPORT, $resourceIdentifier->getTransport());
     $this->assertSame(EnterpriseBeanResourceIdentifier::REMOTE_INTERFACE, $resourceIdentifier->getInterface());
 }