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/testAdminQuestions.php

60 lines
1.9 KiB

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