• 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/ResponseBodyNotContains.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 ResponseBodyNotContains.
18
 *
19
 * @package testing
20
 */
21
final class ResponseBodyNotContains extends Constraint
22
{
23
    private string $string;
24

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

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

45
    public function toString() : string
46
    {
47
        return \sprintf(
1✔
48
            "does not contain '%s'.",
1✔
49
            $this->string
1✔
50
        );
1✔
51
    }
52

53
    protected function matches(mixed $other) : bool
54
    {
55
        return !\str_contains($other, $this->string);
2✔
56
    }
57
}
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