10
10
namespace ZendTest \Mvc \View \Console ;
11
11
12
12
use PHPUnit_Framework_TestCase as TestCase ;
13
+ use Zend \Console \Adapter \AbstractAdapter ;
13
14
use Zend \EventManager \EventManager ;
15
+ use Zend \Mvc \ApplicationInterface ;
14
16
use Zend \Mvc \MvcEvent ;
15
17
use Zend \Mvc \View \Console \DefaultRenderingStrategy ;
16
18
use Zend \ServiceManager \ServiceManager ;
@@ -36,6 +38,8 @@ public function testAttachesRendererAtExpectedPriority()
36
38
$ expectedCallback = [$ this ->strategy , 'render ' ];
37
39
$ expectedPriority = -10000 ;
38
40
$ found = false ;
41
+
42
+ /* @var \Zend\Stdlib\CallbackHandler $listener */
39
43
foreach ($ listeners as $ listener ) {
40
44
$ callback = $ listener ->getCallback ();
41
45
if ($ callback === $ expectedCallback ) {
@@ -60,24 +64,22 @@ public function testCanDetachListenersFromEventManager()
60
64
61
65
public function testIgnoresNonConsoleModelNotContainingResultKeyWhenObtainingResult ()
62
66
{
63
- $ console = $ this ->getMock (' Zend\Console\Adapter\ AbstractAdapter' );
67
+ $ console = $ this ->getMock (AbstractAdapter::class );
64
68
$ console
65
69
->expects ($ this ->any ())
66
70
->method ('encodeText ' )
67
- ->willReturnArgument (0 )
68
- ;
71
+ ->willReturnArgument (0 );
69
72
70
73
//Register console service
71
74
$ sm = new ServiceManager ();
72
75
$ sm ->setService ('console ' , $ console );
73
76
74
- /** @var \PHPUnit_Framework_MockObject_MockObject|\Zend\Mvc\ ApplicationInterface $mockApplication */
75
- $ mockApplication = $ this ->getMock (' Zend\Mvc\ ApplicationInterface' );
77
+ /* @var \PHPUnit_Framework_MockObject_MockObject|ApplicationInterface $mockApplication */
78
+ $ mockApplication = $ this ->getMock (ApplicationInterface::class );
76
79
$ mockApplication
77
80
->expects ($ this ->any ())
78
81
->method ('getServiceManager ' )
79
- ->willReturn ($ sm )
80
- ;
82
+ ->willReturn ($ sm );
81
83
82
84
$ event = new MvcEvent ();
83
85
$ event ->setApplication ($ mockApplication );
@@ -90,4 +92,33 @@ public function testIgnoresNonConsoleModelNotContainingResultKeyWhenObtainingRes
90
92
$ content = $ response ->getContent ();
91
93
$ this ->assertNotContains ('Page not found ' , $ content );
92
94
}
95
+
96
+ public function testIgnoresNonModel ()
97
+ {
98
+ $ console = $ this ->getMock (AbstractAdapter::class);
99
+ $ console
100
+ ->expects ($ this ->any ())
101
+ ->method ('encodeText ' )
102
+ ->willReturnArgument (0 );
103
+
104
+ //Register console service
105
+ $ sm = new ServiceManager ();
106
+ $ sm ->setService ('console ' , $ console );
107
+
108
+ /* @var \PHPUnit_Framework_MockObject_MockObject|ApplicationInterface $mockApplication */
109
+ $ mockApplication = $ this ->getMock (ApplicationInterface::class);
110
+ $ mockApplication
111
+ ->expects ($ this ->any ())
112
+ ->method ('getServiceManager ' )
113
+ ->willReturn ($ sm );
114
+
115
+ $ event = new MvcEvent ();
116
+ $ event ->setApplication ($ mockApplication );
117
+
118
+ $ model = true ;
119
+ $ response = new Response ();
120
+ $ event ->setResult ($ model );
121
+ $ event ->setResponse ($ response );
122
+ $ this ->assertSame ($ response , $ this ->strategy ->render ($ event ));
123
+ }
93
124
}
0 commit comments