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


PHP Client::getProfile方法代码示例

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


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

示例1: testSecuredEventWithImpersonatingUser

 /**
  *  @group failing
  * @runInSeparateProcess
  */
 public function testSecuredEventWithImpersonatingUser()
 {
     $this->client = $this->createAuthenticatedClient('admin');
     $name = 'simple.event';
     $crawler = $this->client->request('GET', "/some-secure-url/{$name}?_switch_user=user");
     $this->assertTrue($this->client->getResponse()->isSuccessful());
     $this->assertEquals('user', $this->client->getProfile()->getCollector('security')->getUser());
     $event = $this->getEventArrayFromResponse($crawler);
     $this->assertEquals($name, $event['typeId']);
     $this->assertEquals($name, $event['type']);
     $this->assertEquals($name, $event['description']);
     $this->assertEquals('admin', $event['impersonatingUser']);
     $this->assertEquals('user', $event['user']);
     $this->assertEquals('127.0.0.1', $event['ip']);
 }
开发者ID:xiidea,项目名称:easy-audit,代码行数:19,代码来源:ImpersonatingUserTest.php

示例2: 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

示例3: testSubmit

 public function testSubmit()
 {
     $user = $this->testUtils->createUser()->getUser();
     /** @var EntityManager $entityManager */
     $entityManager = static::$kernel->getContainer()->get('doctrine.orm.entity_manager');
     $contactRepository = $entityManager->getRepository('AppBundle:Contact');
     $this->assertEmpty($contactRepository->findBy(['email' => $user->getEmail()]));
     $crawler = $this->client->request('GET', '/contact');
     $form = $crawler->filter('form')->form();
     $message = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec at ornare lacus. ' . 'Mauris semper lacus a metus malesuada, at malesuada elit condimentum. ' . 'Proin euismod tellus vitae dolor vestibulum metus.';
     $form['form[message]'] = $message;
     $this->client->enableProfiler();
     // permet de profiler les mails qui vont être envoyés
     $this->client->submit($form);
     $this->assertEquals(Response::HTTP_FOUND, $this->client->getResponse()->getStatusCode());
     $this->testUtils->clearEntities();
     // On vérifie que le contact est en bdd
     /** @var Contact[] $contacts */
     $contacts = $contactRepository->findBy(['email' => $user->getEmail()]);
     $this->assertEquals(1, count($contacts));
     $this->assertEquals($message, $contacts[0]->getMessage());
     $this->assertEquals($user->getId(), $contacts[0]->getUser()->getId());
     /** @var MessageDataCollector $mailCollector */
     $mailCollector = $this->client->getProfile()->getCollector('swiftmailer');
     // 2 mails ont du être envoyés
     $this->assertEquals(2, $mailCollector->getMessageCount());
     $collectedMessages = $mailCollector->getMessages();
     // Le 1er est l'accusé réception à l'utilisateur
     /** @var Swift_Message $accuseReception */
     $accuseReception = $collectedMessages[0];
     $this->assertEquals('Formulaire de contact', $accuseReception->getSubject());
     $this->assertEquals('no-reply@zigotoo.com', key($accuseReception->getFrom()));
     $this->assertEquals('Zigotoo', current($accuseReception->getFrom()));
     $this->assertEquals($user->getEmail(), key($accuseReception->getTo()));
     $this->assertContains($message, $accuseReception->getBody(), 'L\'accusé de réception ne contient pas le message');
     // Le 2eme est une notififaction aux admins
     /** @var Swift_Message $mailAdmins */
     $mailAdmins = $collectedMessages[1];
     $this->assertEquals('Reception formulaire de contact', $mailAdmins->getSubject());
     $this->assertEquals('app@zigotoo.com', key($mailAdmins->getFrom()));
     $this->assertEquals(['pflieger.arnaud@gmail.com', 'MehdiBelkacemi@gmail.com'], array_keys($mailAdmins->getTo()));
     $this->assertContains($message, $mailAdmins->getBody());
     $this->assertContains($user->getEmail(), $mailAdmins->getBody());
 }
开发者ID:apflieger,项目名称:zigotoo,代码行数:44,代码来源:ContactControllerTest.php

示例4: checkEventIsCaught

 /**
  * @param  Client     $client
  * @throws \Exception
  */
 public function checkEventIsCaught(Client $client)
 {
     $profile = $client->getProfile();
     if (!$profile) {
         throw new \Exception("Hey Poser! The profiler should be enabled if you want to check events");
     }
     $eventCollector = $profile->getCollector('events');
     $eventName = 'kernel.controller.PUGX\\StatsBundle\\Listener\\StatsListener::onKernelController';
     $this->assertArrayHasKey($eventName, $eventCollector->getCalledListeners(), "stats listener has been called");
 }
开发者ID:kartik-v,项目名称:badge-poser,代码行数:14,代码来源:StatsFunctionalTest.php

示例5: verifyUserNotCreatedAndNoMailSent

 private function verifyUserNotCreatedAndNoMailSent(\Symfony\Bundle\FrameworkBundle\Client $client)
 {
     $container = $client->getContainer();
     $em = $container->get('doctrine.orm.entity_manager');
     $repo = $em->getRepository('AppBundle\\Entity\\Customer');
     $customers = $repo->findBy(['email' => 'example@example.org']);
     $this->assertSame(0, sizeof($customers));
     $mailCollector = $client->getProfile()->getCollector('swiftmailer');
     $this->assertEquals(0, $mailCollector->getMessageCount());
 }
开发者ID:Galeria-Kaufhof,项目名称:goodbuy-metro,代码行数:10,代码来源:RegistrationTest.php

示例6: testSendAuthLink

 public function testSendAuthLink()
 {
     // Enable the profiler for the next request (it does nothing if the profiler is not available)
     static::$client->enableProfiler();
     static::$client->request('POST', '/ex-google-analytics/send-external-link', [], [], [], json_encode(['url' => 'https://syrup.keboola.com/ex-google-analytics/external-auth?token=123-456789-abcdefgh', 'user' => 'Test', 'email' => 'test@keboola.com', 'message' => 'test message']));
     $response = json_decode(static::$client->getResponse()->getContent(), true);
     $this->assertArrayHasKey('status', $response);
     $this->assertEquals('ok', $response['status']);
     /** @var MessageDataCollector $mailCollector */
     $mailCollector = self::$client->getProfile()->getCollector('swiftmailer');
     // Check that an e-mail was sent
     $this->assertEquals(1, $mailCollector->getMessageCount());
     $collectedMessages = $mailCollector->getMessages();
     $message = $collectedMessages[0];
     // Asserting e-mail data
     $this->assertInstanceOf('Swift_Message', $message);
     $this->assertEquals('Keboola Google Analytics Extractor account authorization', $message->getSubject());
     $this->assertEquals('support@keboola.com', key($message->getFrom()));
     $this->assertEquals('test@keboola.com', key($message->getTo()));
 }
开发者ID:keboola,项目名称:google-analytics-bundle,代码行数:20,代码来源:MailerTest.php

示例7: submitRequest

 /**
  * @When /^I submit a request to "(.*)"$/
  *
  * @param string $request
  */
 public function submitRequest(string $request)
 {
     list($method, $url) = $this->analyzeURLInput($request);
     if ($this->profilerEnabled) {
         $this->client->enableProfiler();
     }
     $this->client->request($method, $url, $this->requestPayload, [], $this->apiKey ? ['HTTP_X-API-KEY' => $this->apiKey] : []);
     $response = $this->client->getResponse();
     $this->response = $this->decode($response->getContent());
     $this->responseCode = $response->getStatusCode();
     if ($this->profilerEnabled) {
         $this->profiler = $this->client->getProfile();
     }
 }
开发者ID:sententiaregum,项目名称:sententiaregum,代码行数:19,代码来源:ApiContext.php

示例8: getProfile

 /**
  * Gets the profile associated with the current Response.
  *
  * @return HttpProfile A Profile instance
  */
 public function getProfile()
 {
     return $this->subject->getProfile();
 }
开发者ID:kleijnweb,项目名称:swagger-bundle,代码行数:9,代码来源:ApiTestClient.php


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