Code Duplication    Length = 15-16 lines in 3 locations

Tests/Unit/EventListener/UserContextSubscriberTest.php 3 locations

@@ 119-134 (lines=16) @@
116
        $this->assertNull($response);
117
    }
118
119
    public function testOnKernelResponse()
120
    {
121
        $request = new Request();
122
        $request->setMethod('HEAD');
123
        $request->headers->set('X-Hash', 'hash');
124
125
        $requestMatcher = $this->getRequestMatcher($request, false);
126
        $hashGenerator = \Mockery::mock('\FOS\HttpCache\UserContext\HashGenerator');
127
128
        $userContextSubscriber = new UserContextSubscriber($requestMatcher, $hashGenerator, array('X-SessionId'), 'X-Hash');
129
        $event = $this->getKernelResponseEvent($request);
130
131
        $userContextSubscriber->onKernelResponse($event);
132
133
        $this->assertContains('X-Hash', $event->getResponse()->headers->get('Vary'));
134
    }
135
136
    public function testOnKernelResponseNotMaster()
137
    {
@@ 136-151 (lines=16) @@
133
        $this->assertContains('X-Hash', $event->getResponse()->headers->get('Vary'));
134
    }
135
136
    public function testOnKernelResponseNotMaster()
137
    {
138
        $request = new Request();
139
        $request->setMethod('HEAD');
140
        $request->headers->set('X-Hash', 'hash');
141
142
        $requestMatcher = $this->getRequestMatcher($request, false);
143
        $hashGenerator = \Mockery::mock('\FOS\HttpCache\UserContext\HashGenerator');
144
145
        $userContextSubscriber = new UserContextSubscriber($requestMatcher, $hashGenerator, array('X-SessionId'), 'X-Hash');
146
        $event = $this->getKernelResponseEvent($request, null, HttpKernelInterface::SUB_REQUEST);
147
148
        $userContextSubscriber->onKernelResponse($event);
149
150
        $this->assertFalse($event->getResponse()->headers->has('Vary'));
151
    }
152
153
    /**
154
     * If there is no hash in the request, vary on the user identifier.
@@ 156-170 (lines=15) @@
153
    /**
154
     * If there is no hash in the request, vary on the user identifier.
155
     */
156
    public function testOnKernelResponseNotCached()
157
    {
158
        $request = new Request();
159
        $request->setMethod('HEAD');
160
161
        $requestMatcher = $this->getRequestMatcher($request, false);
162
        $hashGenerator = \Mockery::mock('\FOS\HttpCache\UserContext\HashGenerator');
163
164
        $userContextSubscriber = new UserContextSubscriber($requestMatcher, $hashGenerator, array('X-SessionId'), 'X-Hash');
165
        $event = $this->getKernelResponseEvent($request);
166
167
        $userContextSubscriber->onKernelResponse($event);
168
169
        $this->assertEquals('X-SessionId', $event->getResponse()->headers->get('Vary'));
170
    }
171
172
    /**
173
     * If there is no hash in the request, vary on the user identifier.