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


PHP FrameworkBundle\Client类代码示例

本文整理汇总了PHP中Symfony\Bundle\FrameworkBundle\Client的典型用法代码示例。如果您正苦于以下问题:PHP Client类的具体用法?PHP Client怎么用?PHP Client使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: setUp

 public function setUp()
 {
     $this->client = static::createClient();
     $this->client->followRedirects();
     $this->container = $this->client->getContainer();
     $this->loadFixtures($this->getFixtures());
 }
开发者ID:stopfstedt,项目名称:ilios,代码行数:7,代码来源:AbstractControllerTest.php

示例2: testControllerNoticeToException

 public function testControllerNoticeToException()
 {
     $this->client = $this->createClient();
     $errorOccured = false;
     $syslogProcessorMock = $this->getMockBuilder('Keboola\\Syrup\\Monolog\\Processor\\SyslogProcessor')->disableOriginalConstructor()->getMock();
     $syslogProcessorMock->expects($this->any())->method("processRecord")->with($this->callback(function ($subject) use(&$errorOccured) {
         if ($subject['message'] == 'Notice: Undefined offset: 3') {
             $e = $subject['context']['exception'];
             $errorOccured = true;
             return $e instanceof \Symfony\Component\Debug\Exception\ContextErrorException;
         }
         return true;
     }))->willReturn(['level' => 100]);
     $container = $this->client->getContainer();
     $container->set('syrup.monolog.syslog_processor', $syslogProcessorMock);
     $this->client->request('GET', '/tests/notice');
     $response = $this->client->getResponse();
     $responseJson = json_decode($response->getContent(), true);
     $this->assertEquals('error', $responseJson['status']);
     $this->assertEquals('Application error', $responseJson['error']);
     $this->assertEquals(500, $responseJson['code']);
     $this->assertArrayHasKey('exceptionId', $responseJson);
     $this->assertArrayHasKey('runId', $responseJson);
     $this->assertTrue($errorOccured);
 }
开发者ID:keboola,项目名称:syrup,代码行数:25,代码来源:ErrorHandlingTest.php

示例3: setUpBeforeClass

 public static function setUpBeforeClass()
 {
     static::$client = static::createClient();
     static::$router = self::$client->getContainer()->get('router');
     static::$em = self::$client->getContainer()->get('doctrine.orm.entity_manager');
     static::$container = self::getContainer();
 }
开发者ID:bzis,项目名称:zomba,代码行数:7,代码来源:TestCase.php

示例4: createClient

 /**
  * {@inheritdoc}
  */
 protected static function createClient(array $options = array(), array $server = array())
 {
     static::bootKernel($options);
     $client = new Client(static::$kernel);
     $client->setServerParameters($server);
     return $client;
 }
开发者ID:hhamon,项目名称:slack-secret-santa,代码行数:10,代码来源:SantaControllerTest.php

示例5: getErrorMessage

 /**
  * @param \Symfony\Bundle\FrameworkBundle\Client $client
  *
  * @return string
  */
 protected function getErrorMessage(Client $client)
 {
     /** @var $profile \Symfony\Component\HttpKernel\Profiler\Profile */
     $profile = $client->getProfile();
     if (!$profile) {
         return '';
     }
     /** @var $exception \Symfony\Component\HttpKernel\DataCollector\ExceptionDataCollector */
     $exception = $profile->getCollector('exception');
     if (!$exception->hasException()) {
         return '';
     }
     $arrayTrace = array();
     foreach (array_slice($exception->getTrace(), 0, 10) as $position => $traceLine) {
         if (isset($traceLine['class'])) {
             $arrayTrace[] = sprintf('[%d] %s(%d) %s%s%s(%s)', $position, $traceLine['file'], $traceLine['line'], $traceLine['short_class'], $traceLine['type'], $traceLine['function'], isset($traceLine['args']) ? implode(', ', array_map(function ($v) {
                 switch ($v[0]) {
                     case 'array':
                         return 'array(' . count($v[1]) . ')';
                     case 'object':
                         return $v[1];
                     default:
                         return $v[1];
                 }
             }, $traceLine['args'])) : '');
         }
     }
     if (count($arrayTrace) < count($exception->getTrace())) {
         $arrayTrace[] = '...';
     }
     return $exception->getMessage() . PHP_EOL . PHP_EOL . implode(PHP_EOL, $arrayTrace) . PHP_EOL;
 }
开发者ID:Cohros,项目名称:KnowledgeBase,代码行数:37,代码来源:ControllerTestCase.php

示例6: logoutAction

 /**
  * Performs logout action and returns same client after log out.
  *
  * @param Client $client
  *
  * @return Client
  */
 public function logoutAction(Client $client)
 {
     $crawler = $client->request('GET', '/settings/login');
     $link = $crawler->filter('a:contains("Logout")')->link();
     $client->click($link);
     return $client;
 }
开发者ID:asev,项目名称:SettingsBundle,代码行数:14,代码来源:LoginTestHelper.php

示例7: setSettingsCookie

 /**
  * Create settings cookies and set it in the cookie jar.
  *
  * @param Client $client
  * @param array  $cookies
  */
 public static function setSettingsCookie(Client $client, array $cookies)
 {
     foreach ($cookies as $name => $cookieSettings) {
         $cookie = new Cookie($name, json_encode($cookieSettings));
         $client->getCookieJar()->set($cookie);
     }
 }
开发者ID:asev,项目名称:SettingsBundle,代码行数:13,代码来源:CookieTestHelper.php

示例8: makeJsonRequest

 /**
  * Create a JSON request
  *
  * @param Client $client
  * @param string $method
  * @param string $url
  * @param string $content
  * @param string $token
  */
 public function makeJsonRequest(Client $client, $method, $url, $content = null, $token = null, $files = array())
 {
     $headers = ['HTTP_ACCEPT' => 'application/json', 'CONTENT_TYPE' => 'application/json'];
     if (!empty($token)) {
         $headers['HTTP_X-JWT-Authorization'] = 'Token ' . $token;
     }
     $client->request($method, $url, [], $files, $headers, $content);
 }
开发者ID:Okami-,项目名称:ilios,代码行数:17,代码来源:JsonControllerTest.php

示例9: setUp

 /**
  * {@inheritDoc}
  */
 public function setUp()
 {
     $this->client = static::createClient();
     $this->container = $this->client->getContainer();
     $this->em = $this->container->get('doctrine')->getManager();
     $this->validator = $this->container->get('validator');
     $this->setCurrentShop();
 }
开发者ID:Newman101,项目名称:WellCommerce,代码行数:11,代码来源:AbstractTestCase.php

示例10: testAjaxDeleteFromBookmarkAction

 /**
  * Test AjaxDeleteFromBookmark action
  */
 public function testAjaxDeleteFromBookmarkAction()
 {
     $fixtures = $this->loadFixtures(['AppBundle\\DataFixtures\\ORM\\LoadUserData', 'AppBundle\\DataFixtures\\ORM\\LoadUserGroupData', 'AppBundle\\DataFixtures\\ORM\\LoadGroupData'])->getReferenceRepository();
     $this->loginAs($fixtures->getReference('user-admin'), 'main');
     $this->client = static::makeClient();
     $this->client->request('GET', '/group/jinjer/bookmark/delete', [], [], ['HTTP_X-Requested-With' => 'XMLHttpRequest']);
     $this->assertStatusCode(Response::HTTP_OK, $this->client);
 }
开发者ID:stfalcon-studio,项目名称:rock-events,代码行数:11,代码来源:GroupControllerTest.php

示例11: callApi

 /**
  * Request to API, return result
  * @param string $url URL of API call
  * @param string $method HTTP method of API call
  * @param array $params parameters of POST call
  * @return array
  */
 protected function callApi($url, $method = 'POST', $params = array())
 {
     $this->httpClient->request($method, $url, [], [], [], json_encode($params));
     $response = $this->httpClient->getResponse();
     /* @var \Symfony\Component\HttpFoundation\Response $response */
     $responseJson = json_decode($response->getContent(), true);
     $this->assertNotEmpty($responseJson, sprintf("Response of API call '%s' after json decoding should not be empty. Raw response:\n%s\n", $url, $response->getContent()));
     return $responseJson;
 }
开发者ID:ErikZigo,项目名称:syrup,代码行数:16,代码来源:AbstractFunctionalTest.php

示例12: testTokenCreation

 /**
  * Test token creation and usage
  */
 public function testTokenCreation()
 {
     $headers = array('PHP_AUTH_USER' => 'test_key', 'PHP_AUTH_PW' => 'test_secret', 'HTTP_username' => 'p-admin', 'HTTP_password' => 'p-admin');
     $this->client->request('GET', '/oauth/access_token?grant_type=password', array(), array(), $headers);
     $this->assertEquals(200, $this->client->getResponse()->getStatusCode());
     $this->assertSame('application/json', $this->client->getResponse()->headers->get('content-type'));
 }
开发者ID:open-orchestra,项目名称:open-orchestra,代码行数:10,代码来源:AuthorizationControllersTest.php

示例13: testSearchPage

 public function testSearchPage()
 {
     $this->client->request('GET', '/search?keyword=samsung sync master');
     $response = $this->client->getResponse();
     $this->assertTrue($response->isSuccessful());
     $this->assertEquals('application/json', $response->headers->get('Content-Type'));
 }
开发者ID:uikolas,项目名称:LT-eshops-search,代码行数:7,代码来源:DefaultControllerTest.php

示例14: testDeleteMultiple

 /**
  * @depends testPut
  */
 public function testDeleteMultiple()
 {
     $data = [2, 3];
     $uri = self::$router->generate('post_assets') . '.json';
     self::$client->request('DELETE', $uri, ['images' => json_encode($data)]);
     $this->assertTrue(self::$client->getResponse()->isRedirect());
 }
开发者ID:gorvelyfab,项目名称:KoopaBaseAdminer,代码行数:10,代码来源:MediaControllerTest.php

示例15: testPutPlayerAction

 public function testPutPlayerAction()
 {
     $em = self::$kernel->getContainer()->get('doctrine')->getManager();
     $queryBuilder = $em->createQueryBuilder();
     $players = $queryBuilder->select('p')->from('DraftBundle:Player', 'p')->setMaxResults(1)->getQuery()->execute();
     if (is_array($players)) {
         $player = $players[0];
     } else {
         $player = $players;
     }
     $name = $player->getName();
     $team = $player->getNflTeam();
     $position = $player->getPosition();
     $toEncode = array('name' => 'willy wonka', 'position' => 'QB', 'nflTeam' => 'SF', 'draftYear' => '2016');
     $postData = json_encode($toEncode);
     $this->client->request('PUT', '/api/players/' . $player->getId(), array(), array(), array('CONTENT_TYPE' => 'application/json'), $postData);
     $response = $this->client->getResponse();
     $content = $response->getContent();
     $this->assertTrue($response->isSuccessful());
     $this->assertEmpty($content);
     $updatedPlayer = $em->getRepository('DraftBundle:Player')->find($player->getId());
     $this->assertEquals('willy wonka', $updatedPlayer->getName());
     $updatedPlayer->setName($name);
     $updatedPlayer->setNflTeam($team);
     $updatedPlayer->setPosition($position);
     $em->persist($updatedPlayer);
     $em->flush();
 }
开发者ID:buphmin,项目名称:RookieDraft,代码行数:28,代码来源:PlayerControllerTest.php


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