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


PHP ResponseHeaderBag::__toString方法代码示例

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


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

示例1: testToStringIncludesCookieHeaders

 public function testToStringIncludesCookieHeaders()
 {
     $bag = new ResponseHeaderBag(array());
     $bag->setCookie(new Cookie('foo', 'bar'));
     $this->assertContains("Set-Cookie: foo=bar; path=/; httponly", explode("\r\n", $bag->__toString()));
     $bag->clearCookie('foo');
     $this->assertContains("Set-Cookie: foo=deleted; expires=" . gmdate("D, d-M-Y H:i:s T", time() - 31536001) . "; httponly", explode("\r\n", $bag->__toString()));
 }
开发者ID:nightchiller,项目名称:symfony,代码行数:8,代码来源:ResponseHeaderBagTest.php

示例2: testCookiesWithSameNames

 public function testCookiesWithSameNames()
 {
     $bag = new ResponseHeaderBag();
     $bag->setCookie(new Cookie('foo', 'bar', 0, '/path/foo', 'foo.bar'));
     $bag->setCookie(new Cookie('foo', 'bar', 0, '/path/bar', 'foo.bar'));
     $bag->setCookie(new Cookie('foo', 'bar', 0, '/path/bar', 'bar.foo'));
     $bag->setCookie(new Cookie('foo', 'bar'));
     $this->assertEquals(4, count($bag->getCookies()));
     $headers = explode("\r\n", $bag->__toString());
     $this->assertContains("Set-Cookie: foo=bar; path=/path/foo; domain=foo.bar; httponly", $headers);
     $this->assertContains("Set-Cookie: foo=bar; path=/path/foo; domain=foo.bar; httponly", $headers);
     $this->assertContains("Set-Cookie: foo=bar; path=/path/bar; domain=bar.foo; httponly", $headers);
     $this->assertContains("Set-Cookie: foo=bar; path=/; httponly", $headers);
     $cookies = $bag->getCookies(ResponseHeaderBag::COOKIES_ARRAY);
     $this->assertTrue(isset($cookies['foo.bar']['/path/foo']['foo']));
     $this->assertTrue(isset($cookies['foo.bar']['/path/bar']['foo']));
     $this->assertTrue(isset($cookies['bar.foo']['/path/bar']['foo']));
     $this->assertTrue(isset($cookies['']['/']['foo']));
 }
开发者ID:nizam-uddin,项目名称:symfony,代码行数:19,代码来源:ResponseHeaderBagTest.php


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