当前位置: 首页>>代码示例>>PHP>>正文


PHP WebTestCase::createClient方法代码示例

本文整理汇总了PHP中Symfony\Bundle\FrameworkBundle\Test\WebTestCase::createClient方法的典型用法代码示例。如果您正苦于以下问题:PHP WebTestCase::createClient方法的具体用法?PHP WebTestCase::createClient怎么用?PHP WebTestCase::createClient使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Symfony\Bundle\FrameworkBundle\Test\WebTestCase的用法示例。


在下文中一共展示了WebTestCase::createClient方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: createPersistentClient

 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;
 }
开发者ID:hotfics,项目名称:lichess-old,代码行数:7,代码来源:AbstractAcceptanceTest.php

示例2: createClient

 /**
  * 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;
 }
开发者ID:ashutosh-srijan,项目名称:findit_akeneo,代码行数:43,代码来源:WebTestCase.php

示例3: getArrayFromMessageBundle

 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');
 }
开发者ID:ja1cap,项目名称:GoogleTranslateBundle,代码行数:8,代码来源:GoogleTranslateCommandTest.php

示例4: testIndexForm

 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());
 }
开发者ID:antodippo,项目名称:ccmusicsearch,代码行数:9,代码来源:DefaultControllerTest.php

示例5: createClient

 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;
 }
开发者ID:Giant-Peach-Design,项目名称:LiipMagentoBundle,代码行数:11,代码来源:MagentoTestCase.php

示例6: setUp

 /**
  * 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();
 }
开发者ID:alexislefebvre,项目名称:axstrad-test-bundle,代码行数:15,代码来源:WebTestCase.php

示例7: prepareEnvironment

 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;
 }
开发者ID:ptsavdar,项目名称:ZenstruckFormBundle,代码行数:12,代码来源:WebTestCase.php

示例8: testSubmitValidData

 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);
     }
 }
开发者ID:bamper,项目名称:symblog_27,代码行数:22,代码来源:CommentTypeTest.php

示例9: createClient

 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;
 }
开发者ID:2martens,项目名称:web-platform,代码行数:5,代码来源:WebTestCase.php


注:本文中的Symfony\Bundle\FrameworkBundle\Test\WebTestCase::createClient方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。