public function indexAction() { echo 'Core base bundle '; $em = $this->getDoctrine()->getManager(); $user = $em->getRepository('Entity:User')->find(8); $vertical = $em->getRepository('Entity:Vertical')->find(1); $category = $em->getRepository('Entity:Category')->find(3); $ad = new \Entity\Ad(); $ad->setAdType('FR'); $ad->setStatus('A'); $ad->setTitle('Tesing demo a8993'); $ad->setIsNew(1); $ad->setPrice(5000); $ad->setIp('192.168.1.19'); $ad->setUser($user); $ad->setVertical($vertical); $ad->setCategory($category); $car = new \Entity\Car(); $car->setMileage('9899'); $car->setAd($ad); $em->persist($car); $em->flush(); exit; $ad = $em->getRepository('Entity:Ad')->find(1); $object = $this->get('rmc_core_base.ad_manager')->getVerticalObject('Car'); //echo $ad->getVerticalObject()->getId(); return $this->render('RmcCoreVerticalBundle:Default:index.html.twig'); }
public function testInsertWithSequenceName() { $sequence = Entity\Car::definition()['fields']['id']['sequence']; /** @var Connection|\PHPUnit_Framework_MockObject_MockObject $connection */ $connection = $this->getMockBuilder(Connection::class)->disableOriginalConstructor()->setMethodsExcept(['mapper'])->getMock(); $connection->expects($this->any())->method('getDatabasePlatform')->willReturn(new \Doctrine\DBAL\Platforms\SqlitePlatform()); $connection->expects($this->once())->method('lastInsertId')->with($sequence); $mapper = $connection->mapper(Entity\Car::class); $entity = $mapper->entity(['name' => 'DMC-12', 'manufacturer_id' => 1]); $mapper->insert($entity); }