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.
3.01-QCM_MuscuMaths/Website/tests/testControllers/testAdminChapters.php

60 lines
1.8 KiB

<?php
use PHPUnit\Framework\TestCase;
use controllers\ControllerAdminChapters;
final class testAdminChapters extends TestCase
{
public function instanciation()
{
$controller = new ControllerAdminChapters();
$this->expectOutputString('Location:/loginAdmin');
$this->assertInstanceOf(ControllerAdminChapters::class, $controller);
}
public function testDelete()
{
$controller = new ControllerAdminChapters();
$controller->delete(["id" => 1]);
$this->expectOutputString('Location:/admin/chapters');
}
public function testAdd()
{
$controller = new ControllerAdminChapters();
$_SERVER['REQUEST_METHOD'] = 'POST';
$_POST['title'] = 'test';
$_POST['content'] = 'test';
$controller->add(["id" => 1]);
$this->expectOutputString('Location:/admin/chapters');
$_SERVER['REQUEST_METHOD'] = 'GET';
$controller->add(["id" => 1]);
$this->expectOutputString('Location:/admin/chapters');
$_SERVER['REQUEST_METHOD'] = 'POST';
$_POST['title'] = '';
$_POST['content'] = '';
$controller->add(["id" => 1]);
$this->expectOutputString('Location:/admin/chapters');
$_SERVER['REQUEST_METHOD'] = 'POST';
$_POST['title'] = 'test';
$_POST['content'] = '';
$controller->add(["id" => 1]);
$this->expectOutputString('Location:/admin/chapters');
$_SERVER['REQUEST_METHOD'] = 'POST';
$_POST['title'] = '';
$_POST['content'] = 'test';
$controller->add(["id" => 1]);
$this->expectOutputString('Location:/admin/chapters');
}
public function testUpdateModal()
{
$controller = new ControllerAdminChapters();
$controller->updateModal(["id" => 121]);
$this->expectOutputString('Location:/admin/chapters');
}
}