Ejemplo n.º 1
0
 protected static function createPersistentClient($cookieName = 'test')
 {
     $client = parent::createClient();
     $client->getContainer()->get('session.storage.file')->deleteFile();
     $client->getCookieJar()->set(new Cookie(session_name(), $cookieName));
     return $client;
 }
Ejemplo n.º 2
0
 /**
  * Creates a Client.
  *
  * @param array $options An array of options to pass to the createKernel class
  * @param array $server  An array of server parameters
  *
  * @return Client A Client instance
  */
 protected static function createClient(array $options = array(), array $server = array())
 {
     if (!self::$internalClient) {
         self::$internalClient = parent::createClient($options, $server);
         if (self::$db_isolation) {
             /** @var Client $client */
             $client = self::$internalClient;
             //workaround MyISAM search tables are not on transaction
             if (self::$db_reindex) {
                 $kernel = $client->getKernel();
                 $application = new \Symfony\Bundle\FrameworkBundle\Console\Application($kernel);
                 $application->setAutoExit(false);
                 $options = array('command' => 'oro:search:reindex');
                 $options['--env'] = "test";
                 $options['--quiet'] = null;
                 $application->run(new \Symfony\Component\Console\Input\ArrayInput($options));
             }
             $client->startTransaction();
             $pdoConnection = Client::getPdoConnection();
             if ($pdoConnection) {
                 //set transaction level to 1 for entityManager
                 $connection = $client->createConnection($pdoConnection);
                 $client->getContainer()->set('doctrine.dbal.default_connection', $connection);
                 /** @var EntityManager $entityManager */
                 $entityManager = $client->getContainer()->get('doctrine.orm.entity_manager');
                 if (spl_object_hash($entityManager->getConnection()) != spl_object_hash($connection)) {
                     $reflection = new \ReflectionProperty('Doctrine\\ORM\\EntityManager', 'conn');
                     $reflection->setAccessible(true);
                     $reflection->setValue($entityManager, $connection);
                 }
             }
         }
     }
     return self::$internalClient;
 }
 protected function getArrayFromMessageBundle($bundle, $locate)
 {
     $client = parent::createClient();
     $kernel = $client->getKernel();
     $foundBundle = $kernel->getBundle($bundle);
     $bundleTransPath = $foundBundle->getPath() . '/Resources/translations';
     return $array = Yaml::parse($bundleTransPath . '/messages.' . $locate . '.yml');
 }
 public function testIndexForm()
 {
     $client = parent::createClient();
     $indexRoute = $client->getContainer()->get('router')->generate('homepage');
     $crawler = $client->request("GET", $indexRoute);
     $form = $crawler->filter("form[name=search]")->form();
     $client->submit($form, array('search[tag]' => 'test'));
     $this->assertEquals(200, $client->getResponse()->getStatusCode());
 }
 protected static function createClient(array $options = array(), array $server = array())
 {
     // let the parent create the client
     $client = parent::createClient($options, $server);
     // load the magefile, create the mage app and dispatch the
     // symfony_on_kernel_request event so the mage-container is properly initialized
     require_once static::$kernel->getContainer()->getParameter('liip_magento.mage_file');
     $params = array('container' => self::$kernel->getContainer());
     \Mage::app()->dispatchEvent('symfony_on_kernel_request', $params);
     return $client;
 }
 /**
  * Set up
  */
 public function setUp()
 {
     try {
         $this->client = self::$_client = parent::createClient($this->getKernelOptions(), $this->getServerParameters());
         static::$application = new Application(static::$kernel);
         static::$application->setAutoExit(false);
         $this->container = static::$kernel->getContainer();
     } catch (Exception $e) {
         throw new RuntimeException(sprintf('Unable to start the application: %s', get_class($e) . ':' . $e->getMessage()));
     }
     $this->createSchema();
 }
Ejemplo n.º 7
0
 protected function prepareEnvironment($environment = 'default')
 {
     $client = parent::createClient(array('environment' => $environment));
     $application = new Application($client->getKernel());
     $application->setAutoExit(false);
     $this->runConsole($application, "doctrine:database:drop", array("--force" => true));
     $this->runConsole($application, "doctrine:database:create");
     $this->runConsole($application, "doctrine:schema:create");
     $this->em = $client->getContainer()->get('doctrine.orm.default_entity_manager');
     $this->addTestData();
     return $client;
 }
Ejemplo n.º 8
0
 public function testSubmitValidData()
 {
     $client = WebTestCase::createClient();
     $container = $client->getContainer();
     $formData = ['user' => 'test user', 'comment' => 'wish'];
     $comment = new Comment();
     $comment->setUser($formData['user']);
     $comment->setComment($formData['comment']);
     $form = $container->get('form.factory')->create(new CommentType(), $comment);
     $form->submit($formData);
     $this->assertTrue($form->isSynchronized());
     $this->assertEquals($comment, $form->getData());
     $this->assertFalse($form->isValid());
     $formErrors = $form->getErrors(true);
     $this->assertEquals('Similar comment is already exists.', $formErrors->getChildren()->getMessage());
     $this->assertEquals(1, $formErrors->count());
     $view = $form->createView();
     $children = $view->children;
     foreach ($formData as $key => $value) {
         $this->assertArrayHasKey($key, $children);
     }
 }
Ejemplo n.º 9
0
 protected static function createClient(array $options = array(), array $server = array())
 {
     $client = parent::createClient($options, array_merge_recursive($server, array('PHP_AUTH_USER' => 'admin', 'PHP_AUTH_PW' => 'admin')));
     return $client;
 }