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


PHP View::setLocation方法代码示例

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


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

示例1: testCreateResponseWithLocation

 /**
  * @dataProvider createResponseWithLocationDataProvider
  */
 public function testCreateResponseWithLocation($expected, $format, $forceRedirects, $noContentCode)
 {
     $viewHandler = new ViewHandler(array('html' => true, 'json' => false, 'xml' => false), Codes::HTTP_BAD_REQUEST, $noContentCode, false, $forceRedirects);
     $view = new View();
     $view->setLocation('foo');
     $returnedResponse = $viewHandler->createResponse($view, new Request(), $format);
     $this->assertEquals($expected, $returnedResponse->getStatusCode());
     $this->assertEquals('foo', $returnedResponse->headers->get('location'));
 }
开发者ID:shreyans264,项目名称:symfonyPlayGround,代码行数:12,代码来源:ViewHandlerTest.php

示例2: testSetLocation

 public function testSetLocation()
 {
     $url = 'users';
     $code = 500;
     $view = View::createRedirect($url, $code);
     $this->assertAttributeEquals($url, 'location', $view);
     $this->assertAttributeEquals(null, 'route', $view);
     $this->assertEquals($code, $view->getResponse()->getStatusCode());
     $view = new View();
     $location = 'location';
     $view->setLocation($location);
     $this->assertEquals($location, $view->getLocation());
 }
开发者ID:LamaDelRay,项目名称:test_symf,代码行数:13,代码来源:ViewTest.php

示例3: testCreateResponseWithLocationAndData

 public function testCreateResponseWithLocationAndData()
 {
     $testValue = array('naviter' => 'oudie');
     $container = $this->getMock('Symfony\\Component\\DependencyInjection\\Container', array('get'));
     $this->setupMockedSerializer($container, $testValue);
     $viewHandler = new ViewHandler(array('json' => false));
     $viewHandler->setContainer($container);
     $view = new View();
     $view->setStatusCode(Codes::HTTP_CREATED);
     $view->setLocation('foo');
     $view->setData($testValue);
     $returnedResponse = $viewHandler->createResponse($view, new Request(), 'json');
     $this->assertEquals('foo', $returnedResponse->headers->get('location'));
     $this->assertEquals(var_export($testValue, true), $returnedResponse->getContent());
 }
开发者ID:mgldev,项目名称:coffeetrack,代码行数:15,代码来源:ViewHandlerTest.php

示例4: testCreateResponseWithLocationAndData

 public function testCreateResponseWithLocationAndData()
 {
     $testValue = ['naviter' => 'oudie'];
     $this->setupMockedSerializer($testValue);
     $viewHandler = $this->createViewHandler(['json' => false]);
     $view = new View();
     $view->setStatusCode(Response::HTTP_CREATED);
     $view->setLocation('foo');
     $view->setData($testValue);
     $returnedResponse = $viewHandler->createResponse($view, new Request(), 'json');
     $this->assertEquals('foo', $returnedResponse->headers->get('location'));
     $this->assertEquals(var_export($testValue, true), $returnedResponse->getContent());
 }
开发者ID:sblaut,项目名称:FOSRestBundle,代码行数:13,代码来源:ViewHandlerTest.php

示例5: testCreateResponseWithLocationAndData

 public function testCreateResponseWithLocationAndData()
 {
     $testValue = ['naviter' => 'oudie'];
     $container = $this->getMock(Container::class, ['get']);
     $this->setupMockedSerializer($container, $testValue);
     $viewHandler = new ViewHandler(['json' => false]);
     $viewHandler->setSerializationContextAdapter($this->getMock('FOS\\RestBundle\\Context\\Adapter\\SerializationContextAdapterInterface'));
     $viewHandler->setContainer($container);
     $view = new View();
     $view->setStatusCode(Response::HTTP_CREATED);
     $view->setLocation('foo');
     $view->setData($testValue);
     $returnedResponse = $viewHandler->createResponse($view, new Request(), 'json');
     $this->assertEquals('foo', $returnedResponse->headers->get('location'));
     $this->assertEquals(var_export($testValue, true), $returnedResponse->getContent());
 }
开发者ID:francescolaffi,项目名称:FOSRestBundle,代码行数:16,代码来源:ViewHandlerTest.php


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