コード例 #1
0
 public function testOverridePriority()
 {
     $injector = new Injector();
     $injector->setAutoScanProperties(true);
     $config = array(array('src' => TEST_SERVICES . '/SampleService.php', 'priority' => 10));
     // load
     $injector->load($config);
     // inject
     $myObject = new TestObject();
     $injector->inject($myObject);
     $this->assertEquals(get_class($myObject->sampleService), 'SampleService');
     $config = array(array('src' => TEST_SERVICES . '/AnotherService.php', 'id' => 'SampleService', 'priority' => 1));
     // load
     $injector->load($config);
     $injector->inject($myObject);
     $this->assertEquals('SampleService', get_class($myObject->sampleService));
 }