示例#1
0
 public function testResetTypes()
 {
     IdGeneratorContainer::add('testing', 'Mandango\\Tests\\Id\\TestingIdGenerator');
     IdGeneratorContainer::reset();
     $this->assertTrue(IdGeneratorContainer::has('native'));
     $this->assertFalse(IdGeneratorContainer::has('testing'));
 }
示例#2
0
文件: Core.php 项目: robo47/mandango
 private function parseAndCheckIdGeneratorProcess()
 {
     if (!isset($this->configClass['idGenerator'])) {
         $this->configClass['idGenerator'] = 'native';
     }
     if (!is_array($this->configClass['idGenerator'])) {
         if (!is_string($this->configClass['idGenerator'])) {
             throw new \RuntimeException(sprintf('The idGenerator of the class "%s" is not neither an array nor a string.', $this->class));
         }
         $this->configClass['idGenerator'] = array('name' => $this->configClass['idGenerator']);
     }
     if (!isset($this->configClass['idGenerator']['options'])) {
         $this->configClass['idGenerator']['options'] = array();
     } elseif (!is_array($this->configClass['idGenerator']['options'])) {
         throw new \RuntimeException(sprintf('The options key of the idGenerator of the class "%s" is not an array.', $this->class));
     }
     if (!IdGeneratorContainer::has($this->configClass['idGenerator']['name'])) {
         throw new \RuntimeException(sprintf('The id generator "%s" of the class "%s" does not exist.', $this->configClass['idGenerator']['name'], $this->class));
     }
 }