2015-05-30 06:50:44 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Skobkin\Bundle\PointToolsBundle\Tests\Controller;
|
|
|
|
|
|
|
|
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
2016-12-11 20:59:05 +00:00
|
|
|
use Symfony\Component\DomCrawler\Crawler;
|
2015-05-30 06:50:44 +00:00
|
|
|
|
|
|
|
class UserControllerTest extends WebTestCase
|
|
|
|
{
|
2016-12-11 20:59:05 +00:00
|
|
|
public function testTestuserPageHasHeading()
|
2015-05-30 06:50:44 +00:00
|
|
|
{
|
|
|
|
$client = static::createClient();
|
|
|
|
|
2016-12-11 20:59:05 +00:00
|
|
|
$crawler = $client->request('GET', '/user/testuser');
|
|
|
|
|
|
|
|
$userLoginHeading = $crawler->filter('h1.user-login')->first();
|
|
|
|
|
|
|
|
$this->assertEquals(
|
|
|
|
1,
|
|
|
|
$userLoginHeading->count(),
|
|
|
|
'User page has no heading element with user login and avatar'
|
|
|
|
);
|
|
|
|
|
|
|
|
return $userLoginHeading;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @depends testTestuserPageHasHeading
|
|
|
|
*
|
|
|
|
* @param Crawler $heading
|
|
|
|
*/
|
|
|
|
public function testTestuserPageHasUserLink(Crawler $heading)
|
|
|
|
{
|
|
|
|
$userLink = $heading->children()->filter('a');
|
|
|
|
|
|
|
|
$this->assertEquals(
|
|
|
|
1,
|
|
|
|
$userLink->count(),
|
|
|
|
'User page has no user link in the heading'
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->assertEquals(
|
|
|
|
'testuser',
|
|
|
|
$userLink->text(),
|
|
|
|
'User link text is not equal user login'
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @depends testTestuserPageHasHeading
|
|
|
|
*
|
|
|
|
* @param Crawler $heading
|
|
|
|
*/
|
|
|
|
public function testTestuserPageHasUserAvatar(Crawler $heading)
|
|
|
|
{
|
|
|
|
$userAvatar = $heading->children()->filter('img')->first();
|
|
|
|
|
|
|
|
$this->assertEquals(
|
|
|
|
1,
|
|
|
|
$userAvatar->count(),
|
|
|
|
'testuser page has no avatar'
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->assertEquals(
|
|
|
|
'//point.im/avatar/testuser/80',
|
|
|
|
$userAvatar->attr('src'),
|
|
|
|
'testuser avatar image source is not correct'
|
|
|
|
);
|
2015-05-30 06:50:44 +00:00
|
|
|
}
|
|
|
|
|
2016-12-11 20:59:05 +00:00
|
|
|
public function testTestuserHasSubscribers()
|
|
|
|
{
|
|
|
|
$client = static::createClient();
|
|
|
|
|
|
|
|
$crawler = $client->request('GET', '/user/testuser');
|
|
|
|
|
|
|
|
$subscribersList = $crawler->filter('.user-subscribers ul.users')->first();
|
|
|
|
|
|
|
|
$this->assertEquals(
|
|
|
|
1,
|
|
|
|
$subscribersList->count(),
|
|
|
|
'testuser has no subscribers list shown on the page'
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->assertGreaterThan(
|
|
|
|
0,
|
|
|
|
$subscribersList->children()->count(),
|
|
|
|
'Testuser has zero subscribers in the list'
|
|
|
|
);
|
|
|
|
}
|
2015-05-30 06:50:44 +00:00
|
|
|
}
|