You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.6 KiB
61 lines
1.6 KiB
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
/* For licensing terms, see /license.txt */
|
|
|
|
namespace Chamilo\Tests\CoreBundle\Controller;
|
|
|
|
use Chamilo\Tests\ChamiloTestTrait;
|
|
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
|
|
class IndexControllerTest extends WebTestCase
|
|
{
|
|
use ChamiloTestTrait;
|
|
|
|
public function testIndex(): void
|
|
{
|
|
$client = static::createClient();
|
|
$client->request('GET', '/');
|
|
|
|
$this->assertResponseIsSuccessful();
|
|
}
|
|
|
|
public function testToggleStudentViewAction(): void
|
|
{
|
|
$client = static::createClient();
|
|
|
|
// retrieve the admin
|
|
$admin = $this->getUser('admin');
|
|
|
|
// simulate $testUser being logged in
|
|
$client->loginUser($admin);
|
|
|
|
$client->request('GET', '/toggle_student_view');
|
|
|
|
$this->assertSame(Response::HTTP_OK, $client->getResponse()->getStatusCode());
|
|
}
|
|
|
|
public function testLogout(): void
|
|
{
|
|
$client = static::createClient();
|
|
$response = $client->request('GET', '/');
|
|
$defaultUrl = $response->getUri();
|
|
|
|
// retrieve the admin
|
|
$admin = $this->getUser('admin');
|
|
|
|
// simulate $testUser being logged in
|
|
$client->loginUser($admin);
|
|
|
|
$client->request('GET', '/account/home');
|
|
$this->assertSame(Response::HTTP_OK, $client->getResponse()->getStatusCode());
|
|
|
|
$client->request('GET', '/logout');
|
|
$this->assertResponseRedirects($defaultUrl);
|
|
|
|
$client->request('GET', '/main/admin/index.php');
|
|
$this->assertSame(Response::HTTP_INTERNAL_SERVER_ERROR, $client->getResponse()->getStatusCode());
|
|
}
|
|
}
|
|
|