function testLIWithoutIncludedDependencies() { $pico = new DefaultPicoContainer(); $pico->registerComponent(new LazyIncludingComponentAdapter(new ConstructorInjectionComponentAdapter('LazyIncludeModelWithDpendencies'), 'lazyincludemodelwithdpendencies.inc.php')); $pico->registerComponent(new LazyIncludingComponentAdapter(new ConstructorInjectionComponentAdapter('LazyIncludeModelDependend'), 'lazyincludemodeldependend.inc.php')); $this->assertFalse(class_exists('LazyIncludeModelWithDpendencies')); $this->assertFalse(class_exists('LazyIncludeModelDependend')); $ci = $pico->getComponentInstance('LazyIncludeModelWithDpendencies'); $this->assertTrue(class_exists('LazyIncludeModelWithDpendencies')); $this->assertTrue(class_exists('LazyIncludeModelDependend')); $this->assertIsA($ci, 'LazyIncludeModelWithDpendencies'); }
function testCachingComponentAdapter() { $pico = new DefaultPicoContainer(); $pico->registerComponent(new CachingComponentAdapter(new ConstructorInjectionComponentAdapter('Boy'))); $boy1 = $pico->getComponentInstance('Boy'); $boy2 = $pico->getComponentInstance('Boy'); if ($boy1 !== $boy2) { $this->fail(); } else { $this->pass(); } }
function testNonCachingComponentAdapter() { $pico = new DefaultPicoContainer(); $pico->registerComponent(new ConstructorInjectionComponentAdapter('Boy')); $boy1 = $pico->getComponentInstance('Boy'); $boy2 = $pico->getComponentInstance('Boy'); $this->assertCopy($boy1, $boy2); }