public function testResetTypes()
 {
     IdGeneratorContainer::add('testing', 'Mongator\\Tests\\Id\\TestingIdGenerator');
     IdGeneratorContainer::reset();
     $this->assertTrue(IdGeneratorContainer::has('native'));
     $this->assertFalse(IdGeneratorContainer::has('testing'));
 }
示例#2
0
 public function MongatorIdGeneratorToPHP($configClass, $id, $indent = 8)
 {
     $idGenerator = IdGeneratorContainer::get($configClass['idGenerator']['name']);
     $code = $idGenerator->getToPHPCode();
     $code = str_replace('%id%', $id, $code);
     $code = static::indentCode($code, $indent);
     return $code;
 }
示例#3
0
 protected function tearDown()
 {
     IdGeneratorContainer::reset();
     TypeContainer::reset();
 }
示例#4
0
 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
<?php

$configClasses = (require __DIR__ . '/config_classes.php');
$loader = (require __DIR__ . "/../vendor/autoload.php");
$loader->add('Mongator\\Tests', __DIR__);
$loader->add('Mongator\\Benchmarks', __DIR__);
$loader->add('Model', __DIR__);
// mondator
use Mandango\Mondator\Mondator;
use Mongator\Id\IdGeneratorContainer;
$mondator = new Mondator();
$mondator->setConfigClasses($configClasses);
$mondator->setExtensions(array(new Mongator\Extension\Core(array('metadata_factory_class' => 'Model\\Mapping\\Metadata', 'metadata_factory_output' => __DIR__, 'default_output' => __DIR__)), new Mongator\Extension\DocumentArrayAccess(), new Mongator\Extension\DocumentPropertyOverloading()));
IdGeneratorContainer::add('ab-id', 'Mongator\\Tests\\Id\\ABIdGenerator');
$mondator->process();