@@ -500,7 +500,9 @@ public function shouldCreateFile()
500500 'branch_name ' => 'master ' ,
501501 'encoding ' => null ,
502502 'content ' => 'some contents ' ,
503- 'commit_message ' => 'Added new file '
503+ 'commit_message ' => 'Added new file ' ,
504+ 'author_email ' => null ,
505+ 'author_name ' => null ,
504506 ))
505507 ->will ($ this ->returnValue ($ expectedArray ))
506508 ;
@@ -523,14 +525,41 @@ public function shouldCreateFileWithEncoding()
523525 'branch_name ' => 'master ' ,
524526 'encoding ' => 'text ' ,
525527 'content ' => 'some contents ' ,
526- 'commit_message ' => 'Added new file '
528+ 'commit_message ' => 'Added new file ' ,
529+ 'author_email ' => null ,
530+ 'author_name ' => null ,
527531 ))
528532 ->will ($ this ->returnValue ($ expectedArray ))
529533 ;
530534
531535 $ this ->assertEquals ($ expectedArray , $ api ->createFile (1 , 'dir/file1.txt ' , 'some contents ' , 'master ' , 'Added new file ' , 'text ' ));
532536 }
533537
538+ /**
539+ * @test
540+ */
541+ public function shouldCreateFileWithAuthor ()
542+ {
543+ $ expectedArray = array ('file_name ' => 'file1.txt ' , 'file_path ' => 'dir/file1.txt ' );
544+
545+ $ api = $ this ->getApiMock ();
546+ $ api ->expects ($ this ->once ())
547+ ->method ('post ' )
548+ ->with ('projects/1/repository/files ' , array (
549+ 'file_path ' => 'dir/file1.txt ' ,
550+ 'branch_name ' => 'master ' ,
551+ 'encoding ' => null ,
552+ 'content ' => 'some contents ' ,
553+ 'commit_message ' => 'Added new file ' ,
554+ 'author_email ' =>
'[email protected] ' ,
555+ 'author_name ' => 'GitLab User ' ,
556+ ))
557+ ->will ($ this ->returnValue ($ expectedArray ))
558+ ;
559+
560+ $ this ->
assertEquals (
$ expectedArray,
$ api->
createFile (
1 ,
'dir/file1.txt ' ,
'some contents ' ,
'master ' ,
'Added new file ' ,
null ,
'[email protected] ' ,
'GitLab User ' ));
561+ }
562+
534563 /**
535564 * @test
536565 */
@@ -546,7 +575,9 @@ public function shouldUpdateFile()
546575 'branch_name ' => 'master ' ,
547576 'encoding ' => null ,
548577 'content ' => 'some new contents ' ,
549- 'commit_message ' => 'Updated new file '
578+ 'commit_message ' => 'Updated new file ' ,
579+ 'author_email ' => null ,
580+ 'author_name ' => null ,
550581 ))
551582 ->will ($ this ->returnValue ($ expectedArray ))
552583 ;
@@ -569,14 +600,41 @@ public function shouldUpdateFileWithEncoding()
569600 'branch_name ' => 'master ' ,
570601 'encoding ' => 'base64 ' ,
571602 'content ' => 'some new contents ' ,
572- 'commit_message ' => 'Updated file '
603+ 'commit_message ' => 'Updated file ' ,
604+ 'author_email ' => null ,
605+ 'author_name ' => null ,
573606 ))
574607 ->will ($ this ->returnValue ($ expectedArray ))
575608 ;
576609
577610 $ this ->assertEquals ($ expectedArray , $ api ->updateFile (1 , 'dir/file1.txt ' , 'some new contents ' , 'master ' , 'Updated file ' , 'base64 ' ));
578611 }
579612
613+ /**
614+ * @test
615+ */
616+ public function shouldUpdateFileWithAuthor ()
617+ {
618+ $ expectedArray = array ('file_name ' => 'file1.txt ' , 'file_path ' => 'dir/file1.txt ' );
619+
620+ $ api = $ this ->getApiMock ();
621+ $ api ->expects ($ this ->once ())
622+ ->method ('put ' )
623+ ->with ('projects/1/repository/files ' , array (
624+ 'file_path ' => 'dir/file1.txt ' ,
625+ 'branch_name ' => 'master ' ,
626+ 'encoding ' => null ,
627+ 'content ' => 'some new contents ' ,
628+ 'commit_message ' => 'Updated file ' ,
629+ 'author_email ' =>
'[email protected] ' ,
630+ 'author_name ' => 'GitLab User ' ,
631+ ))
632+ ->will ($ this ->returnValue ($ expectedArray ))
633+ ;
634+
635+ $ this ->
assertEquals (
$ expectedArray,
$ api->
updateFile (
1 ,
'dir/file1.txt ' ,
'some new contents ' ,
'master ' ,
'Updated file ' ,
null ,
'[email protected] ' ,
'GitLab User ' ));
636+ }
637+
580638 /**
581639 * @test
582640 */
@@ -587,13 +645,42 @@ public function shouldDeleteFile()
587645 $ api = $ this ->getApiMock ();
588646 $ api ->expects ($ this ->once ())
589647 ->method ('delete ' )
590- ->with ('projects/1/repository/files ' , array ('file_path ' => 'dir/file1.txt ' , 'branch_name ' => 'master ' , 'commit_message ' => 'Deleted file ' ))
648+ ->with ('projects/1/repository/files ' , array (
649+ 'file_path ' => 'dir/file1.txt ' ,
650+ 'branch_name ' => 'master ' ,
651+ 'commit_message ' => 'Deleted file ' ,
652+ 'author_email ' => null ,
653+ 'author_name ' => null ,
654+ ))
591655 ->will ($ this ->returnValue ($ expectedBool ))
592656 ;
593657
594658 $ this ->assertEquals ($ expectedBool , $ api ->deleteFile (1 , 'dir/file1.txt ' , 'master ' , 'Deleted file ' ));
595659 }
596660
661+ /**
662+ * @test
663+ */
664+ public function shouldDeleteFileWithAuthor ()
665+ {
666+ $ expectedBool = true ;
667+
668+ $ api = $ this ->getApiMock ();
669+ $ api ->expects ($ this ->once ())
670+ ->method ('delete ' )
671+ ->with ('projects/1/repository/files ' , array (
672+ 'file_path ' => 'dir/file1.txt ' ,
673+ 'branch_name ' => 'master ' ,
674+ 'commit_message ' => 'Deleted file ' ,
675+ 'author_email ' =>
'[email protected] ' ,
676+ 'author_name ' => 'GitLab User ' ,
677+ ))
678+ ->will ($ this ->returnValue ($ expectedBool ))
679+ ;
680+
681+ $ this ->
assertEquals (
$ expectedBool,
$ api->
deleteFile (
1 ,
'dir/file1.txt ' ,
'master ' ,
'Deleted file ' ,
'[email protected] ' ,
'GitLab User ' ));
682+ }
683+
597684 /**
598685 * @test
599686 */
@@ -618,4 +705,4 @@ protected function getApiClass()
618705 {
619706 return 'Gitlab\Api\Repositories ' ;
620707 }
621- }
708+ }
0 commit comments