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


PHP Application::get方法代码示例

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


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

示例1: testError

 /**
  * @dataProvider provideExceptionsAndCode
  */
 public function testError($exception, $code)
 {
     $app = new Application('test');
     $app['dispatcher']->addSubscriber(new ApiExceptionHandlerSubscriber($app));
     $app->get('/', function () use($exception) {
         throw $exception;
     });
     $client = new Client($app);
     $client->request('GET', '/');
     $this->assertEquals($code, $client->getResponse()->getStatusCode());
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:14,代码来源:ApiExceptionHandlerSubscriberTest.php

示例2: request

 private function request($accept)
 {
     $app = new Application(Application::ENV_TEST);
     $app['dispatcher']->addSubscriber(new ContentNegotiationSubscriber($app['negotiator'], $app['phraseanet.content-negotiation.priorities']));
     $app->get('/content/negociation', function () {
         return '';
     });
     $client = new Client($app);
     $client->request('GET', '/content/negociation', array(), array(), array('HTTP_Accept' => $accept));
     return $client->getResponse();
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:11,代码来源:ContentNegotiationSubscriberTest.php

示例3: request

 private function request($accept)
 {
     $app = new Application('test');
     $app['dispatcher']->addSubscriber(new ContentNegotiationSubscriber($app));
     $app->get('/content/negociation', function () {
         return '';
     });
     $client = new Client($app);
     $client->request('GET', '/content/negociation', array(), array(), array('HTTP_Accept' => $accept));
     return $client->getResponse();
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:11,代码来源:ContentNegotiationSubscriberTest.php

示例4: testErrorOnOtherRoutes

 /**
  * @dataProvider provideExceptionsAndCode
  */
 public function testErrorOnOtherRoutes($exception, $code, $contentType)
 {
     $app = new Application('test');
     unset($app['exception_handler']);
     $app['dispatcher']->addSubscriber(new ApiOauth2ErrorsSubscriber(PhraseaExceptionHandler::register(), $this->createTranslatorMock()));
     $app->get('/', function () use($exception) {
         throw $exception;
     });
     $client = new Client($app);
     $this->setExpectedException(get_class($exception));
     $client->request('GET', '/');
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:15,代码来源:ApiOauth2ErrorsSubscriberTest.php

示例5: testItCanBeDisabled

 public function testItCanBeDisabled()
 {
     $app = new Application();
     $app['exception_handler'] = new PhraseaExceptionHandlerSubscriber(PhraseaExceptionHandler::register());
     $app->get('/', function () {
         throw new \Exception();
     });
     $app['exception_handler']->disable();
     $client = new Client($app);
     $this->setExpectedException('\\Exception');
     $client->request('GET', '/');
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:12,代码来源:PhraseaExceptionHandlerSubscriberTest.php

示例6: request

 /**
  * @param array  $conf
  * @param string $method
  * @param array  $extraHeaders
  *
  * @return \Symfony\Component\HttpFoundation\Response
  */
 private function request(array $conf, $method = 'GET', array $extraHeaders = [])
 {
     $app = new Application('test');
     $app['phraseanet.configuration']['api_cors'] = $conf;
     $app['dispatcher']->addSubscriber(new ApiCorsSubscriber($app));
     $app->get('/api/v1/test-route', function () {
         return '';
     });
     $client = new Client($app);
     $client->request($method, '/api/v1/test-route', [], [], array_merge($extraHeaders, ['HTTP_Origin' => $this->origin]));
     return $client->getResponse();
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:19,代码来源:ApiCorsSubscriberTest.php

示例7: testNoHeaderNoRedirection

 public function testNoHeaderNoRedirection()
 {
     $app = new Application();
     unset($app['exception_handler']);
     $app['dispatcher']->addSubscriber(new FirewallSubscriber());
     $app->get('/', function () {
         throw new HttpException(500);
     });
     $client = new Client($app);
     $this->setExpectedException('Symfony\\Component\\HttpKernel\\Exception\\HttpException');
     $client->request('GET', '/');
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:12,代码来源:FirewallSubscriberTest.php

示例8: testErrorOnOtherExceptions

 public function testErrorOnOtherExceptions()
 {
     $app = new Application('test');
     $app['bridge.account'] = $this->getMockBuilder('Bridge_Account')->disableOriginalConstructor()->getMock();
     unset($app['exception_handler']);
     $app['dispatcher']->addSubscriber(new BridgeExceptionSubscriber($app));
     $app->get('/', function () {
         throw new \InvalidArgumentException();
     });
     $client = new Client($app);
     $this->setExpectedException('\\InvalidArgumentException');
     $client->request('GET', '/');
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:13,代码来源:BridgeExceptionSubscriberTest.php

示例9: testError

 /**
  * @dataProvider provideExceptionsAndCode
  */
 public function testError($exception, $code)
 {
     $app = new Application('test');
     $app['api'] = function () use($app) {
         return new \API_V1_adapter($app);
     };
     $app->register(new \API_V1_Timer());
     $app['dispatcher']->addSubscriber(new ApiExceptionHandlerSubscriber($app));
     $app->get('/', function () use($exception) {
         throw $exception;
     });
     $client = new Client($app);
     $client->request('GET', '/');
     $this->assertEquals($code, $client->getResponse()->getStatusCode());
     $this->assertEquals('application/json', $client->getResponse()->headers->get('content-type'));
 }
开发者ID:romainneutron,项目名称:Phraseanet,代码行数:19,代码来源:ApiExceptionHandlerSubscriberTest.php

示例10: testRoutes

 /**
  * @dataProvider provideVariousRoutes
  */
 public function testRoutes($disabled, $route)
 {
     $app = new Application();
     $app['dispatcher']->addSubscriber(new CookiesDisablerSubscriber($app));
     $app->get($route, function () {
         $response = new Response();
         $response->headers->setCookie(new Cookie('key', 'value'));
         return $response;
     });
     $client = $this->getClientWithCookie($app);
     $client->request('GET', $route);
     $this->assertSame($disabled, $app['session.test']);
     if ($disabled) {
         $this->assertCount(0, $client->getResponse()->headers->getCookies(ResponseHeaderBag::COOKIES_ARRAY));
     } else {
         $this->assertGreaterThanOrEqual(1, count($client->getResponse()->headers->getCookies(ResponseHeaderBag::COOKIES_ARRAY)));
     }
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:21,代码来源:CookiesDisablerSubscriberTest.php

示例11: testIpsAndEnvironments

 /**
  * @dataProvider provideIpsAndEnvironments
  */
 public function testIpsAndEnvironments($exceptionThrown, $env, $incomingIp, $authorized)
 {
     $app = new Application($env);
     unset($app['exception_handler']);
     $app['phraseanet.configuration.config-path'] = __DIR__ . '/Fixtures/configuration-debugger.yml';
     $app['phraseanet.configuration.config-compiled-path'] = __DIR__ . '/Fixtures/configuration-debugger.php';
     if (is_file($app['phraseanet.configuration.config-compiled-path'])) {
         unlink($app['phraseanet.configuration.config-compiled-path']);
     }
     $app['conf']->set(['debugger', 'allowed-ips'], $authorized);
     $app['dispatcher']->addSubscriber(new DebuggerSubscriber($app));
     $app->get('/', function () {
         return 'success';
     });
     $app->boot();
     if ($exceptionThrown) {
         $this->setExpectedException('Symfony\\Component\\HttpKernel\\Exception\\AccessDeniedHttpException');
     }
     $app->handle(new Request([], [], [], [], [], ['REMOTE_ADDR' => $incomingIp]));
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:23,代码来源:DebuggerSubscriberTest.php

示例12: testCheckPositive

 public function testCheckPositive()
 {
     $app = new Application();
     $app['phraseanet.configuration.config-path'] = __DIR__ . '/Fixtures/configuration-maintenance.yml';
     $app['phraseanet.configuration.config-compiled-path'] = __DIR__ . '/Fixtures/configuration-maintenance.php';
     if (is_file($app['phraseanet.configuration.config-compiled-path'])) {
         unlink($app['phraseanet.configuration.config-compiled-path']);
     }
     unset($app['exception_handler']);
     $app['dispatcher']->addSubscriber(new MaintenanceSubscriber($app));
     $app->get('/', function () {
         return 'Hello';
     });
     $client = new Client($app);
     try {
         $client->request('GET', '/');
         $this->fail('An exception should have been raised');
     } catch (HttpException $e) {
         $this->assertEquals(503, $e->getStatusCode());
         $this->assertEquals(['Retry-After' => 3600], $e->getHeaders());
     }
 }
开发者ID:romainneutron,项目名称:Phraseanet,代码行数:22,代码来源:MaintenanceSubscriberTest.php

示例13: testRoutes

 /**
  * @dataProvider provideRouteParameters
  */
 public function testRoutes($route, $isJson, $exceptionExpected)
 {
     $app = new Application();
     unset($app['exception_handler']);
     $app['dispatcher']->addSubscriber(new JsonRequestSubscriber());
     $app->get($route, function () {
         throw new \Exception('I disagree');
     });
     $client = new Client($app);
     $headers = $isJson ? ['HTTP_ACCEPT' => 'application/json'] : [];
     if ($exceptionExpected) {
         $this->setExpectedException('Exception');
     }
     $client->request('GET', $route, [], [], $headers);
     if (!$exceptionExpected) {
         $this->assertEquals(200, $client->getResponse()->getStatusCode());
         $this->assertEquals('application/json', $client->getResponse()->headers->get('content-type'));
         $data = json_decode($client->getResponse()->getContent(), true);
         $this->assertArrayHasKey('success', $data);
         $this->assertArrayHasKey('message', $data);
         $this->assertFalse($data['success']);
     }
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:26,代码来源:JsonRequestSubscriberTest.php

示例14: getApp

 private function getApp()
 {
     $app = new Application(Application::ENV_TEST);
     $app->get('/', function (Application $app, Request $request) {
         $app['session']->set('usr_id', 5);
         $response = new Response('hello');
         $response->headers->setCookie(new Cookie('key', 'value'));
         return $response;
     });
     unset($app['exception_handler']);
     return $app;
 }
开发者ID:luisbrito,项目名称:Phraseanet,代码行数:12,代码来源:ApplicationTest.php

示例15: testForbiddenRoutes

 /**
  * @dataProvider forbiddenRouteProvider
  */
 public function testForbiddenRoutes($route)
 {
     $app = new Application('test');
     $app['dispatcher']->addSubscriber(new SessionManagerSubscriber($app));
     $app['authentication'] = $this->getMockBuilder('Alchemy\\Phrasea\\Authentication\\Authenticator')->disableOriginalConstructor()->getMock();
     $app['authentication']->expects($this->never())->method('isAuthenticated');
     $app['EM'] = $this->getMockBuilder('Doctrine\\ORM\\EntityManager')->disableOriginalConstructor()->getMock();
     $app['EM']->expects($this->never())->method('flush');
     $app->get('/login', function () {
         return '';
     })->bind("homepage");
     $app->get($route, function () {
         return '';
     });
     $client = new Client($app);
     $client->request('GET', $route, [], [], ['HTTP_CONTENT-TYPE' => 'application/json', 'HTTP_ACCEPT' => 'application/json', 'HTTP_X-Requested-With' => 'XMLHttpRequest']);
 }
开发者ID:nlegoff,项目名称:Phraseanet,代码行数:20,代码来源:SessionManagerSubscriberTest.php


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