2015-05-30 06:22:06 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Skobkin\Bundle\PointToolsBundle\Tests\Controller;
|
|
|
|
|
|
|
|
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
|
|
|
|
|
|
|
class MainControllerTest extends WebTestCase
|
|
|
|
{
|
2016-12-11 20:27:14 +00:00
|
|
|
public function testUserSearch()
|
2015-05-30 06:22:06 +00:00
|
|
|
{
|
|
|
|
$client = static::createClient();
|
|
|
|
|
|
|
|
$crawler = $client->request('GET', '/');
|
2016-12-11 20:27:14 +00:00
|
|
|
|
|
|
|
$userSearchForm = $crawler->filter('form.form-inline')->form();
|
|
|
|
|
|
|
|
$userSearchForm['skobkin_bundle_pointtoolsbundle_user_search[login]'] = 'testuser';
|
|
|
|
|
|
|
|
$crawler = $client->submit($userSearchForm);
|
|
|
|
|
|
|
|
$this->assertTrue($client->getResponse()->isRedirect('/user/testuser'), 'Redirect to testuser\'s page didn\'t happen');
|
2015-05-30 06:22:06 +00:00
|
|
|
}
|
|
|
|
|
2016-12-11 20:27:14 +00:00
|
|
|
public function testUserStats()
|
|
|
|
{
|
|
|
|
$client = static::createClient();
|
|
|
|
|
|
|
|
$crawler = $client->request('GET', '/');
|
|
|
|
|
|
|
|
$userStatsBlock = $crawler->filter('.container.service-stats');
|
|
|
|
|
|
|
|
// Assuming we have stats block
|
|
|
|
$this->assertEquals(1, $userStatsBlock->count(), 'Stats block not found');
|
|
|
|
// Assuming we have 3 rows in the stats block
|
|
|
|
$this->assertEquals(3, $userStatsBlock->children()->count());
|
|
|
|
// @todo rewrite to named classes
|
|
|
|
// Assuming we have at least one user shown
|
|
|
|
$this->assertGreaterThan(
|
|
|
|
0,
|
|
|
|
$userStatsBlock->children()->first()->children()->last()->text(),
|
|
|
|
'Zero service users shown on the main page'
|
|
|
|
);
|
|
|
|
// Assuming we have at least one subscriber
|
|
|
|
$this->assertGreaterThan(
|
|
|
|
0,
|
|
|
|
$userStatsBlock->children()->eq(1)->children()->last()->text()
|
|
|
|
);
|
|
|
|
}
|
2015-05-30 06:22:06 +00:00
|
|
|
}
|