コード例 #1
0
ファイル: AccountModelTest.php プロジェクト: carlohcs/core
 public function setUp()
 {
     parent::setUp();
     $this->createSchema();
     //Persist needeed data in db
     //Add SP state
     $state = new Core\Models\Address\State\StateModel();
     $state->setId(26);
     //SP
     $state->setInitials('SP');
     $state->setState('Sao Paulo');
     //http://stackoverflow.com/questions/32784033/symfony2-doctrine2-autoincrement-field-with-custom-id-generator
     $metadata = $this->entityManager->getClassMetadata(get_class($state));
     $metadata->setIdGeneratorType($metadata::GENERATOR_TYPE_NONE);
     $this->entityManager->persist($state);
     //Add Sao Paulo city
     $city = new Core\Models\Address\City\CityModel();
     $city->setId(9422);
     $city->setCity('Sao Paulo');
     $city->setState($state);
     $metadata = $this->entityManager->getClassMetadata(get_class($city));
     $metadata->setIdGeneratorType($metadata::GENERATOR_TYPE_NONE);
     $this->entityManager->persist($city);
     //Persist and save the entities
     $this->entityManager->flush();
 }
コード例 #2
0
 public function setUp()
 {
     parent::setUp();
     $this->controller = new $this->controllerStringName();
     $this->request = $this->controller->getRequest();
     $this->response = $this->controller->getResponse();
     $this->routeMatch = new RouteMatch(array('controller' => 'index'));
     $this->event = new MvcEvent();
     $config = $this->getService('Config');
     $routerConfig = isset($config['router']) ? $config['router'] : array();
     $router = HttpRouter::factory($routerConfig);
     $this->event->setRouter($router);
     $this->event->setRouteMatch($this->routeMatch);
     $this->controller->setEvent($this->event);
     $this->controller->setServiceLocator($this->serviceManager);
 }