77use PHPUnit \Framework \TestCase ;
88use Redmine \Api \Issue ;
99use Redmine \Api \IssueCategory ;
10+ use Redmine \Api \IssueStatus ;
1011use Redmine \Client \Client ;
1112use Redmine \Http \HttpClient ;
1213use Redmine \Http \Response ;
14+ use Redmine \Tests \Fixtures \AssertingHttpClient ;
1315use Redmine \Tests \Fixtures \MockClient ;
1416
1517/**
@@ -146,7 +148,7 @@ public function testCreateWithClientCleansParameters()
146148 $ parameters = [
147149 'project ' => 'Project Name ' ,
148150 'category ' => 'Category 5 Name ' ,
149- 'status ' => 'Status Name ' ,
151+ 'status ' => 'Status 6 Name ' ,
150152 'tracker ' => 'Tracker Name ' ,
151153 'assigned_to ' => 'Assigned to User Name ' ,
152154 'author ' => 'Author Name ' ,
@@ -158,28 +160,35 @@ public function testCreateWithClientCleansParameters()
158160 ->method ('getIdByName ' )
159161 ->willReturn (1 );
160162 $ getIdByNameApi = $ this ->createMock ('Redmine\Api\Tracker ' );
161- $ getIdByNameApi ->expects ($ this ->exactly (2 ))
163+ $ getIdByNameApi ->expects ($ this ->exactly (1 ))
162164 ->method ('getIdByName ' )
163165 ->willReturn ('cleanedValue ' );
164166 $ getIdByUsernameApi = $ this ->createMock ('Redmine\Api\User ' );
165167 $ getIdByUsernameApi ->expects ($ this ->exactly (2 ))
166168 ->method ('getIdByUsername ' )
167169 ->willReturn ('cleanedValue ' );
168170
169- $ httpClient = $ this ->createMock (HttpClient::class);
170- $ httpClient ->expects ($ this ->exactly (1 ))
171- ->method ('request ' )
172- ->willReturn (
173- $ this ->createConfiguredMock (
174- Response::class,
175- [
176- 'getStatusCode ' => 200 ,
177- 'getContentType ' => 'application/json ' ,
178- 'getContent ' => '{"issue_categories":[{"id":5,"name":"Category 5 Name"}]} ' ,
179- ],
180- ),
181- )
182- ;
171+ $ httpClient = AssertingHttpClient::create (
172+ $ this ,
173+ [
174+ 'GET ' ,
175+ '/projects/1/issue_categories.json ' ,
176+ 'application/json ' ,
177+ '' ,
178+ 200 ,
179+ 'application/json ' ,
180+ '{"issue_categories":[{"id":5,"name":"Category 5 Name"}]} ' ,
181+ ],
182+ [
183+ 'GET ' ,
184+ '/issue_statuses.json ' ,
185+ 'application/json ' ,
186+ '' ,
187+ 200 ,
188+ 'application/json ' ,
189+ '{"issue_statuses":[{"id":6,"name":"Status 6 Name"}]} ' ,
190+ ],
191+ );
183192
184193 $ client = $ this ->createMock (Client::class);
185194 $ client ->expects ($ this ->exactly (5 ))
@@ -188,7 +197,7 @@ public function testCreateWithClientCleansParameters()
188197 [
189198 ['project ' , $ projectApi ],
190199 ['issue_category ' , new IssueCategory ($ httpClient )],
191- ['issue_status ' , $ getIdByNameApi ],
200+ ['issue_status ' , new IssueStatus ( $ httpClient ) ],
192201 ['tracker ' , $ getIdByNameApi ],
193202 ['user ' , $ getIdByUsernameApi ],
194203 ],
@@ -201,7 +210,7 @@ public function testCreateWithClientCleansParameters()
201210 '/issues.xml ' ,
202211 <<< XML
203212 <?xml version="1.0"?>
204- <issue><project_id>1</project_id><category_id>5</category_id><status_id>cleanedValue </status_id><tracker_id>cleanedValue</tracker_id><assigned_to_id>cleanedValue</assigned_to_id><author_id>cleanedValue</author_id></issue>
213+ <issue><project_id>1</project_id><category_id>5</category_id><status_id>6 </status_id><tracker_id>cleanedValue</tracker_id><assigned_to_id>cleanedValue</assigned_to_id><author_id>cleanedValue</author_id></issue>
205214
206215 XML ,
207216 )
0 commit comments