public function get(FixtureIdInterface $fixture) : ObjectInterface { if ($this->has($fixture)) { return $this->objects[$fixture->getId()]; } throw ObjectNotFoundExceptionFactory::create($fixture->getId(), $fixture instanceof FixtureInterface ? $fixture->getClassName() : 'no class given'); }
/** * @expectedException \Nelmio\Alice\Throwable\Exception\ObjectNotFoundException * @expectedExceptionMessage Could not find the object "foo" of the class "Dummy". */ public function testThrowsExceptionWhenTryingToGetInexistingObject() { $bag = new ObjectBag(); $bag->get($this->createFixture('foo', 'Dummy')); }