1+ <?php
2+
3+ namespace PHPixie \Tests \HTTP ;
4+
5+ /**
6+ * @coversDefaultClass PHPixie\HTTP\Output
7+ */
8+ class OutputTest extends \PHPixie \Test \Testcase
9+ {
10+ protected $ output ;
11+
12+ public function setUp ()
13+ {
14+ $ this ->output = $ this ->getMock (
15+ '\PHPixie\HTTP\Output ' ,
16+ array (),
17+ array (
18+ 'header ' ,
19+ 'setCookie ' ,
20+ 'fpassthru ' ,
21+ 'echo '
22+ )
23+ );
24+ }
25+
26+ /**
27+ * @covers ::response
28+ * @covers ::<protected>
29+ */
30+ public function testResponse ()
31+ {
32+ $ headers = array (
33+ 'pixie ' => array (
34+ 'Trixie ' ,
35+ 'Blum '
36+ ),
37+ 'fairy ' => array (
38+ 'Stella '
39+ )
40+ );
41+ $ body = $ this ->getStream ();
42+
43+ $ response = $ this ->response (
44+ $ headers ,
45+ $ body ,
46+ 200 ,
47+ 'OK '
48+ );
49+ }
50+
51+ protected function response ($ headerArray , $ body , $ statusCode , $ reasonPhrase )
52+ {
53+ $ headers = $ this ->getHeaders ();
54+ $ this ->method ($ headers , 'headerArray ' , $ headerArray , array ());
55+
56+ $ response = $ this ->quickMock ('\PHPixie\HTTP\Responses\Response ' );
57+ $ methods = array (
58+ 'headers ' => $ headers ,
59+ 'body ' => $ body ,
60+ 'statusCode ' => $ statusCode ,
61+ 'reasonPhrase ' => $ reasonPhrase
62+ );
63+ foreach ($ methods as $ method => $ value ) {
64+ $ this ->method ($ response , $ method , $ value , array ());
65+ }
66+
67+ return $ response ;
68+ }
69+
70+ protected function getHeaders ()
71+ {
72+ return $ this ->quickMock ('\PHPixie\HTTP\Data\Headers ' );
73+ }
74+
75+ protected function getStream ()
76+ {
77+ return $ this ->quickMock ('\Psr\Http\Message\StreamInterface ' );
78+ }
79+
80+ protected function getContext ()
81+ {
82+ return $ this ->quickMock ('\PHPixie\HTTP\Context ' );
83+ }
84+
85+ protected function getCookies ()
86+ {
87+ return $ this ->quickMock ('\PHPixie\HTTP\Context\Cookies ' );
88+ }
89+
90+ protected function getCookieUpdate ()
91+ {
92+ return $ this ->quickMock ('\PHPixie\HTTP\Context\Cookies\Update ' );
93+ }
94+
95+ }
0 commit comments