Exemplo n.º 1
0
 /**
  * Flush in notification
  */
 protected function flushNotification(Announcement $entity, $title = "Nouvelle Action", $criticity = "success")
 {
     $notification = $this->dm->getRepository('BackBundle:Notifications')->findOneByAid($entity->getId());
     if (!$notification) {
         $notification = new Notifications();
     }
     $notification->setAid($entity->getId());
     $notification->setTitle($title);
     $notification->setObject($entity->getTitle());
     $notification->setCriticity($criticity);
     $notification->setAuthor($entity->getUser());
     $this->dm->persist($notification);
     $this->dm->flush();
     $redis = new \Redis();
     $redis->connect('127.0.0.1', '6379');
     $emitter = new Emitter($redis);
     $now = new \DateTime('now');
     $emitter->emit('notification', ['title' => $title, 'date' => $now->format('Y-m-d H:i:s'), 'author' => $entity->getUser()->getPseudo(), 'objet' => $entity->getTitle(), 'criticity' => $criticity]);
 }
 /**
  * The application contains a lot of secure URLs which shouldn't be
  * publicly accessible. This tests ensures that whenever a user tries to
  * access one of those pages, a redirection to the login form is performed.
  *
  * @dataProvider getDatas
  */
 public function testCreate($datas)
 {
     $em = $this->container->get('doctrine.orm.entity_manager');
     $user = $em->getRepository("BackBundle:User")->findOneByPseudo("djscrave");
     $formData = array('title' => $datas, 'price' => 23.55, 'ref' => "BB-5555-A", 'city' => "Paris", 'cp' => "75002", 'address' => "12 rue Mandar", 'country' => "France", 'type' => "apt", 'energyLabel' => "A", 'surface' => 25, 'nbrooms' => 2, 'bedrooms' => 3, 'pricePerMeterSquare' => 100, 'content' => "Description de mon appartement", 'activate' => true, 'user' => $user);
     $announcement = new Announcement();
     $announcement->setTitle($formData['title']);
     $announcement->setPrice((double) $formData['price']);
     $announcement->setRef($formData['ref']);
     $announcement->setAddress($formData['address']);
     $announcement->setCity($formData['city']);
     $announcement->setCp($formData['cp']);
     $announcement->setContent($formData['content']);
     $announcement->setCountry($formData['country']);
     $announcement->setType($formData['type']);
     $announcement->setEnergyLabel($formData['energyLabel']);
     $announcement->setNbrooms((int) $formData['nbrooms']);
     $announcement->setBedrooms((int) $formData['bedrooms']);
     $announcement->setSurface($formData['surface']);
     $announcement->setPricePerMeterSquare((double) $formData['pricePerMeterSquare']);
     $announcement->setActivate($formData['activate']);
     $announcement->setUser($formData['user']);
     $em->persist($announcement);
     $em->flush();
     $this->assertEquals($datas, $announcement->getTitle());
     $announcement = $em->getRepository("BackBundle:Announcement")->findOneByTitle($datas);
     $announcement->setTitle("New B");
     $em->persist($announcement);
     $em->flush();
     $this->assertEquals("New B", $announcement->getTitle());
     $em->remove($announcement);
     $em->flush();
     $announcement = $em->getRepository("BackBundle:Announcement")->findOneByTitle("New B");
     $this->assertEquals(null, $announcement);
 }
Exemplo n.º 3
0
 /**
  * SUbmit this form and all attributes
  */
 public function testSubmitValidData()
 {
     $this->markTestSkipped('PHPUnit will skip this test method');
     $formData = array('title' => 'New', 'price' => 23.55, 'ref' => "BB-5555-A", 'city' => "Paris", 'cp' => "75002", 'address' => "12 rue Mandar", 'country' => "France", 'type' => "apt", 'energyLabel' => "A", 'surface' => 25, 'nbrooms' => 2, 'bedrooms' => 3, 'pricePerMeterSquare' => 100, 'content' => "Description de mon appartement", 'activate' => true);
     $announcement = new Announcement();
     $announcement->setTitle($formData['title']);
     $announcement->setPrice((double) $formData['price']);
     $announcement->setRef($formData['ref']);
     $announcement->setAddress($formData['address']);
     $announcement->setCity($formData['city']);
     $announcement->setCp($formData['cp']);
     $announcement->setContent($formData['content']);
     $announcement->setCountry($formData['country']);
     $announcement->setType($formData['type']);
     $announcement->setEnergyLabel($formData['energyLabel']);
     $announcement->setNbrooms((int) $formData['nbrooms']);
     $announcement->setBedrooms((int) $formData['bedrooms']);
     $announcement->setSurface($formData['surface']);
     $announcement->setPricePerMeterSquare((double) $formData['pricePerMeterSquare']);
     $announcement->setActivate($formData['activate']);
     $announcement->setActivate($formData['activate']);
     //        $announcement->setUser($formData['user']);
     $form = new AnnouncementType();
     $form = $this->factory->create($form);
     $form->submit($formData);
     $this->assertTrue($form->isSynchronized());
     $this->assertEquals($announcement, $form->getData());
     // Ensure the view has all required variables
     $view = $form->createView();
     $children = $view->children;
     foreach (array_keys($formData) as $key) {
         $this->assertArrayHasKey($key, $children);
     }
 }
Exemplo n.º 4
0
 /**
  * load Announcement
  * @param ObjectManager $manager
  */
 public function load(ObjectManager $manager)
 {
     $formData = array('title' => 'New', 'price' => 23.55, 'ref' => "BB-5555-A", 'city' => "Paris", 'cp' => "75002", 'address' => "12 rue Mandar", 'country' => "France", 'type' => "apt", 'energyLabel' => "A", 'surface' => 25, 'nbrooms' => 2, 'bedrooms' => 3, 'pricePerMeterSquare' => 100, 'content' => "Description de mon appartement", 'activate' => true, 'user' => $this->getReference('user'));
     $announcement = new Announcement();
     $announcement->setTitle($formData['title']);
     $announcement->setPrice((double) $formData['price']);
     $announcement->setRef($formData['ref']);
     $announcement->setAddress($formData['address']);
     $announcement->setCity($formData['city']);
     $announcement->setCp($formData['cp']);
     $announcement->setContent($formData['content']);
     $announcement->setCountry($formData['country']);
     $announcement->setType($formData['type']);
     $announcement->setEnergyLabel($formData['energyLabel']);
     $announcement->setNbrooms((int) $formData['nbrooms']);
     $announcement->setBedrooms((int) $formData['bedrooms']);
     $announcement->setSurface($formData['surface']);
     $announcement->setPricePerMeterSquare((double) $formData['pricePerMeterSquare']);
     $announcement->setActivate($formData['activate']);
     $announcement->setUser($formData['user']);
     $manager->persist($announcement);
     $manager->flush();
 }
Exemplo n.º 5
0
 public function activate(Announcement $offer)
 {
     $offer->setActivate(!$offer->getActivate());
     $this->em->persist($offer);
     $this->em->flush();
 }