Tests: Add tests

pull/3959/head
Julio 4 years ago
parent 3505aafc39
commit 372bf351e3
  1. 31
      tests/CoreBundle/Controller/AccountControllerTest.php
  2. 45
      tests/CoreBundle/Controller/CourseControllerTest.php
  3. 4
      tests/CoreBundle/Controller/IndexControllerTest.php
  4. 29
      tests/CoreBundle/Controller/ToolControllerTest.php

@ -0,0 +1,31 @@
<?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 AccountControllerTest extends WebTestCase
{
use ChamiloTestTrait;
public function testEdit(): void
{
$client = static::createClient();
// retrieve the admin
$admin = $this->getUser('admin');
// simulate $testUser being logged in
$client->loginUser($admin);
$client->request('GET', '/account/edit');
$this->assertSame(Response::HTTP_OK, $client->getResponse()->getStatusCode());
}
}

@ -0,0 +1,45 @@
<?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 CourseControllerTest extends WebTestCase
{
use ChamiloTestTrait;
public function testHomeRedirectAction(): void
{
$client = static::createClient();
$course = $this->createCourse('new');
$admin = $this->getUser('admin');
// simulate $testUser being logged in
$client->loginUser($admin);
$client->request('GET', '/course/'.$course->getCode().'/index.php');
$this->assertResponseRedirects('/course/'.$course->getId().'/home');
}
public function testWelcomeAction(): void
{
$client = static::createClient();
$course = $this->createCourse('new course');
$admin = $this->getUser('admin');
// simulate $testUser being logged in
$client->loginUser($admin);
$client->request('GET', '/course/'.$course->getId().'/welcome');
$this->assertSame(Response::HTTP_OK, $client->getResponse()->getStatusCode());
$this->assertStringContainsString('new course', $client->getResponse()->getContent());
}
}

@ -22,7 +22,7 @@ class IndexControllerTest extends WebTestCase
$this->assertResponseIsSuccessful();
}
public function testUserAccess(): void
public function testToggleStudentViewAction(): void
{
$client = static::createClient();
@ -32,7 +32,7 @@ class IndexControllerTest extends WebTestCase
// simulate $testUser being logged in
$client->loginUser($admin);
$client->request('GET', '/account/edit');
$client->request('GET', '/toggle_student_view');
$this->assertSame(Response::HTTP_OK, $client->getResponse()->getStatusCode());
}

@ -0,0 +1,29 @@
<?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;
class ToolControllerTest extends WebTestCase
{
use ChamiloTestTrait;
public function testToolUpdate(): void
{
$client = static::createClient();
$admin = $this->getUser('admin');
// simulate $testUser being logged in
$client->loginUser($admin);
$client->request('GET', '/tool/update');
$this->assertResponseIsSuccessful();
$this->assertStringContainsString('Updated', $client->getResponse()->getContent());
}
}
Loading…
Cancel
Save