- [.] [phpunit/tests/Database_check] Tests unitaire du checker
- [x] [phpunit/] Install+Config phpunit
This commit is contained in:
parent
04540bb092
commit
594cad0ea4
|
@ -1,5 +1,4 @@
|
|||
<?php define('__ROOT__', dirname(__FILE__) );
|
||||
|
||||
require_once __ROOT__.'/manager/autoloader.php';
|
||||
|
||||
/*******************************************/
|
||||
|
|
|
@ -141,7 +141,10 @@
|
|||
case 'user.code':
|
||||
return $checker && is_string($value) && preg_match('/^[\dA-F]{2}(\-[\dA-F]{2}){3,5}$/i', $value);
|
||||
break;
|
||||
case 'user.username': case 'user.firstname': case 'user.lastname':
|
||||
case 'user.username': case 'user.lastname':
|
||||
return $checker && is_string($value) && preg_match('/^[\w-]{3,30}$/i', $value);
|
||||
break;
|
||||
case 'user.firstname': case 'user.lastname':
|
||||
return $checker && is_string($value) && preg_match('/^[a-z -]{3,30}$/i', $value);
|
||||
break;
|
||||
case 'user.mail':
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
<?php
|
||||
<?php define('__ROOT__', dirname(dirname(__FILE__)) );
|
||||
|
||||
function debug(){
|
||||
ini_set('display_errors',1);
|
||||
|
@ -25,7 +25,7 @@
|
|||
require_once $path;
|
||||
}
|
||||
|
||||
// On definit l'autoloader
|
||||
// On definit l'autoloader comme autoloader (obvious)
|
||||
spl_autoload_register('autoloader', false, true);
|
||||
|
||||
|
||||
|
|
|
@ -0,0 +1,14 @@
|
|||
<phpunit bootstrap="../manager/autoloader.php">
|
||||
|
||||
<testsuites>
|
||||
<testsuite name="Database::check">
|
||||
<file>tests/Database_check.php</file>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
|
||||
|
||||
<logging>
|
||||
<log type="coverage-html" target="coverage"/>
|
||||
</logging>
|
||||
|
||||
</phpunit>
|
|
@ -0,0 +1,167 @@
|
|||
<?php
|
||||
|
||||
class Database_check extends PHPUnit_Framework_TestCase{
|
||||
|
||||
|
||||
/* [1] AUTO_INCREMENT
|
||||
=========================================================*/
|
||||
public function testAutoIncrementSizeInfCorrect(){
|
||||
$this->assertTrue( \manager\Database::check('auto_increment_id', -2147483647) );
|
||||
}
|
||||
public function testAutoIncrementSizeInfStringCorrect(){
|
||||
$this->assertTrue( \manager\Database::check('auto_increment_id', '-2147483647') );
|
||||
}
|
||||
|
||||
|
||||
public function testAutoIncrementSizeSupCorrect(){
|
||||
$this->assertTrue( \manager\Database::check('auto_increment_id', 2147483647) );
|
||||
}
|
||||
public function testAutoIncrementSizeSupStringCorrect(){
|
||||
$this->assertTrue( \manager\Database::check('auto_increment_id', '2147483647') );
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function testAutoIncrementSizeLtInfIncorrect(){
|
||||
$this->assertFalse( \manager\Database::check('auto_increment_id', -2147483647-1) );
|
||||
}
|
||||
public function testAutoIncrementSizeLtInfStringIncorrect(){
|
||||
$this->assertFalse( \manager\Database::check('auto_increment_id', '-2147483648') );
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function testAutoIncrementSizeGtSupIncorrect(){
|
||||
$this->assertFalse( \manager\Database::check('auto_increment_id', 2147483647+1) );
|
||||
}
|
||||
public function testAutoIncrementSizeGtSupStringIncorrect(){
|
||||
$this->assertFalse( \manager\Database::check('auto_increment_id', '2147483648') );
|
||||
}
|
||||
|
||||
|
||||
/* [1] Code RFID
|
||||
=========================================================*/
|
||||
public function testUserCodeSize4(){
|
||||
$this->assertTrue( \manager\Database::check('user.code', '01-23-AB-CD') );
|
||||
}
|
||||
|
||||
public function testUserCodeSize6(){
|
||||
$this->assertTrue( \manager\Database::check('user.code', '01-23-45-67-89-AB') );
|
||||
}
|
||||
|
||||
public function testUserCodeSize4WrongCharacter(){
|
||||
$this->assertFalse( \manager\Database::check('user.code', '01-23-AB-CG') );
|
||||
}
|
||||
|
||||
public function testUserCodeSizeGreaterThan6(){
|
||||
$this->assertFalse( \manager\Database::check('user.code', '01-23-45-67-89-AB-CD') );
|
||||
}
|
||||
|
||||
public function testUserCodeSize6WrongCharacter(){
|
||||
$this->assertFalse( \manager\Database::check('user.code', '01-23-45-67-89-AG') );
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* [2] username
|
||||
=========================================================*/
|
||||
/* (1) Type */
|
||||
public function testUsernameTypeStringCorrect(){
|
||||
$this->assertTrue( \manager\Database::check('user.username', '012') );
|
||||
}
|
||||
|
||||
public function testUsernameTypeIntIncorrect(){
|
||||
$this->assertFalse( \manager\Database::check('user.username', 012) );
|
||||
}
|
||||
|
||||
/* (2) Content */
|
||||
public function testUsernameContentCorrect(){
|
||||
$this->assertTrue( \manager\Database::check('user.username', '0123456789_-') );
|
||||
$this->assertTrue( \manager\Database::check('user.username', 'abcdefghijklmnopqrstuvwxyz') );
|
||||
$this->assertTrue( \manager\Database::check('user.username', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ') );
|
||||
}
|
||||
|
||||
public function testUsernameContentIncorrect(){
|
||||
$illegal_chars = '{}[]()=+.,\'\\"/:;|!@#$%^&* ';
|
||||
|
||||
foreach(str_split($illegal_chars) as $char) // Teste les caracteres enonces plus haut
|
||||
$this->assertFalse( \manager\Database::check('user.username', 'abc'.$char) );
|
||||
}
|
||||
|
||||
/* (3) Size */
|
||||
public function testUsernameSize3Correct(){
|
||||
$this->assertTrue( \manager\Database::check('user.username', '012') );
|
||||
}
|
||||
|
||||
public function testUsernameSize30Correct(){
|
||||
$this->assertTrue( \manager\Database::check('user.username', '0123456789abcdefghijklmno_-sda') );
|
||||
}
|
||||
|
||||
public function testUsernameSizeLt3Incorrect(){
|
||||
$this->assertFalse( \manager\Database::check('user.username', '01') );
|
||||
}
|
||||
|
||||
public function testUsernameSizeGt30Incorrect(){
|
||||
$this->assertFalse( \manager\Database::check('user.username', '0123456789abcdefghijklmno_-sdaa') );
|
||||
}
|
||||
|
||||
/* [3] firstname / lastname
|
||||
=========================================================*/
|
||||
/* (1) Type */
|
||||
public function testFirstnameTypeStringCorrect(){
|
||||
$this->assertTrue( \manager\Database::check('user.firstname', 'abc') );
|
||||
}
|
||||
|
||||
public function testFirstnameTypeIntIncorrect(){
|
||||
$this->assertFalse( \manager\Database::check('user.firstname', 01932) );
|
||||
}
|
||||
|
||||
/* (2) Content */
|
||||
public function testFirstnameContentCorrect(){
|
||||
$this->assertTrue( \manager\Database::check('user.firstname', 'abcdefghijklmnopqrstuvwxyz') );
|
||||
$this->assertTrue( \manager\Database::check('user.firstname', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ') );
|
||||
}
|
||||
|
||||
public function testFirstnameContentIncorrect(){
|
||||
$illegal_chars = '{}[]()=_+.,\'\\"/:;|!@#$%^&*0123456789';
|
||||
|
||||
foreach(str_split($illegal_chars) as $char) // Teste les caracteres enonces plus haut
|
||||
$this->assertFalse( \manager\Database::check('user.firstname', 'abc'.$char) );
|
||||
}
|
||||
|
||||
/* (3) Size */
|
||||
public function testFirstnameSize3Correct(){
|
||||
$this->assertTrue( \manager\Database::check('user.firstname', 'abc') );
|
||||
}
|
||||
|
||||
public function testFirstnameSize30Correct(){
|
||||
$this->assertTrue( \manager\Database::check('user.firstname', 'abcdefghijklmnopqrstuvwxyz-k s') );
|
||||
}
|
||||
|
||||
public function testFirstnameSizeLt3Incorrect(){
|
||||
$this->assertFalse( \manager\Database::check('user.firstname', 'ab') );
|
||||
}
|
||||
|
||||
public function testFirstnameSizeGt30Incorrect(){
|
||||
$this->assertFalse( \manager\Database::check('user.firstname', 'abcdefghijklmnopqrstuvwxyz-k ss') );
|
||||
}
|
||||
|
||||
/* [4] Adresse mail
|
||||
=========================================================*/
|
||||
public function testMailContentCorrect(){
|
||||
$this->assertTrue( \manager\Database::check('user.mail', 'nom-prenom.mot@domaine-d.gouv') );
|
||||
}
|
||||
|
||||
public function testMailContentIncorrect1(){
|
||||
$this->assertFalse( \manager\Database::check('user.mail', 'nom-prenom.mot@domaine-d.gouve') );
|
||||
}
|
||||
|
||||
public function testMailContentIncorrect2(){
|
||||
$this->assertFalse( \manager\Database::check('user.mail', 'nom-prenom.mot@domaine-d.g') );
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
2
todo.md
2
todo.md
|
@ -13,6 +13,7 @@
|
|||
############
|
||||
# EN COURS #
|
||||
############
|
||||
- [.] [phpunit/tests/Database_check] Tests unitaire du checker
|
||||
- [ ] [Database] Checker de type
|
||||
- [ ] Gestion des groupes (utilisateurs/machines)
|
||||
- [x] bdd
|
||||
|
@ -40,6 +41,7 @@
|
|||
########
|
||||
# FAIT #
|
||||
########
|
||||
- [x] [phpunit/] Install+Config phpunit
|
||||
- [x] [manager/Repo] Gestion des Repo
|
||||
- [x] [ManagerError] Correction/ajout des codes erreurs
|
||||
- [x] [ModuleRequest] Modification des erreurs
|
||||
|
|
|
@ -91,6 +91,14 @@
|
|||
echo $user['mail'];
|
||||
echo "</span>";
|
||||
echo"</span>";
|
||||
|
||||
// Groupes de la machine
|
||||
echo "<span class='groups'>";
|
||||
echo \manager\ResourceDispatcher::getResource('f/svg/group/st/container');
|
||||
|
||||
echo "<span>a</span>";
|
||||
echo "<span>a</span>";
|
||||
echo"</span>";
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue