示例#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
文件: Mandango.php 项目: hybr/jpm
 public function mandangoIdGeneratorToMongo($configClass, $id, $indent = 8)
 {
     $idGenerator = IdGeneratorContainer::get($configClass['idGenerator']['name']);
     $code = $idGenerator->getToMongoCode();
     $code = str_replace('%id%', $id, $code);
     $code = static::indentCode($code, $indent);
     return $code;
 }
示例#3
0
 protected function tearDown()
 {
     Archive::clear();
     IdGeneratorContainer::reset();
     TypeContainer::reset();
 }
示例#4
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));
     }
 }
示例#5
0
 protected function tearDown()
 {
     IdGeneratorContainer::reset();
     TypeContainer::reset();
 }