/** * Check behavior of getStateParentsClassesNamesList() if the finder return all parent class of a state (including external classes). */ public function testGetStateParentsClassesNamesList() { $this->getClassLoaderMock()->expects($this->any())->method('loadClass')->willReturnCallback(function ($class) { $parts = explode('\\', $class); $state = array_pop($parts); include_once $this->statedClass1Path . '/States/' . $state . '.php'; return true; }); $this->initializeFinder('Class1', $this->statedClass1Path); $this->assertEquals(array('Teknoo\\Tests\\Support\\MockState'), $this->finder->getStateParentsClassesNamesList('State4b')); $this->assertEquals(array('Class1\\States\\State4b', 'Teknoo\\Tests\\Support\\MockState'), $this->finder->getStateParentsClassesNamesList('State5')); $this->assertEquals(array('Class1\\States\\State5', 'Class1\\States\\State4b', 'Teknoo\\Tests\\Support\\MockState'), $this->finder->getStateParentsClassesNamesList('State6')); }
/** * Return the Factory Object Interface. * * @param FinderInterface $finder * * @return Factory\FactoryInterface */ public function getFactoryObject(FinderInterface $finder) { $factory = new Factory\Integrated($finder->getStatedClassName(), $finder, $this->repository); return $factory; }
/** * To store a single instance of each state instance, shared by all stated class instance. * * @param string $loadingStateName * @param FinderInterface $finderLoader * @param bool $enablePrivateMode * * @return \Teknoo\States\State\StateInterface */ private function buildState(string $loadingStateName, FinderInterface $finderLoader, bool $enablePrivateMode) { if (!isset($this->statesInstancesList[$loadingStateName])) { $this->statesInstancesList[$loadingStateName] = $finderLoader->buildState($loadingStateName, $enablePrivateMode, $finderLoader->getStatedClassName(), $this->computeStateAlias($loadingStateName, $finderLoader)); } return $this->statesInstancesList[$loadingStateName]; }