@@ -500,7 +500,9 @@ public function shouldCreateFile()
500
500
'branch_name ' => 'master ' ,
501
501
'encoding ' => null ,
502
502
'content ' => 'some contents ' ,
503
- 'commit_message ' => 'Added new file '
503
+ 'commit_message ' => 'Added new file ' ,
504
+ 'author_email ' => null ,
505
+ 'author_name ' => null ,
504
506
))
505
507
->will ($ this ->returnValue ($ expectedArray ))
506
508
;
@@ -523,14 +525,41 @@ public function shouldCreateFileWithEncoding()
523
525
'branch_name ' => 'master ' ,
524
526
'encoding ' => 'text ' ,
525
527
'content ' => 'some contents ' ,
526
- 'commit_message ' => 'Added new file '
528
+ 'commit_message ' => 'Added new file ' ,
529
+ 'author_email ' => null ,
530
+ 'author_name ' => null ,
527
531
))
528
532
->will ($ this ->returnValue ($ expectedArray ))
529
533
;
530
534
531
535
$ this ->assertEquals ($ expectedArray , $ api ->createFile (1 , 'dir/file1.txt ' , 'some contents ' , 'master ' , 'Added new file ' , 'text ' ));
532
536
}
533
537
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
+
534
563
/**
535
564
* @test
536
565
*/
@@ -546,7 +575,9 @@ public function shouldUpdateFile()
546
575
'branch_name ' => 'master ' ,
547
576
'encoding ' => null ,
548
577
'content ' => 'some new contents ' ,
549
- 'commit_message ' => 'Updated new file '
578
+ 'commit_message ' => 'Updated new file ' ,
579
+ 'author_email ' => null ,
580
+ 'author_name ' => null ,
550
581
))
551
582
->will ($ this ->returnValue ($ expectedArray ))
552
583
;
@@ -569,14 +600,41 @@ public function shouldUpdateFileWithEncoding()
569
600
'branch_name ' => 'master ' ,
570
601
'encoding ' => 'base64 ' ,
571
602
'content ' => 'some new contents ' ,
572
- 'commit_message ' => 'Updated file '
603
+ 'commit_message ' => 'Updated file ' ,
604
+ 'author_email ' => null ,
605
+ 'author_name ' => null ,
573
606
))
574
607
->will ($ this ->returnValue ($ expectedArray ))
575
608
;
576
609
577
610
$ this ->assertEquals ($ expectedArray , $ api ->updateFile (1 , 'dir/file1.txt ' , 'some new contents ' , 'master ' , 'Updated file ' , 'base64 ' ));
578
611
}
579
612
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
+
580
638
/**
581
639
* @test
582
640
*/
@@ -587,13 +645,42 @@ public function shouldDeleteFile()
587
645
$ api = $ this ->getApiMock ();
588
646
$ api ->expects ($ this ->once ())
589
647
->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
+ ))
591
655
->will ($ this ->returnValue ($ expectedBool ))
592
656
;
593
657
594
658
$ this ->assertEquals ($ expectedBool , $ api ->deleteFile (1 , 'dir/file1.txt ' , 'master ' , 'Deleted file ' ));
595
659
}
596
660
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
+
597
684
/**
598
685
* @test
599
686
*/
@@ -618,4 +705,4 @@ protected function getApiClass()
618
705
{
619
706
return 'Gitlab\Api\Repositories ' ;
620
707
}
621
- }
708
+ }
0 commit comments