本文整理汇总了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;
}
示例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;
}
示例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');
}
示例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());
}
示例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;
}
示例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();
}
示例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;
}
示例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);
}
}
示例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;
}