/**
  * 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);
 }
 protected function getLegacyKernel()
 {
     if (!isset($this->legacyKernelClosure)) {
         $this->legacyKernelClosure = $this->container->get('ezpublish_legacy.kernel');
     }
     $legacyKernelClosure = $this->legacyKernelClosure;
     return $legacyKernelClosure();
 }
 /**
  * Execute
  */
 public function testExecute()
 {
     $application = new Application();
     $application->add($this->container->get('announcement_command'));
     $command = $application->find('notifications:purge');
     $commandTester = new CommandTester($command);
     $commandTester->execute(array('command' => $command->getName()));
     $this->assertRegExp('/Terminé|affect/', $commandTester->getDisplay());
 }
 /**
  * @test
  * @group test_factory
  **/
 public function プラグイン生成テスト()
 {
     $manager = new Midnight\Crawler\PluginManager();
     $names = $manager->getEnablePluginNames();
     foreach ($names as $name) {
         $plugin = $this->container->get($name);
         $instance_name = 'Midnight\\Crawler\\Plugin\\TestData\\' . $name . 'TestData';
         $this->assertInstanceOf($instance_name, $plugin);
     }
 }
 /**
  * {@inheritdoc}
  */
 public function validate($value, Constraint $constraint)
 {
     // if recaptcha is disabled, always valid
     if (!$this->container->getParameter("vihuvac_recaptcha.enabled")) {
         return true;
     }
     // define variables for recaptcha check answer
     $secretKey = $this->container->getParameter("vihuvac_recaptcha.secret_key");
     $remoteip = $this->container->get("request_stack")->getCurrentRequest()->server->get("REMOTE_ADDR");
     $response = $this->container->get("request_stack")->getCurrentRequest()->get("g-recaptcha-response");
     if (!$this->checkAnswer($secretKey, $remoteip, $response)) {
         $this->context->addViolation($constraint->message);
     }
 }
 /**
  * Get the translated field from a content object
  * 
  * @param \eZ\Publish\Core\Repository\Values\Content\Content $content
  * @param string $fieldIdentifier
  * @return \eZ\Publish\API\Repository\Values\Content\Field
  */
 protected function getTranslatedContentFieldValue( $content, $fieldIdentifier )
 {
     $translationHelper = $this->container->get( 'ezpublish.translation_helper' );
     $field = $translationHelper->getTranslatedField( $content, $fieldIdentifier );
     if( $field instanceof Field )
     {
         return $field->value;
     }
     return false;
 }