Test Failed
Push — master ( 5cbc25...e493eb )
by Alexey
03:02
created

UserControllerTest::testTestuserPageHasUserLink()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 16
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 16
rs 9.4285
cc 1
eloc 10
nc 1
nop 1
1
<?php
2
3
namespace Skobkin\Bundle\PointToolsBundle\Tests\Controller;
4
5
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
6
use Symfony\Component\DomCrawler\Crawler;
7
8
class UserControllerTest extends WebTestCase
9
{
10
    public function testTestuserPageHasHeading()
11
    {
12
        $client = static::createClient();
13
14
        $crawler = $client->request('GET', '/user/testuser');
15
16
        $userLoginHeading = $crawler->filter('h1.user-login')->first();
17
18
        $this->assertEquals(
19
            1,
20
            $userLoginHeading->count(),
21
            'User page has no heading element with user login and avatar'
22
        );
23
24
        return $userLoginHeading;
25
    }
26
27
    /**
28
     * @depends testTestuserPageHasHeading
29
     *
30
     * @param Crawler $heading
31
     */
32
    public function testTestuserPageHasUserLink(Crawler $heading)
33
    {
34
        $userLink = $heading->children()->filter('a');
35
36
        $this->assertEquals(
37
            1,
38
            $userLink->count(),
39
            'User page has no user link in the heading'
40
        );
41
42
        $this->assertEquals(
43
            'testuser',
44
            $userLink->text(),
45
            'User link text is not equal user login'
46
        );
47
    }
48
49
    /**
50
     * @depends testTestuserPageHasHeading
51
     *
52
     * @param Crawler $heading
53
     */
54
    public function testTestuserPageHasUserAvatar(Crawler $heading)
55
    {
56
        $userAvatar = $heading->children()->filter('img')->first();
57
58
        $this->assertEquals(
59
            1,
60
            $userAvatar->count(),
61
            'testuser page has no avatar'
62
        );
63
64
        $this->assertEquals(
65
            '//point.im/avatar/testuser/80',
66
            $userAvatar->attr('src'),
67
            'testuser avatar image source is not correct'
68
        );
69
    }
70
71
    public function testTestuserHasSubscribers()
72
    {
73
        $client = static::createClient();
74
75
        $crawler = $client->request('GET', '/user/testuser');
76
77
        $subscribersList = $crawler->filter('.user-subscribers ul.users')->first();
78
79
        $this->assertEquals(
80
            1,
81
            $subscribersList->count(),
82
            'testuser has no subscribers list shown on the page'
83
        );
84
85
        $this->assertGreaterThan(
86
            0,
87
            $subscribersList->children()->count(),
88
            'Testuser has zero subscribers in the list'
89
        );
90
    }
91
}
92