Passed
Push — master ( 600cae...0a2876 )
by jelmer
05:21 queued 11s
created

AddTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
eloc 20
dl 0
loc 34
ccs 0
cts 27
cp 0
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testAuthenticationIsNeeded() 0 12 1
A testFormIsDisplayed() 0 17 1
1
<?php
2
3
namespace Backend\Modules\ContentBlocks\Tests\Action;
4
5
use Common\WebTestCase;
6
7
class AddTest extends WebTestCase
8
{
9
    public function testAuthenticationIsNeeded(): void
10
    {
11
        $client = static::createClient();
12
        $this->logout($client);
13
14
        $client->setMaxRedirects(1);
15
        $client->request('GET', '/private/en/content_blocks/index');
16
17
        // we should get redirected to authentication with a reference to blog index in our url
18
        self::assertStringEndsWith(
19
            '/private/en/authentication?querystring=%2Fprivate%2Fen%2Fcontent_blocks%2Findex',
20
            $client->getHistory()->current()->getUri()
21
        );
22
    }
23
24
    public function testFormIsDisplayed(): void
25
    {
26
        $client = static::createClient();
27
        $this->login($client);
28
29
        $client->request('GET', '/private/en/content_blocks/add');
30
        self::assertContains(
31
            'Title<abbr data-toggle="tooltip" aria-label="Required field" title="Required field">*</abbr>',
32
            $client->getResponse()->getContent()
33
        );
34
        self::assertContains(
35
            'Visible on site',
36
            $client->getResponse()->getContent()
37
        );
38
        self::assertContains(
39
            'Add content block',
40
            $client->getResponse()->getContent()
41
        );
42
    }
43
}
44