Code Duplication    Length = 15-18 lines in 6 locations

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

@@ 57-71 (lines=15) @@
54
        $this->assertFalse($this->parameterResolver->resolveApi());
55
    }
56
57
    public function testResolveApiWihApiRequest()
58
    {
59
        $this->requestStack
60
            ->expects($this->exactly(2))
61
            ->method('getMasterRequest')
62
            ->will($this->returnValue($request = $this->createRequestMock()));
63
64
        $request->attributes
65
            ->expects($this->once())
66
            ->method('get')
67
            ->with($this->identicalTo('_lug_api'), $this->identicalTo(false))
68
            ->will($this->returnValue(true));
69
70
        $this->assertTrue($this->parameterResolver->resolveApi());
71
    }
72
73
    public function testResolveApiWithHtmlRequest()
74
    {
@@ 394-408 (lines=15) @@
391
        $this->assertFalse($this->parameterResolver->resolveHateoas());
392
    }
393
394
    public function testResolveHateoasExplicit()
395
    {
396
        $this->requestStack
397
            ->expects($this->once())
398
            ->method('getMasterRequest')
399
            ->will($this->returnValue($request = $this->createRequestMock()));
400
401
        $request->attributes
402
            ->expects($this->once())
403
            ->method('get')
404
            ->with($this->identicalTo('_lug_hateoas'), $this->identicalTo(false))
405
            ->will($this->returnValue(true));
406
407
        $this->assertTrue($this->parameterResolver->resolveHateoas());
408
    }
409
410
    public function testResolveLocationRoute()
411
    {
@@ 732-746 (lines=15) @@
729
        $this->assertFalse($this->parameterResolver->resolveRedirectRouteParametersForward());
730
    }
731
732
    public function testResolveRedirectRouteParametersForwardExplicit()
733
    {
734
        $this->requestStack
735
            ->expects($this->once())
736
            ->method('getMasterRequest')
737
            ->will($this->returnValue($request = $this->createRequestMock()));
738
739
        $request->attributes
740
            ->expects($this->once())
741
            ->method('get')
742
            ->with($this->identicalTo('_lug_redirect_route_parameters_forward'), $this->identicalTo(false))
743
            ->will($this->returnValue(true));
744
745
        $this->assertTrue($this->parameterResolver->resolveRedirectRouteParametersForward());
746
    }
747
748
    public function testResolveRepositoryMethodWithoutRequest()
749
    {
@@ 827-841 (lines=15) @@
824
        $this->assertTrue($this->parameterResolver->resolveSerializerNull());
825
    }
826
827
    public function testResolveSerializerNullDefault()
828
    {
829
        $this->requestStack
830
            ->expects($this->once())
831
            ->method('getMasterRequest')
832
            ->will($this->returnValue($request = $this->createRequestMock()));
833
834
        $request->attributes
835
            ->expects($this->once())
836
            ->method('get')
837
            ->with($this->identicalTo('_lug_serializer_null'), $this->identicalTo($null = true))
838
            ->will($this->returnValue($null));
839
840
        $this->assertTrue($this->parameterResolver->resolveSerializerNull());
841
    }
842
843
    public function testResolveSerializerNullExplicit()
844
    {
@@ 1135-1149 (lines=15) @@
1132
        $this->assertFalse($this->parameterResolver->resolveVoter());
1133
    }
1134
1135
    public function testResolveVoterExplicit()
1136
    {
1137
        $this->requestStack
1138
            ->expects($this->once())
1139
            ->method('getMasterRequest')
1140
            ->will($this->returnValue($request = $this->createRequestMock()));
1141
1142
        $request->attributes
1143
            ->expects($this->once())
1144
            ->method('get')
1145
            ->with($this->identicalTo('_lug_voter'), $this->identicalTo(false))
1146
            ->will($this->returnValue(true));
1147
1148
        $this->assertTrue($this->parameterResolver->resolveVoter());
1149
    }
1150
1151
    /**
1152
     * @return \PHPUnit_Framework_MockObject_MockObject|RequestStack

src/Bundle/ResourceBundle/Tests/Security/SecurityCheckerTest.php 1 location

@@ 69-86 (lines=18) @@
66
        $this->assertTrue($this->securityChecker->isGranted('show', $this->createStdClassMock()));
67
    }
68
69
    public function testIsGrantedWithVoter()
70
    {
71
        $this->parameterResolver
72
            ->expects($this->once())
73
            ->method('resolveVoter')
74
            ->will($this->returnValue(true));
75
76
        $this->authorizationChecker
77
            ->expects($this->once())
78
            ->method('isGranted')
79
            ->with(
80
                $this->identicalTo('lug.'.($action = 'show')),
81
                $this->identicalTo($object = $this->createStdClassMock())
82
            )
83
            ->will($this->returnValue(true));
84
85
        $this->assertTrue($this->securityChecker->isGranted($action, $object));
86
    }
87
88
    /**
89
     * @return \PHPUnit_Framework_MockObject_MockObject|AuthorizationCheckerInterface