• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

api-platform / core / 6067528200

04 Sep 2023 12:12AM UTC coverage: 36.875% (-21.9%) from 58.794%
6067528200

Pull #5791

github

web-flow
Merge 64157e578 into d09cfc9d2
Pull Request #5791: fix: strip down any sql function name

3096 of 3096 new or added lines in 205 files covered. (100.0%)

9926 of 26918 relevant lines covered (36.87%)

6.5 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/HttpCache/Tests/State/AddHeadersProcessorTest.php
1
<?php
2

3
/*
4
 * This file is part of the API Platform project.
5
 *
6
 * (c) Kévin Dunglas <dunglas@gmail.com>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11

12
declare(strict_types=1);
13

14
namespace ApiPlatform\HttpCache\Tests\State;
15

16
use ApiPlatform\HttpCache\State\AddHeadersProcessor;
17
use ApiPlatform\Metadata\Get;
18
use ApiPlatform\State\ProcessorInterface;
19
use PHPUnit\Framework\TestCase;
20
use Symfony\Component\HttpFoundation\Request;
21
use Symfony\Component\HttpFoundation\Response;
22
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
23

24
class AddHeadersProcessorTest extends TestCase
25
{
26
    public function testAddHeaders(): void
27
    {
28
        $operation = new Get();
×
29
        $response = $this->createMock(Response::class);
×
30
        $response->expects($this->once())->method('setEtag');
×
31
        $response->method('getContent')->willReturn('{}');
×
32
        $response->method('isSuccessful')->willReturn(true);
×
33
        $response->headers = $this->createMock(ResponseHeaderBag::class);
×
34
        $response->headers->method('hasCacheControlDirective')->with($this->logicalOr(
×
35
            $this->identicalTo('public'),
×
36
            $this->identicalTo('s-maxage'),
×
37
            $this->identicalTo('max-age'),
×
38
            $this->identicalTo('stale-while-revalidate'),
×
39
            $this->identicalTo('stale-if-error'),
×
40
        ))->willReturn(false);
×
41
        $response->headers->expects($this->exactly(2))->method('addCacheControlDirective')->with($this->logicalOr(
×
42
            $this->identicalTo('stale-while-revalidate'),
×
43
            $this->identicalTo('stale-if-error'),
×
44
        ), '10');
×
45
        $response->expects($this->once())->method('setPublic');
×
46
        $response->expects($this->once())->method('setMaxAge');
×
47
        $response->expects($this->once())->method('setSharedMaxAge');
×
48
        $request = $this->createMock(Request::class);
×
49
        $request->method('isMethodCacheable')->willReturn(true);
×
50
        $context = ['request' => $request];
×
51
        $decorated = $this->createMock(ProcessorInterface::class);
×
52
        $decorated->method('process')->willReturn($response);
×
53
        $processor = new AddHeadersProcessor($decorated, etag: true, maxAge: 100, sharedMaxAge: 200, vary: ['Accept', 'Accept-Encoding'], public: true, staleWhileRevalidate: 10, staleIfError: 10);
×
54
        $processor->process($response, $operation, [], $context);
×
55
    }
56
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc