Passed
Push — dependabot/composer/doctrine/d... ( 71e71a...50cb9e )
by
unknown
42:38 queued 27:52
created

Modules/Tags/Tests/Actions/MassActionTest.php (1 issue)

Labels
Severity
1
<?php
2
3
namespace Backend\Modules\Tags\Tests\Action;
4
5
use Backend\Modules\Tags\DataFixtures\LoadTagsModulesTags;
6
use Backend\Modules\Tags\DataFixtures\LoadTagsTags;
7
use Backend\Core\Tests\BackendWebTestCase;
8
use Symfony\Bundle\FrameworkBundle\Client;
9
10
class MassActionTest extends BackendWebTestCase
11
{
12
    protected function setUp(): void
13
    {
14
        parent::setUp();
15
16
        $this->loadFixtures(
17
            $this->getProvidedData()[0],
18
            [
19
                LoadTagsTags::class,
20
                LoadTagsModulesTags::class,
21
            ]
22
        );
23
    }
24
25
    public function testAuthenticationIsNeeded(Client $client): void
26
    {
27
        self::assertAuthenticationIsNeeded($client, '/private/en/tags/mass_action');
28
    }
29
30
    public function testActionIsRequired(Client $client): void
31
    {
32
        $this->login($client);
33
34
        $client->setMaxRedirects(1);
35
        self::assertHttpStatusCode200($client, '/private/en/tags/mass_action');
36
        self::assertCurrentUrlEndsWith($client, '&error=no-action-selected');
37
    }
38
39
    public function testIdsAreRequired(Client $client): void
40
    {
41
        $this->login($client);
42
43
        $client->setMaxRedirects(1);
44
        self::assertHttpStatusCode200($client, '/private/en/tags/mass_action?action=delete');
45
        self::assertCurrentUrlEndsWith($client, '&error=no-selection');
46
    }
47
48
    public function testDeletingOneTag(Client $client): void
49
    {
50
        $this->login($client);
51
52
        $client->setMaxRedirects(1);
53
        self::assertHttpStatusCode200($client, '/private/en/tags/mass_action?action=delete&id[]=2');
54
        self::assertCurrentUrlEndsWith($client, '&report=deleted');
55
        $response = $client->getResponse();
56
        self::assertResponseHasContent(
57
            $response,
58
            'id=' . LoadTagsTags::TAGS_TAG_1_ID . '" title="">' . LoadTagsTags::TAGS_TAG_1_NAME . '</a>'
59
        );
60
        self::assertResponseDoesNotHaveContent(
61
            $response,
62
            'id=' . LoadTagsTags::TAGS_TAG_2_ID . '" title="">' . LoadTagsTags::TAGS_TAG_2_NAME . '</a>'
63
        );
64
    }
65
66
    public function testDeletingAllTags(Client $client): void
67
    {
68
        $this->login($client);
69
70
        $client->setMaxRedirects(1);
71
        self::assertHttpStatusCode200(
72
            $client,
73
            '/private/en/tags/mass_action?action=delete&id[]=' . LoadTagsTags::TAGS_TAG_1_ID
74
            . '&id[]=' . LoadTagsTags::TAGS_TAG_2_ID
75
        );
76
        self::assertCurrentUrlEndsWith($client, '&report=deleted');
77
78
        $response = $client->getResponse();
79
        self::assertResponseHasContent($response, '<p>There are no tags yet.</p>');
0 ignored issues
show
It seems like $response can also be of type null; however, parameter $response of Common\WebTestCase::assertResponseHasContent() does only seem to accept Symfony\Component\HttpFoundation\Response, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

79
        self::assertResponseHasContent(/** @scrutinizer ignore-type */ $response, '<p>There are no tags yet.</p>');
Loading history...
80
        self::assertResponseDoesNotHaveContent(
81
            $response,
82
            'id=' . LoadTagsTags::TAGS_TAG_1_ID . '" title="">' . LoadTagsTags::TAGS_TAG_1_NAME . '</a>',
83
            'id=' . LoadTagsTags::TAGS_TAG_2_ID . '" title="">' . LoadTagsTags::TAGS_TAG_2_NAME . '</a>'
84
        );
85
    }
86
}
87