Code Duplication    Length = 15-15 lines in 12 locations

src/Bundle/ResourceBundle/Tests/Routing/ParameterResolverTest.php 12 locations

@@ 224-238 (lines=15) @@
221
        $this->assertSame(1, $this->parameterResolver->resolveCurrentPage());
222
    }
223
224
    public function testResolveCurrentPageDefault()
225
    {
226
        $this->requestStack
227
            ->expects($this->once())
228
            ->method('getMasterRequest')
229
            ->will($this->returnValue($request = $this->createRequestMock()));
230
231
        $request
232
            ->expects($this->once())
233
            ->method('get')
234
            ->with($this->identicalTo('page'), $this->identicalTo($page = 1))
235
            ->will($this->returnValue($page));
236
237
        $this->assertSame($page, $this->parameterResolver->resolveCurrentPage());
238
    }
239
240
    public function testResolveCurrentPageExplicit()
241
    {
@@ 240-254 (lines=15) @@
237
        $this->assertSame($page, $this->parameterResolver->resolveCurrentPage());
238
    }
239
240
    public function testResolveCurrentPageExplicit()
241
    {
242
        $this->requestStack
243
            ->expects($this->once())
244
            ->method('getMasterRequest')
245
            ->will($this->returnValue($request = $this->createRequestMock()));
246
247
        $request
248
            ->expects($this->once())
249
            ->method('get')
250
            ->with($this->identicalTo('page'), $this->identicalTo(1))
251
            ->will($this->returnValue($page = 2));
252
253
        $this->assertSame($page, $this->parameterResolver->resolveCurrentPage());
254
    }
255
256
    public function testResolveFormWithoutRequest()
257
    {
@@ 719-733 (lines=15) @@
716
        );
717
    }
718
719
    public function testResolveRedirectRouteParametersWithoutObject()
720
    {
721
        $this->requestStack
722
            ->expects($this->once())
723
            ->method('getMasterRequest')
724
            ->will($this->returnValue($request = $this->createRequestMock()));
725
726
        $request->attributes
727
            ->expects($this->once())
728
            ->method('get')
729
            ->with($this->identicalTo('_lug_redirect_route_parameters'), $this->identicalTo([]))
730
            ->will($this->returnValue([]));
731
732
        $this->assertEmpty($this->parameterResolver->resolveRedirectRouteParameters());
733
    }
734
735
    /**
736
     * @expectedException \Lug\Bundle\ResourceBundle\Exception\RuntimeException
@@ 739-753 (lines=15) @@
736
     * @expectedException \Lug\Bundle\ResourceBundle\Exception\RuntimeException
737
     * @expectedExceptionMessage The route parameters could not be found for the route "redirect_route_parameters".
738
     */
739
    public function testResolveRedirectRouteParametersWithObjectMissing()
740
    {
741
        $this->requestStack
742
            ->expects($this->once())
743
            ->method('getMasterRequest')
744
            ->will($this->returnValue($request = $this->createRequestMock()));
745
746
        $request->attributes
747
            ->expects($this->once())
748
            ->method('get')
749
            ->with($this->identicalTo('_lug_redirect_route_parameters'), $this->identicalTo([]))
750
            ->will($this->returnValue(['id']));
751
752
        $this->assertEmpty($this->parameterResolver->resolveRedirectRouteParameters());
753
    }
754
755
    public function testResolveRedirectRouteParametersForwardWithoutRequest()
756
    {
@@ 834-848 (lines=15) @@
831
        $this->assertEmpty($this->parameterResolver->resolveSerializerGroups());
832
    }
833
834
    public function testResolveSerializerGroupsDefault()
835
    {
836
        $this->requestStack
837
            ->expects($this->once())
838
            ->method('getMasterRequest')
839
            ->will($this->returnValue($request = $this->createRequestMock()));
840
841
        $request->attributes
842
            ->expects($this->once())
843
            ->method('get')
844
            ->with(
845
                $this->identicalTo('_lug_serializer_groups'),
846
                $this->identicalTo($groups = [])
847
            )
848
            ->will($this->returnValue($groups));
849
850
        $this->assertEmpty($this->parameterResolver->resolveSerializerGroups());
851
    }
@@ 914-928 (lines=15) @@
911
        $this->assertEmpty($this->parameterResolver->resolveSorting());
912
    }
913
914
    public function testResolveSortingDefault()
915
    {
916
        $this->requestStack
917
            ->expects($this->once())
918
            ->method('getMasterRequest')
919
            ->will($this->returnValue($request = $this->createRequestMock()));
920
921
        $request->attributes
922
            ->expects($this->once())
923
            ->method('get')
924
            ->with($this->identicalTo('_lug_sorting'), $this->identicalTo($sorting = []))
925
            ->will($this->returnValue($sorting));
926
927
        $this->assertEmpty($this->parameterResolver->resolveSorting());
928
    }
929
930
    public function testResolveSortingExplicit()
931
    {
@@ 930-944 (lines=15) @@
927
        $this->assertEmpty($this->parameterResolver->resolveSorting());
928
    }
929
930
    public function testResolveSortingExplicit()
931
    {
932
        $this->requestStack
933
            ->expects($this->once())
934
            ->method('getMasterRequest')
935
            ->will($this->returnValue($request = $this->createRequestMock()));
936
937
        $request->attributes
938
            ->expects($this->once())
939
            ->method('get')
940
            ->with($this->identicalTo('_lug_sorting'), $this->identicalTo([]))
941
            ->will($this->returnValue($sorting = ['foo' => 'ASC']));
942
943
        $this->assertSame($sorting, $this->parameterResolver->resolveSorting());
944
    }
945
946
    public function testResolveStatusCodeWithoutRequest()
947
    {
@@ 951-965 (lines=15) @@
948
        $this->assertSame($statusCode = 200, $this->parameterResolver->resolveStatusCode($statusCode));
949
    }
950
951
    public function testResolveStatusCodeDefault()
952
    {
953
        $this->requestStack
954
            ->expects($this->once())
955
            ->method('getMasterRequest')
956
            ->will($this->returnValue($request = $this->createRequestMock()));
957
958
        $request->attributes
959
            ->expects($this->once())
960
            ->method('get')
961
            ->with($this->identicalTo('_lug_status_code'), $this->identicalTo($statusCode = 200))
962
            ->will($this->returnValue($statusCode));
963
964
        $this->assertSame($statusCode, $this->parameterResolver->resolveStatusCode($statusCode));
965
    }
966
967
    public function testResolveStatusCodeExplicit()
968
    {
@@ 1039-1053 (lines=15) @@
1036
        $this->assertEmpty($this->parameterResolver->resolveThemes());
1037
    }
1038
1039
    public function testResolveThemesDefault()
1040
    {
1041
        $this->requestStack
1042
            ->expects($this->once())
1043
            ->method('getMasterRequest')
1044
            ->will($this->returnValue($request = $this->createRequestMock()));
1045
1046
        $request->attributes
1047
            ->expects($this->once())
1048
            ->method('get')
1049
            ->with($this->identicalTo('_lug_themes'), $this->identicalTo($themes = []))
1050
            ->will($this->returnValue($themes));
1051
1052
        $this->assertEmpty($this->parameterResolver->resolveThemes());
1053
    }
1054
1055
    public function testResolveThemesExplicit()
1056
    {
@@ 1055-1069 (lines=15) @@
1052
        $this->assertEmpty($this->parameterResolver->resolveThemes());
1053
    }
1054
1055
    public function testResolveThemesExplicit()
1056
    {
1057
        $this->requestStack
1058
            ->expects($this->once())
1059
            ->method('getMasterRequest')
1060
            ->will($this->returnValue($request = $this->createRequestMock()));
1061
1062
        $request->attributes
1063
            ->expects($this->once())
1064
            ->method('get')
1065
            ->with($this->identicalTo('_lug_themes'), $this->identicalTo([]))
1066
            ->will($this->returnValue($themes = ['theme']));
1067
1068
        $this->assertSame($themes, $this->parameterResolver->resolveThemes());
1069
    }
1070
1071
    public function testResolveTranslationDomainWithoutRequest()
1072
    {
@@ 1169-1183 (lines=15) @@
1166
        $this->assertEmpty($this->parameterResolver->resolveValidationGroups());
1167
    }
1168
1169
    public function testResolveValidationGroupsDefault()
1170
    {
1171
        $this->requestStack
1172
            ->expects($this->once())
1173
            ->method('getMasterRequest')
1174
            ->will($this->returnValue($request = $this->createRequestMock()));
1175
1176
        $request->attributes
1177
            ->expects($this->once())
1178
            ->method('get')
1179
            ->with($this->identicalTo('_lug_validation_groups'), $this->identicalTo($groups = []))
1180
            ->will($this->returnValue($groups));
1181
1182
        $this->assertEmpty($this->parameterResolver->resolveValidationGroups());
1183
    }
1184
1185
    public function testResolveValidationGroupsExplicit()
1186
    {
@@ 1185-1199 (lines=15) @@
1182
        $this->assertEmpty($this->parameterResolver->resolveValidationGroups());
1183
    }
1184
1185
    public function testResolveValidationGroupsExplicit()
1186
    {
1187
        $this->requestStack
1188
            ->expects($this->once())
1189
            ->method('getMasterRequest')
1190
            ->will($this->returnValue($request = $this->createRequestMock()));
1191
1192
        $request->attributes
1193
            ->expects($this->once())
1194
            ->method('get')
1195
            ->with($this->identicalTo('_lug_validation_groups'), $this->identicalTo([]))
1196
            ->will($this->returnValue($groups = ['group']));
1197
1198
        $this->assertSame($groups, $this->parameterResolver->resolveValidationGroups());
1199
    }
1200
1201
    public function testResolveVoterWithoutRequest()
1202
    {