GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

StringTwigExtensionTest   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 78
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 2
dl 0
loc 78
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A testGetFilters() 0 13 2
A testAntispam() 0 6 1
A testAntispamText() 0 6 1
A getMailHtml() 0 27 1
A getMailText() 0 13 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * (c) Christian Gripp <[email protected]>
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
namespace Core23\AntiSpamBundle\Tests\Twig\Extension;
13
14
use Core23\AntiSpamBundle\Twig\Extension\StringTwigExtension;
15
use PHPUnit\Framework\TestCase;
16
use Twig\TwigFilter;
17
18
final class StringTwigExtensionTest extends TestCase
19
{
20
    public function testGetFilters(): void
21
    {
22
        $extension = new StringTwigExtension('spam', ['[AT]'], ['[DOT]']);
23
24
        $filters = $extension->getFilters();
25
26
        static::assertNotCount(0, $filters);
27
28
        foreach ($filters as $filter) {
29
            static::assertInstanceOf(TwigFilter::class, $filter);
30
            static::assertIsCallable($filter->getCallable());
31
        }
32
    }
33
34
    /**
35
     * @dataProvider getMailHtml
36
     */
37
    public function testAntispam(string $input, string $output): void
38
    {
39
        $extension = new StringTwigExtension('spam', ['[AT]'], ['[DOT]']);
40
41
        static::assertSame($output, $extension->antispam($input));
42
    }
43
44
    /**
45
     * @dataProvider getMailText
46
     */
47
    public function testAntispamText(string $input, string $output): void
48
    {
49
        $extension = new StringTwigExtension('spam', ['[AT]'], ['[DOT]']);
50
51
        static::assertSame($output, $extension->antispam($input, false));
52
    }
53
54
    public function getMailHtml(): iterable
55
    {
56
        // @noinspection JSUnusedLocalSymbols
57
        return [
58
            [
59
                'Lorem Ipsum <script>const link = "[email protected]"; </script> Sit Amet',
60
                'Lorem Ipsum <script>const link = "[email protected]"; </script> Sit Amet',
61
            ],
62
            // TODO: Replace plain mails text in html
63
            //            [
64
            //                'Lorem Ipsum [email protected] Sit Amet',
65
            //                'Lorem Ipsum <span class="spam"><span>foo[DOT]sub</span>[AT]<span>bar[DOT]baz[DOT]tld</span></span> Sit Amet',
66
            //            ],
67
            [
68
                'Lorem Ipsum <a href="mailto:[email protected]">John Smith</a> Sit Amet',
69
                'Lorem Ipsum <span class="spam"><span>john</span>[AT]<span>smith[DOT]cool</span> (<span>John Smith</span>)</span> Sit Amet',
70
            ],
71
            [
72
                'Lorem Ipsum <a href="mailto:[email protected]">[email protected]</a> Sit Amet',
73
                'Lorem Ipsum <span class="spam"><span>foo[DOT]sub</span>[AT]<span>bar[DOT]baz[DOT]tld</span></span> Sit Amet',
74
            ],
75
            [
76
                'Lorem Ipsum <span class="spam"><span>foo[DOT]sub</span>[AT]<span>bar[DOT]baz[DOT]tld</span></span> Sit Amet',
77
                'Lorem Ipsum <span class="spam"><span>foo[DOT]sub</span>[AT]<span>bar[DOT]baz[DOT]tld</span></span> Sit Amet',
78
            ],
79
        ];
80
    }
81
82
    public function getMailText(): iterable
83
    {
84
        return [
85
            [
86
                'Lorem Ipsum [email protected] Sit Amet',
87
                'Lorem Ipsum foo[DOT]sub[AT]bar[DOT]baz[DOT]tld Sit Amet',
88
            ],
89
            [
90
                'Lorem Ipsum foo[DOT]sub[AT]bar[DOT]baz[DOT]tld Sit Amet',
91
                'Lorem Ipsum foo[DOT]sub[AT]bar[DOT]baz[DOT]tld Sit Amet',
92
            ],
93
        ];
94
    }
95
}
96