示例#1
0
 protected function createTicket($day, $checkedIn = null, $email = null)
 {
     if ($email === null) {
         $email = sprintf('*****@*****.**', $this->ticketCounter);
     }
     if ($checkedIn === null) {
         $checkedIn = true;
     }
     $client = static::createClient();
     $container = $client->getContainer();
     /* @var $em \Doctrine\Common\Persistence\ObjectManager */
     $em = $container->get('doctrine')->getManager();
     // Create a ticket
     $event = $em->getRepository('BCRMBackendBundle:Event\\Event')->findAll()[0];
     $ticket = new Ticket();
     $ticket->setEmail($email);
     $ticket->setName('John Doe');
     $ticket->setEvent($event);
     $ticket->setDay($day);
     $ticket->setCode(sprintf('STATS%d', $this->ticketCounter++));
     $ticket->setCheckedIn($checkedIn);
     $em->persist($ticket);
     $em->flush();
     return $email;
 }
 /**
  * @test
  * @group   functional
  * @depends checkinsOnTheWrongDayShouldNotWork
  */
 public function theTicketSearchApiShouldWork()
 {
     $client = static::createClient(array(), array('PHP_AUTH_USER' => 'concierge', 'PHP_AUTH_PW' => 'letmein'));
     $container = $client->getContainer();
     // Confirm registration key
     /* @var $em \Doctrine\Common\Persistence\ObjectManager */
     $em = $container->get('doctrine')->getManager();
     // Create a ticket
     $event = $em->getRepository('BCRMBackendBundle:Event\\Event')->findAll()[0];
     $ticket = new Ticket();
     $ticket->setEmail('*****@*****.**');
     $ticket->setName('John Doe');
     $ticket->setEvent($event);
     $ticket->setDay(Ticket::DAY_SUNDAY);
     $ticket->setCode('SRCHTCKT');
     $em->persist($ticket);
     $em->flush();
     $client->request('GET', '/api/concierge/ticketsearch?q=SRCHTCKT');
     $response = $client->getResponse();
     $this->assertEquals(200, $response->getStatusCode());
     $this->assertEquals("application/json", $response->headers->get('Content-Type'));
     $this->assertEquals("utf-8", $response->getCharset());
     $result = json_decode($response->getContent());
     $this->assertEquals(1, count($result->items));
     $ticket = $result->items[0];
     $this->assertEquals('*****@*****.**', $ticket->email);
     $this->assertEquals(false, $ticket->checkedIn);
     $this->assertEquals(2, $ticket->day);
     $this->assertEquals('SRCHTCKT', $ticket->code);
     $this->assertTrue($ticket->id > 1);
 }
示例#3
0
 /**
  * @test
  * @group functional
  */
 public function listUnprintedTickets()
 {
     $client = static::createClient();
     $container = $client->getContainer();
     // Confirm registration key
     /* @var $em \Doctrine\Common\Persistence\ObjectManager */
     $em = $container->get('doctrine')->getManager();
     $event = $em->getRepository('BCRMBackendBundle:Event\\Event')->findAll()[0];
     // Create registrations
     for ($i = 0; $i < 5; $i++) {
         $registration = new Registration();
         $registration->setEmail(sprintf('*****@*****.**', $i));
         $registration->setName(sprintf('John Doe %d', $i));
         $registration->setEvent($event);
         $registration->setConfirmed(true);
         $registration->setSaturday(false);
         $registration->setSunday(true);
         $registration->setTags(sprintf('#johndoe%d', $i));
         $em->persist($registration);
     }
     // Create tickets
     for ($i = 0; $i < 5; $i++) {
         $checkedIn = $i > 1;
         $sundayTicket = new Ticket();
         $sundayTicket->setEmail(sprintf('*****@*****.**', $i));
         $sundayTicket->setName(sprintf('John Doe %d', $i));
         $sundayTicket->setEvent($event);
         $sundayTicket->setDay(Ticket::DAY_SUNDAY);
         $sundayTicket->setCode(sprintf('PRNT%d', $i));
         $sundayTicket->setNotified(true);
         $sundayTicket->setCheckedIn($checkedIn);
         $em->persist($sundayTicket);
         $saturdayTicket = new Ticket();
         $saturdayTicket->setEmail(sprintf('*****@*****.**', $i));
         $saturdayTicket->setName(sprintf('John Doe %d', $i));
         $saturdayTicket->setEvent($event);
         $saturdayTicket->setDay(Ticket::DAY_SATURDAY);
         $saturdayTicket->setCode(sprintf('NOPRNT%d', $i));
         $saturdayTicket->setNotified(true);
         $saturdayTicket->setCheckedIn($checkedIn);
         $em->persist($saturdayTicket);
     }
     $em->flush();
     $client = static::createClient(array(), array('PHP_AUTH_USER' => 'concierge', 'PHP_AUTH_PW' => 'letmein'));
     $client->request('GET', '/api/printing/queue');
     $response = $client->getResponse();
     $this->assertEquals(200, $response->getStatusCode());
     $this->assertEquals("application/json", $response->headers->get('Content-Type'));
     $this->assertEquals("utf-8", $response->getCharset());
     $queue = json_decode($response->getContent());
     $this->assertEquals(3, count($queue->items));
     $ticket = $queue->items[0];
     $this->assertObjectHasAttribute('name', $ticket);
     $this->assertObjectHasAttribute('tags', $ticket);
     $this->assertObjectHasAttribute('code', $ticket);
     $this->assertObjectHasAttribute('day', $ticket);
     $this->assertEquals('#' . strtolower(str_replace(' ', '', $ticket->name)), $ticket->tags);
     $this->assertEquals(1, preg_match('/^PRNT[0-9]+$/', $ticket->code));
     $this->assertEquals(2, $ticket->day);
     return $queue->items;
 }
示例#4
0
 /**
  * @test
  * @group        unit
  * @dataProvider labels
  */
 public function ticketShouldHaveLabel($type, $label)
 {
     $ticket = new Ticket();
     $ticket->setType($type);
     $this->assertEquals($label, $ticket->getLabel());
 }