2016-02-13 16:28:28 +00:00
|
|
|
<?php namespace phpunit;
|
2016-02-12 19:49:03 +00:00
|
|
|
|
2016-02-13 16:28:28 +00:00
|
|
|
class Database_delNumeric extends \PHPUnit_Framework_TestCase{
|
2016-02-12 19:49:03 +00:00
|
|
|
|
|
|
|
/* [1] Verification pour 2 dimensions
|
|
|
|
=========================================================*/
|
|
|
|
/* (1) Global */
|
|
|
|
public function testGlobal2Dim(){
|
|
|
|
$fetchData = array(array(
|
|
|
|
'id' => '000001',
|
|
|
|
0 => '000001',
|
|
|
|
'nom' => 'Jean Dupont',
|
|
|
|
1 => 'Jean Dupont',
|
|
|
|
));
|
|
|
|
|
|
|
|
$computed_array = \manager\Database::delNumeric( $fetchData );
|
|
|
|
|
|
|
|
$this->assertArrayHasKey( 'id', $computed_array[0] );
|
|
|
|
$this->assertArrayHasKey( 'nom', $computed_array[0] );
|
|
|
|
$this->assertArrayNotHasKey( 0, $computed_array[0] );
|
|
|
|
$this->assertArrayNotHasKey( 1, $computed_array[0] );
|
|
|
|
}
|
|
|
|
|
|
|
|
/* (2) Verification d'indices numeriques dans les donnees */
|
|
|
|
public function testGlobal2DimWithNumericIndexes(){
|
|
|
|
$fetchData = array(array(
|
|
|
|
'id' => '000001',
|
|
|
|
0 => '000001',
|
|
|
|
'nom' => 'Jean Dupont',
|
|
|
|
1 => 'Jean Dupont',
|
|
|
|
2 => 'Bla',
|
|
|
|
3 => 'Bla',
|
|
|
|
4 => 'Bla',
|
|
|
|
5 => 'Bla',
|
|
|
|
6 => 'Bla',
|
|
|
|
7 => 'Bla'
|
|
|
|
));
|
|
|
|
|
|
|
|
$computed_array = \manager\Database::delNumeric( $fetchData );
|
|
|
|
|
|
|
|
$this->assertArrayHasKey( 'id', $computed_array[0] );
|
|
|
|
$this->assertArrayHasKey( 'nom', $computed_array[0] );
|
|
|
|
$this->assertArrayNotHasKey( 0, $computed_array[0] );
|
|
|
|
$this->assertArrayNotHasKey( 1, $computed_array[0] );
|
|
|
|
|
|
|
|
$this->assertArrayHasKey( 2, $computed_array[0] );
|
|
|
|
$this->assertArrayHasKey( 3, $computed_array[0] );
|
|
|
|
$this->assertArrayHasKey( 4, $computed_array[0] );
|
|
|
|
$this->assertArrayHasKey( 5, $computed_array[0] );
|
|
|
|
$this->assertArrayHasKey( 6, $computed_array[0] );
|
|
|
|
$this->assertArrayHasKey( 7, $computed_array[0] );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* [2] Verification pour 1 dimensions
|
|
|
|
=========================================================*/
|
|
|
|
/* (1) Global */
|
|
|
|
public function testGlobal1Dim(){
|
|
|
|
$fetchData = array(
|
|
|
|
'id' => '000001',
|
|
|
|
0 => '000001',
|
|
|
|
'nom' => 'Jean Dupont',
|
|
|
|
1 => 'Jean Dupont'
|
|
|
|
);
|
|
|
|
|
|
|
|
$computed_array = \manager\Database::delNumeric( $fetchData );
|
|
|
|
|
|
|
|
$this->assertArrayHasKey( 'id', $computed_array );
|
|
|
|
$this->assertArrayHasKey( 'nom', $computed_array );
|
|
|
|
$this->assertArrayNotHasKey( 0, $computed_array );
|
|
|
|
$this->assertArrayNotHasKey( 1, $computed_array );
|
|
|
|
}
|
|
|
|
|
|
|
|
/* (2) Verification d'indices numeriques dans les donnees */
|
|
|
|
public function testGlobal1DimWithNumericIndexes(){
|
|
|
|
$fetchData = array(
|
|
|
|
'id' => '000001',
|
|
|
|
0 => '000001',
|
|
|
|
'nom' => 'Jean Dupont',
|
|
|
|
1 => 'Jean Dupont',
|
|
|
|
2 => 'Bla',
|
|
|
|
3 => 'Bla',
|
|
|
|
4 => 'Bla',
|
|
|
|
5 => 'Bla',
|
|
|
|
6 => 'Bla',
|
|
|
|
7 => 'Bla'
|
|
|
|
);
|
|
|
|
|
|
|
|
$computed_array = \manager\Database::delNumeric( $fetchData );
|
|
|
|
|
|
|
|
$this->assertArrayHasKey( 'id', $computed_array );
|
|
|
|
$this->assertArrayHasKey( 'nom', $computed_array );
|
|
|
|
$this->assertArrayNotHasKey( 0, $computed_array );
|
|
|
|
$this->assertArrayNotHasKey( 1, $computed_array );
|
|
|
|
|
|
|
|
$this->assertArrayHasKey( 2, $computed_array );
|
|
|
|
$this->assertArrayHasKey( 3, $computed_array );
|
|
|
|
$this->assertArrayHasKey( 4, $computed_array );
|
|
|
|
$this->assertArrayHasKey( 5, $computed_array );
|
|
|
|
$this->assertArrayHasKey( 6, $computed_array );
|
|
|
|
$this->assertArrayHasKey( 7, $computed_array );
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
?>
|