Compare commits
3 Commits
Author | SHA1 | Date |
---|---|---|
|
05664ac355 | 2 years ago |
|
c83272e06f | 2 years ago |
![]() |
c035dbcb02 | 2 years ago |
@ -0,0 +1,69 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace testModel;
|
||||||
|
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
use Model\ModelAdmin;
|
||||||
|
use Exception;
|
||||||
|
|
||||||
|
class ModelAdminTest extends TestCase
|
||||||
|
{
|
||||||
|
public function testConstructor()
|
||||||
|
{
|
||||||
|
$model = new ModelAdmin();
|
||||||
|
$this->assertInstanceOf(ModelAdmin::class, $model);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testAddQuestionInvalidType()
|
||||||
|
{
|
||||||
|
$this->expectException(Exception::class);
|
||||||
|
$this->expectExceptionMessage("Type de question invalide");
|
||||||
|
$_POST['type']="JeSuisUnTypeInvalideDePlusDe50CaracteresEtJeSuisTropLongPourEtreUnTypeDeQuestionValide";
|
||||||
|
$_POST['question']="Suis-je une question valide ?";
|
||||||
|
$model = (new ModelAdmin())->addQuestion();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testDeleteQuestionInvalidType()
|
||||||
|
{
|
||||||
|
$this->expectException(Exception::class);
|
||||||
|
$this->expectExceptionMessage("Type de question invalide");
|
||||||
|
$_POST['type']="JeSuisUnTypeInvalideDePlusDe50CaracteresEtJeSuisTropLongPourEtreUnTypeDeQuestionValide";
|
||||||
|
$_POST['question']="Suis-je une question valide ?";
|
||||||
|
$model = (new ModelAdmin())->deleteQuestion();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testAddResponseInvalidCategories()
|
||||||
|
{
|
||||||
|
$this->expectException(Exception::class);
|
||||||
|
$this->expectExceptionMessage('Categories invalides');
|
||||||
|
$_POST['categories']=['JeSuisUneCategorieInvalideDePlusDe50CaracteresEtJeSuisTropLonguePourEtreUneCategorieValide'];
|
||||||
|
$_POST['response']="Suis-je une réponse valide ?";
|
||||||
|
$model = (new ModelAdmin())->addResponse();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testAddKeywordInvalidKeyword()
|
||||||
|
{
|
||||||
|
$this->expectException(Exception::class);
|
||||||
|
$this->expectExceptionMessage('Mot clé invalide');
|
||||||
|
$_POST['keyword']="JeSuisUnMotCleInvalideDePlusDe50CaracteresEtJeSuisTropLonguePourEtreUnMotCleValide";
|
||||||
|
$model = (new ModelAdmin())->addKeyword();
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetCategories()
|
||||||
|
{
|
||||||
|
$categories = (new ModelAdmin())->getCategories();
|
||||||
|
$this->assertIsArray($categories);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetQuestions()
|
||||||
|
{
|
||||||
|
$questions = (new ModelAdmin())->getQuestions();
|
||||||
|
$this->assertIsArray($questions);
|
||||||
|
}
|
||||||
|
|
||||||
|
public function testGetResponsesCandidate()
|
||||||
|
{
|
||||||
|
$responses = (new ModelAdmin())->getResponsesCandidate();
|
||||||
|
$this->assertIsArray($responses);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,58 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace TestModel;
|
||||||
|
|
||||||
|
use Exceptions\InexistantLoginException;
|
||||||
|
use Exceptions\InvalidLoginOrPasswordException;
|
||||||
|
use Model\ModelCandidate;
|
||||||
|
use PHPUnit\Framework\TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
class ModelCandidateTest extends TestCase
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testInvalideAllArgumentLogin() {
|
||||||
|
$this->expectException(InvalidLoginOrPasswordException::class);
|
||||||
|
|
||||||
|
$_REQUEST['password'] = "";
|
||||||
|
$_REQUEST['login'] = "";
|
||||||
|
$model = new ModelCandidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testInvalidePasswordArgumentLogin() {
|
||||||
|
$this->expectException(InvalidLoginOrPasswordException::class);
|
||||||
|
|
||||||
|
$_REQUEST['password'] = "admin";
|
||||||
|
$_REQUEST['login'] = "aze";
|
||||||
|
$model = new ModelCandidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testInvalideLoginArgumentLogin() {
|
||||||
|
$this->expectException(InvalidLoginOrPasswordException::class);
|
||||||
|
|
||||||
|
$_REQUEST['password'] = "ad";
|
||||||
|
$_REQUEST['login'] = "azertyuiop";
|
||||||
|
$model = new ModelCandidate();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function testUndifineLoginArgumentLogin() {
|
||||||
|
$this->expectException(InexistantLoginException::class);
|
||||||
|
|
||||||
|
$_REQUEST['password'] = "invalideAdmin";
|
||||||
|
$_REQUEST['login'] = "azertyuiop";
|
||||||
|
$model = new ModelCandidate();
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in new issue