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

aplus-framework / testing / 16211940240

03 Oct 2024 09:03PM UTC coverage: 100.0%. Remained the same
16211940240

push

github

natanfelles
Export-ignore SECURITY.md

280 of 280 relevant lines covered (100.0%)

4.9 hits per line

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

100.0
/src/Constraints/ResponseNotContainsHeader.php
1
<?php declare(strict_types=1);
2
/*
3
 * This file is part of Aplus Framework Testing Library.
4
 *
5
 * (c) Natan Felles <natanfelles@gmail.com>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace Framework\Testing\Constraints;
11

12
use PHPUnit\Framework\Constraint\Constraint;
13
use PHPUnit\Framework\ExpectationFailedException;
14
use SebastianBergmann\Comparator\ComparisonFailure;
15

16
/**
17
 * Class ResponseNotContainsHeader.
18
 *
19
 * @package testing
20
 */
21
final class ResponseNotContainsHeader extends Constraint
22
{
23
    private string $string;
24

25
    public function __construct(string $string)
26
    {
27
        $this->string = $string;
3✔
28
    }
29

30
    protected function fail(mixed $other, string $description, ?ComparisonFailure $comparisonFailure = null) : never
31
    {
32
        $failureDescription = \sprintf(
2✔
33
            'Failed asserting that Response %s',
2✔
34
            $this->failureDescription($other)
2✔
35
        );
2✔
36
        if (!empty($description)) {
2✔
37
            $failureDescription = $description . "\n" . $failureDescription;
2✔
38
        }
39
        throw new ExpectationFailedException(
2✔
40
            $failureDescription,
2✔
41
            $comparisonFailure
2✔
42
        );
2✔
43
    }
44

45
    protected function failureDescription(mixed $other) : string
46
    {
47
        return $this->toString();
2✔
48
    }
49

50
    public function toString() : string
51
    {
52
        return \sprintf(
2✔
53
            "does not contain header '%s'.",
2✔
54
            $this->string
2✔
55
        );
2✔
56
    }
57

58
    protected function matches(mixed $other) : bool
59
    {
60
        return $other === null;
3✔
61
    }
62
}
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