Ejemplo n.º 1
0
 public function testGet()
 {
     $factory = new Factory(function () {
         return new \stdClass();
     });
     /** @var LocatorInterface $locator */
     $locator = $this->getMockBuilder(LocatorInterface::class)->getMock();
     $result = $factory->get($locator);
     $this->assertEquals($result, $factory->get($locator));
     $this->assertNotSame($result, $factory->get($locator));
     $factory = new Factory(function (LocatorInterface $locator) {
         return $locator;
     });
     $this->assertSame($locator, $factory->get($locator));
 }
Ejemplo n.º 2
0
 public function get(LocatorInterface $locator)
 {
     if (!$this->isCalled) {
         $this->result = parent::get($locator);
         $this->isCalled = true;
     }
     return $this->result;
 }