projet-php/test/StaticRepoTest.php

64 lines
2.6 KiB
PHP
Raw Permalink Normal View History

<?php
/**
* Created by PhpStorm.
* User: seekdasky
* Date: 09/12/15
* Time: 12:44
*/
class StaticRepoTest extends PHPUnit_Framework_TestCase
{
public function testGetConnexion(){
$this->assertTrue(StaticRepo::getConnexion() instanceof PDO);
}
public function testTestConnexion(){
$this->assertTrue(StaticRepo::testConnexion());
}
public function testDelNumericOneDimension(){
$array = [0=>'kjbk','kughk'=>'kjbk',1=>'aze','azert'=>'aza'];
$this->assertEquals(StaticRepo::delNumeric($array,true),['kughk'=>'kjbk','azert'=>'aza']);
}
public function testDelNumericTwoDimension(){
$array = [0=>[0=>'kjbk','kughk'=>'kjbk',1=>'aze','azert'=>'aze'],1=>[0=>'kjbk','kughk'=>'kjbk',1=>'aze','azert'=>'aza']];
$this->assertEquals(StaticRepo::delNumeric($array),[0=>['kughk'=>'kjbk','azert'=>'aze'],1=>['kughk'=>'kjbk','azert'=>'aza']]);
}
public function testCheckParam(){
$this->assertTrue(StaticRepo::checkParam("Bonjour",'String20'));
$this->assertFalse(StaticRepo::checkParam("Bonjour",'String5'));
$this->assertTrue(StaticRepo::checkParam("M",'Civilite'));
$this->assertTrue(StaticRepo::checkParam("F",'Civilite'));
$this->assertFalse(StaticRepo::checkParam("P",'Civilite'));
$this->assertTrue(StaticRepo::checkParam(100,'Integer'));
$this->assertTrue(StaticRepo::checkParam(0,'Integer'));
$this->assertFalse(StaticRepo::checkParam(4294967296,'Integer'));
$this->assertTrue(StaticRepo::checkParam(100,'TinyInteger'));
$this->assertTrue(StaticRepo::checkParam(0,'TinyInteger'));
$this->assertFalse(StaticRepo::checkParam(256,'TinyInteger'));
$this->assertTrue(StaticRepo::checkParam(100,'SmallInteger'));
$this->assertTrue(StaticRepo::checkParam(0,'SmallInteger'));
$this->assertFalse(StaticRepo::checkParam(65536,'SmallInteger'));
$this->assertTrue(StaticRepo::checkParam(100,'BigInteger'));
$this->assertTrue(StaticRepo::checkParam(0,'BigInteger'));
$this->assertFalse(StaticRepo::checkParam(18446744073700000000,'BigInteger'));
2015-12-10 10:46:29 +00:00
$this->assertTrue(StaticRepo::checkParam('19/11/1996','Date'));
$this->assertFalse(StaticRepo::checkParam('15/1551','Date'));
$this->assertFalse(StaticRepo::checkParam('15/1f/5451','Date'));
$this->assertTrue(StaticRepo::checkParam('19:30','Heure'));
$this->assertFalse(StaticRepo::checkParam('af:65','Heure'));
$this->assertFalse(StaticRepo::checkParam('15451','Heure'));
$this->assertFalse(StaticRepo::checkParam('lololo','lolololo'));
}
}