private function prepareCloseByOwner() { $em = $this->getService('doctrine')->getEntityManager(); $location1 = new Location(); $location1->setName('Location name'); $location1->setCity('Location city'); $location1->setStreet('Location street'); $location1->setNumber('Location number'); $location1->setApartment('Location apartment'); $location1->setPostal('00-000'); $location1->setPhone('+48100000000'); $location1->setEmail('*****@*****.**'); $this->persist($location1); $location2 = new Location(); $location2->setName('Location name 2'); $location2->setCity('Location city'); $location2->setStreet('Location street'); $location2->setNumber('Location number'); $location2->setApartment('Location apartment'); $location2->setPostal('00-000'); $location2->setPhone('+48100000000'); $location2->setEmail('*****@*****.**'); $this->persist($location2); $role = new Role(); $role->setName('Admin'); foreach ($em->getRepository('Entity\\Functionality')->findAll() as $functionality) { $role->getFunctionalities()->add($functionality); } $this->persist($role); $owner = new User(); $owner->setEmail('*****@*****.**'); $owner->setFirstName('first name'); $owner->setLastName('last name'); $owner->setLocation($location2); $owner->setRole($role); $this->persist($owner); $performer = new User(); $performer->setEmail('*****@*****.**'); $performer->setFirstName('first name'); $performer->setLastName('last name'); $performer->setLocation($location1); $performer->setRole($role); $this->persist($performer); $deviceTag = new DeviceTag(); $deviceTag->setName('DeviceTag name'); $this->persist($deviceTag); $device = new Device(); $device->setName('Device name'); $device->setPhoto('Device.photo.jpg'); $device->getTags()->add($deviceTag); $device->setType($em->getRepository('Entity\\DeviceType')->findOneById(1)); $device->setState($em->getRepository('Entity\\DeviceState')->findOneById(1)); $device->setSerialNumber('Device serial number'); $device->setState($em->getRepository('Entity\\DeviceState')->findOneById(2)); $device->setSymbol('?'); $device->setLocation($location1); $device->setUser($performer); $this->persist($device); $order = new Order(); $order->setOwner($owner); $order->setState($em->getRepository('Entity\\OrderState')->findOneById(2)); $order->setDevice($device); $order->setPerformer($performer); $order->setFetchedAt(new \DateTime()); $this->persist($order); $this->flush(); $session = $this->createSession(); $session->set('user.id', $owner->getId()); $client = $this->createClient($session); $client->loadPage('/order/show/' . $order->getId()); $this->assertEquals(200, $client->getResponse()->getStatusCode(), 'Invalid status code.'); $timeLines = $client->findElements('.timeline-entry'); $this->assertCount(2, $timeLines, 'Invalid number steps'); $buttons = $timeLines[1]->findElements('a'); $this->assertCount(2, $buttons, 'Invalid buttons number'); $this->assertEquals('Me', $buttons[0]->getHtml(), 'Invalid Me label'); $this->assertEquals('My location', $buttons[1]->getHtml(), 'Invalid Location label'); return array($buttons, $order, $performer, $device, $location2, $client, $owner); }
/** * Method for fetch order to realization * * @param \Entity\Order $entity * @return mixed * @throws OrderAllreadyFetchedException */ public function fetch($entity) { if ($entity->getState()->getId() != 1) { throw new OrderAllreadyFetchedException(); } $entity->setPerformer($this->getUser()); $entity->setState($this->cast('Mapper\\OrderState', 2)); $entity->setFetchedAt(new \DateTime()); $this->flush(); return $this->redirect('/order/show/' . $entity->getId()); }