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