117 lines
3.4 KiB
PHP
Executable File
117 lines
3.4 KiB
PHP
Executable File
<?php namespace phpunit;
|
|
|
|
class Database_delNumeric extends \PHPUnit_Framework_TestCase{
|
|
|
|
/* [0] Verification du type
|
|
=========================================================*/
|
|
public function testTypeInt(){
|
|
$this->assertEquals( [], \manager\Database::delNumeric(10) );
|
|
}
|
|
|
|
public function testTypeString(){
|
|
$this->assertEquals( [], \manager\Database::delNumeric('notarray') );
|
|
}
|
|
|
|
/* [1] Verification pour 2 dimensions
|
|
=========================================================*/
|
|
/* (1) Global */
|
|
public function testGlobal2Dim(){
|
|
$fetchData = [[
|
|
'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 = [[
|
|
'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 = [
|
|
'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 = [
|
|
'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 );
|
|
}
|
|
|
|
}
|
|
|
|
?>
|