This repository was archived by the owner on May 1, 2019. It is now read-only.
File tree 1 file changed +64
-0
lines changed
module/ZfModule/test/ZfModuleTest/Integration/Controller
1 file changed +64
-0
lines changed Original file line number Diff line number Diff line change 4
4
5
5
use ApplicationTest \Integration \Util \Bootstrap ;
6
6
use Zend \Http ;
7
+ use Zend \Mvc ;
7
8
use Zend \Paginator ;
8
9
use Zend \Test \PHPUnit \Controller \AbstractHttpControllerTestCase ;
9
10
use ZfModule \Controller ;
10
11
use ZfModule \Mapper ;
11
12
13
+ /**
14
+ * @method Mvc\Application getApplication()
15
+ */
12
16
class UserControllerTest extends AbstractHttpControllerTestCase
13
17
{
14
18
protected function setUp ()
@@ -63,4 +67,64 @@ public function testUserPageCanBeAccessed()
63
67
$ this ->assertActionName ('modulesForUser ' );
64
68
$ this ->assertResponseStatusCode (Http \Response::STATUS_CODE_200 );
65
69
}
70
+
71
+ /**
72
+ * @dataProvider providerInvalidUserName
73
+ *
74
+ * @param string $userName
75
+ */
76
+ public function testModulesForUserDoesNotMatchOnInvalidUserName ($ userName )
77
+ {
78
+ $ moduleMapper = $ this ->getMockBuilder (Mapper \Module::class)->getMock ();
79
+
80
+ $ moduleMapper
81
+ ->expects ($ this ->any ())
82
+ ->method ('pagination ' )
83
+ ->with (
84
+ $ this ->equalTo (1 ),
85
+ $ this ->equalTo (10 ),
86
+ $ this ->equalTo ($ userName ),
87
+ $ this ->equalTo ('created_at ' ),
88
+ $ this ->equalTo ('DESC ' )
89
+ )
90
+ ->willReturn (new Paginator \Paginator (new Paginator \Adapter \Null ()))
91
+ ;
92
+
93
+ $ moduleMapper
94
+ ->expects ($ this ->any ())
95
+ ->method ('findAll ' )
96
+ ->willReturn ([])
97
+ ;
98
+
99
+ $ this ->getApplicationServiceLocator ()
100
+ ->setAllowOverride (true )
101
+ ->setService (
102
+ Mapper \Module::class,
103
+ $ moduleMapper
104
+ )
105
+ ;
106
+
107
+ $ url = sprintf (
108
+ '/user/%s ' ,
109
+ $ userName
110
+ );
111
+
112
+ $ this ->dispatch ($ url );
113
+
114
+ $ event = $ this ->getApplication ()->getMvcEvent ();
115
+
116
+ $ this ->assertSame (Mvc \Application::ERROR_ROUTER_NO_MATCH , $ event ->getError ());
117
+ }
118
+
119
+ /**
120
+ * @return array
121
+ */
122
+ public function providerInvalidUserName ()
123
+ {
124
+ return [
125
+ [
126
+ '9 ' ,
127
+ ],
128
+ ];
129
+ }
66
130
}
You can’t perform that action at this time.
0 commit comments