Пример #1
0
 /**
  * Test normal behavior of the finder to load (if needed) and build state.
  */
 public function testBuildState()
 {
     $this->initializeFinder('Class1', $this->statedClass1Path);
     $this->getClassLoaderMock()->expects($this->any())->method('loadClass')->with($this->equalTo('Class1\\States\\State4'))->willReturnCallback(function () {
         include_once $this->statedClass1Path . '/States/State4.php';
         return true;
     });
     $stateObject = $this->finder->buildState('State4', false, 'Class1');
     $this->assertEquals('Class1\\States\\State4', get_class($stateObject));
     $this->assertInstanceOf('\\Teknoo\\States\\State\\StateInterface', $stateObject);
 }
Пример #2
0
 /**
  * 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];
 }