@@ -31,17 +31,17 @@ public function testSetEndpointTrailingSlash()
3131 */
3232 public function testUpdateVersion ()
3333 {
34- $ params = [
35- " released " => true ,
36- " releaseDate " => " 2010-07-06 " ,
37- ] ;
34+ $ params = array (
35+ ' released ' => true ,
36+ ' releaseDate ' => ' 2010-07-06 ' ,
37+ ) ;
3838
3939 // Stub the api method and keep the rest intact
4040 /** @var Api|\PHPUnit_Framework_MockObject_MockObject $api */
41- $ api = $ this ->getMockBuilder (Api::class )->setMethods ([ " api " ] )->disableOriginalConstructor ()->getMock ();
42- $ api ->expects ($ this ->once ())->method (" api " )->with (
41+ $ api = $ this ->getMockBuilder (' \chobie\Jira\ Api' )->setMethods (array ( ' api ' ) )->disableOriginalConstructor ()->getMock ();
42+ $ api ->expects ($ this ->once ())->method (' api ' )->with (
4343 $ this ->equalTo (Api::REQUEST_PUT ),
44- $ this ->equalTo (" /rest/api/2/version/111000 " ),
44+ $ this ->equalTo (' /rest/api/2/version/111000 ' ),
4545 $ this ->equalTo ($ params )
4646 );
4747
@@ -53,17 +53,17 @@ public function testUpdateVersion()
5353 */
5454 public function testReleaseVersion ()
5555 {
56- $ params = [
57- " released " => true ,
58- " releaseDate " => date (" Y-m-d " ),
59- ] ;
56+ $ params = array (
57+ ' released ' => true ,
58+ ' releaseDate ' => date (' Y-m-d ' ),
59+ ) ;
6060
6161 // Stub the api method and keep the rest intact
6262 /** @var Api|\PHPUnit_Framework_MockObject_MockObject $api */
63- $ api = $ this ->getMockBuilder (Api::class )->setMethods ([ " api " ] )->disableOriginalConstructor ()->getMock ();
64- $ api ->expects ($ this ->once ())->method (" api " )->with (
63+ $ api = $ this ->getMockBuilder (' \chobie\Jira\ Api' )->setMethods (array ( ' api ' ) )->disableOriginalConstructor ()->getMock ();
64+ $ api ->expects ($ this ->once ())->method (' api ' )->with (
6565 $ this ->equalTo (Api::REQUEST_PUT ),
66- $ this ->equalTo (" /rest/api/2/version/111000 " ),
66+ $ this ->equalTo (' /rest/api/2/version/111000 ' ),
6767 $ this ->equalTo ($ params )
6868 );
6969
@@ -75,23 +75,52 @@ public function testReleaseVersion()
7575 */
7676 public function testReleaseVersionAdvanced ()
7777 {
78- $ releaseDate = " 2010-07-06 " ;
78+ $ releaseDate = ' 2010-07-06 ' ;
7979
80- $ params = [
81- " released " => true ,
82- " releaseDate " => $ releaseDate ,
83- " test " => " extra "
84- ] ;
80+ $ params = array (
81+ ' released ' => true ,
82+ ' releaseDate ' => $ releaseDate ,
83+ ' test ' => ' extra '
84+ ) ;
8585
8686 // Stub the api method and keep the rest intact
8787 /** @var Api|\PHPUnit_Framework_MockObject_MockObject $api */
88- $ api = $ this ->getMockBuilder (Api::class )->setMethods ([ " api " ] )->disableOriginalConstructor ()->getMock ();
89- $ api ->expects ($ this ->once ())->method (" api " )->with (
88+ $ api = $ this ->getMockBuilder (' \chobie\Jira\ Api' )->setMethods (array ( ' api ' ) )->disableOriginalConstructor ()->getMock ();
89+ $ api ->expects ($ this ->once ())->method (' api ' )->with (
9090 $ this ->equalTo (Api::REQUEST_PUT ),
91- $ this ->equalTo (" /rest/api/2/version/111000 " ),
91+ $ this ->equalTo (' /rest/api/2/version/111000 ' ),
9292 $ this ->equalTo ($ params )
9393 );
9494
95- $ api ->releaseVersion (111000 , $ releaseDate , ["test " => "extra " ]);
95+ $ api ->releaseVersion (111000 , $ releaseDate , array ('test ' => 'extra ' ));
96+ }
97+
98+ /**
99+ * Tests FindVersionByName
100+ */
101+ public function testFindVersionByName ()
102+ {
103+ $ name = '3.36.0 ' ;
104+ $ versionId = '14206 ' ;
105+ $ projectKey = 'POR ' ;
106+
107+ $ versions = array (
108+ array ('id ' => '14205 ' , 'name ' => '3.62.0 ' ),
109+ array ('id ' => $ versionId , 'name ' => $ name ),
110+ array ('id ' => '14207 ' , 'name ' => '3.66.0 ' ),
111+ );
112+
113+ // Stub the getVersions method and keep the rest intact
114+ /** @var Api|\PHPUnit_Framework_MockObject_MockObject $api */
115+ $ api = $ this ->getMockBuilder ('\chobie\Jira\Api ' )->setMethods (array ('getVersions ' ))->disableOriginalConstructor ()->getMock ();
116+ $ api ->expects ($ this ->exactly (2 ))->method ('getVersions ' )->with (
117+ $ this ->equalTo ($ projectKey )
118+ )->willReturn ($ versions );
119+
120+ // He should find this one
121+ $ this ->assertEquals (array ('id ' => $ versionId , 'name ' => $ name ), $ api ->findVersionByName ($ projectKey , $ name ));
122+
123+ // And there should be no result for this one
124+ $ this ->assertNull ($ api ->findVersionByName ($ projectKey , 'i_do_not_exist ' ));
96125 }
97126}
0 commit comments