コード例 #1
0
 public function testAutoSetInjector()
 {
     $injector = new Injector();
     $injector->setAutoScanProperties(true);
     $injector->addAutoProperty('auto', 'somevalue');
     $config = array(array('src' => TEST_SERVICES . '/SampleService.php'));
     $injector->load($config);
     $this->assertTrue($injector->hasService('SampleService') == 'SampleService');
     // We expect a false because the 'AnotherService' is actually
     // just a replacement of the SampleService
     $myObject = new TestObject();
     $injector->inject($myObject);
     $this->assertEquals(get_class($myObject->sampleService), 'SampleService');
     $this->assertEquals($myObject->auto, 'somevalue');
 }