Passed
Push — master ( eaf66d...5fa21f )
by Caen
13:40 queued 12s
created

HtmlTestingAssertions::complete()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 0
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Hyde\Testing\Support\HtmlTesting;
6
7
use Illuminate\Testing\Assert as PHPUnit;
8
9
trait HtmlTestingAssertions
10
{
11
    public function complete(): void
12
    {
13
        // Just an empty helper so we get easier Git diffs when adding new assertions.
14
    }
15
16
    public function assertSee(string $value): static
17
    {
18
        return $this->doAssert(fn () => PHPUnit::assertStringContainsString($value, $this->html, "The string '$value' was not found in the HTML."));
19
    }
20
21
    public function assertDontSee(string $value): static
22
    {
23
        return $this->doAssert(fn () => PHPUnit::assertStringNotContainsString($value, $this->html, "The string '$value' was found in the HTML."));
24
    }
25
26
    public function assertSeeEscaped(string $value): static
27
    {
28
        return $this->doAssert(fn () => PHPUnit::assertStringContainsString(e($value), $this->html, "The escaped string '$value' was not found in the HTML."));
29
    }
30
31
    public function assertDontSeeEscaped(string $value): static
32
    {
33
        return $this->doAssert(fn () => PHPUnit::assertStringNotContainsString(e($value), $this->html, "The escaped string '$value' was found in the HTML."));
34
    }
35
36
    protected function doAssert(callable $assertion): static
37
    {
38
        $assertion();
39
40
        return $this;
41
    }
42
}
43