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.
93 lines
3.1 KiB
93 lines
3.1 KiB
<?php
|
|
|
|
use PHPUnit\Framework\TestCase;
|
|
use controllers\ControllerAdminAdministrators;
|
|
|
|
final class testAdminAdministrators extends TestCase
|
|
{
|
|
public function testInstanciation()
|
|
{
|
|
$controller = new ControllerAdminAdministrators();
|
|
$this->expectOutputString('Location:/loginAdmin');
|
|
$this->assertInstanceOf(ControllerAdminAdministrators::class, $controller);
|
|
}
|
|
|
|
public function testDelete()
|
|
{
|
|
$controller = new ControllerAdminAdministrators();
|
|
$controller->delete(["id" => 1]);
|
|
//$this->expectOutputString('Location:/admin/administrators');
|
|
}
|
|
|
|
public function testAdd()
|
|
{
|
|
$controller = new ControllerAdminAdministrators();
|
|
$_SERVER['REQUEST_METHOD'] = 'POST';
|
|
$_POST['username'] = 'test';
|
|
$_POST['password'] = 'test';
|
|
$controller->add(["id" => 1]);
|
|
$this->expectOutputString('Location:/admin/administrators');
|
|
|
|
$_SERVER['REQUEST_METHOD'] = 'GET';
|
|
$controller->add(["id" => 1]);
|
|
$this->expectOutputString('Location:/admin/administrators');
|
|
|
|
$_SERVER['REQUEST_METHOD'] = 'POST';
|
|
$_POST['username'] = '';
|
|
$_POST['password'] = '';
|
|
$controller->add(["id" => 1]);
|
|
$this->expectOutputString('Location:/admin/administrators');
|
|
|
|
$_SERVER['REQUEST_METHOD'] = 'POST';
|
|
$_POST['username'] = 'test';
|
|
$_POST['password'] = '';
|
|
$controller->add(["id" => 1]);
|
|
$this->expectOutputString('Location:/admin/administrators');
|
|
|
|
$_SERVER['REQUEST_METHOD'] = 'POST';
|
|
$_POST['username'] = '';
|
|
$_POST['password'] = 'test';
|
|
$controller->add(["id" => 1]);
|
|
$this->expectOutputString('Location:/admin/administrators');
|
|
}
|
|
|
|
public function testUpdateModal()
|
|
{
|
|
$controller = new ControllerAdminAdministrators();
|
|
$controller->updateModal(["id" => 121]);
|
|
$this->expectOutputString('Location:/admin/administrators');
|
|
}
|
|
|
|
public function testUpdate()
|
|
{
|
|
$controller = new ControllerAdminAdministrators();
|
|
$_SERVER['REQUEST_METHOD'] = 'POST';
|
|
$_POST['username'] = 'test';
|
|
$_POST['password'] = 'test';
|
|
$controller->update(["id" => 1]);
|
|
$this->expectOutputString('Location:/admin/administrators');
|
|
|
|
$_SERVER['REQUEST_METHOD'] = 'GET';
|
|
$controller->update(["id" => 1]);
|
|
$this->expectOutputString('Location:/admin/administrators');
|
|
|
|
$_SERVER['REQUEST_METHOD'] = 'POST';
|
|
$_POST['username'] = '';
|
|
$_POST['password'] = '';
|
|
$controller->update(["id" => 1]);
|
|
$this->expectOutputString('Location:/admin/administrators');
|
|
|
|
$_SERVER['REQUEST_METHOD'] = 'POST';
|
|
$_POST['username'] = 'test';
|
|
$_POST['password'] = '';
|
|
$controller->update(["id" => 1]);
|
|
$this->expectOutputString('Location:/admin/administrators');
|
|
|
|
$_SERVER['REQUEST_METHOD'] = 'POST';
|
|
$_POST['username'] = '';
|
|
$_POST['password'] = 'test';
|
|
$controller->update(["id" => 1]);
|
|
$this->expectOutputString('Location:/admin/administrators');
|
|
}
|
|
}
|