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