point-tools/old/tests/Skobkin/PointToolsBundle/Controller/UserControllerTest.php

94 lines
2.4 KiB
PHP
Raw Normal View History

2015-05-30 06:50:44 +00:00
<?php
2017-01-09 19:08:01 +00:00
namespace Tests\Skobkin\PointToolsBundle\Controller;
2015-05-30 06:50:44 +00:00
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');
2017-11-04 20:29:32 +00:00
$userLoginHeading = $crawler->filter('h1#user-login')->first();
2016-12-11 20:59:05 +00:00
$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'
);
$pointScheme = static::createClient()->getContainer()->getParameter('point_scheme');
2016-12-11 20:59:05 +00:00
$this->assertEquals(
$pointScheme.'://point.im/avatar/testuser/80',
2016-12-11 20:59:05 +00:00
$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
}