@@ -680,7 +680,10 @@ public function testUploadFiles() {
680
680
$ this ->apiController ->uploadFiles (1 , 10 , '' );
681
681
}
682
682
683
- public function testNewSubmission_answers () {
683
+ /**
684
+ * Values for the mock objects for the following methods: testNewSubmission_answers, testUpdateSubmission_answers.
685
+ */
686
+ public function dataForSubmission_answers () {
684
687
$ form = new Form ();
685
688
$ form ->setId (1 );
686
689
$ form ->setHash ('hash ' );
@@ -728,6 +731,16 @@ public function testNewSubmission_answers() {
728
731
5 => ['ignore unknown question ' ],
729
732
];
730
733
734
+ return [
735
+ 'test ' => [$ form , $ questions , $ answers ],
736
+ ];
737
+ }
738
+
739
+ /**
740
+ * @dataProvider dataForSubmission_answers()
741
+ */
742
+ public function testNewSubmission_answers ($ form , $ questions , $ answers ) {
743
+
731
744
$ this ->formMapper ->expects ($ this ->once ())
732
745
->method ('findById ' )
733
746
->with (1 )
@@ -882,6 +895,61 @@ public function testNewSubmission_validateSubmission() {
882
895
$ this ->apiController ->newSubmission (1 , [], '' );
883
896
}
884
897
898
+ /**
899
+ * @dataProvider dataForSubmission_answers()
900
+ */
901
+ public function testUpdateSubmission_answers ($ form , $ questions , $ answers ) {
902
+
903
+ $ form ->setAllowEdit (true );
904
+ $ submission = new Submission ();
905
+ $ submission ->setId (12 );
906
+
907
+ $ this ->formMapper ->expects ($ this ->once ())
908
+ ->method ('findById ' )
909
+ ->with (1 )
910
+ ->willReturn ($ form );
911
+
912
+ $ this ->formsService ->expects ($ this ->once ())
913
+ ->method ('getQuestions ' )
914
+ ->with (1 )
915
+ ->willReturn ($ questions );
916
+
917
+ $ this ->formAccess ();
918
+
919
+ $ this ->submissionService
920
+ ->method ('validateSubmission ' )
921
+ ->willReturn (true );
922
+
923
+ $ this ->submissionMapper ->expects ($ this ->once ())
924
+ ->method ('findByFormAndUser ' )
925
+ ->with (1 , 'currentUser ' )
926
+ ->willReturn ($ submission );
927
+
928
+ $ userFolder = $ this ->createMock (Folder::class);
929
+ $ userFolder ->expects ($ this ->once ())
930
+ ->method ('nodeExists ' )
931
+ ->willReturn (true );
932
+
933
+ $ file = $ this ->createMock (File::class);
934
+
935
+ $ userFolder ->expects ($ this ->once ())
936
+ ->method ('getById ' )
937
+ ->willReturn ([$ file ]);
938
+
939
+ $ folder = $ this ->createMock (Folder::class);
940
+
941
+ $ userFolder ->expects ($ this ->once ())
942
+ ->method ('get ' )
943
+ ->willReturn ($ folder );
944
+
945
+ $ this ->storage ->expects ($ this ->once ())
946
+ ->method ('getUserFolder ' )
947
+ ->with ('admin ' )
948
+ ->willReturn ($ userFolder );
949
+
950
+ $ this ->apiController ->updateSubmission (1 , 12 , $ answers , '' );
951
+ }
952
+
885
953
public function testDeleteSubmissionNotFound () {
886
954
$ exception = $ this ->createMock (MapperException::class);
887
955
0 commit comments