SMMP/phpunit/tests/Database_delNumeric.php

117 lines
3.5 KiB
PHP
Raw Normal View History

<?php namespace phpunit;
class Database_delNumeric extends \PHPUnit_Framework_TestCase{
/* [0] Verification du type
=========================================================*/
public function testTypeInt(){
$this->assertEquals( [], \database\core\DatabaseDriver::delNumeric(10) );
}
public function testTypeString(){
$this->assertEquals( [], \database\core\DatabaseDriver::delNumeric('notarray') );
}
/* [1] Verification pour 2 dimensions
=========================================================*/
/* (1) Global */
public function testGlobal2Dim(){
2016-07-04 13:45:29 +00:00
$fetchData = [[
'id' => '000001',
0 => '000001',
'nom' => 'Jean Dupont',
1 => 'Jean Dupont',
2016-07-04 13:45:29 +00:00
]];
$computed_array = \database\core\DatabaseDriver::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(){
2016-07-04 13:45:29 +00:00
$fetchData = [[
'id' => '000001',
0 => '000001',
'nom' => 'Jean Dupont',
1 => 'Jean Dupont',
2 => 'Bla',
3 => 'Bla',
4 => 'Bla',
5 => 'Bla',
6 => 'Bla',
7 => 'Bla'
2016-07-04 13:45:29 +00:00
]];
$computed_array = \database\core\DatabaseDriver::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(){
2016-07-04 13:45:29 +00:00
$fetchData = [
'id' => '000001',
0 => '000001',
'nom' => 'Jean Dupont',
1 => 'Jean Dupont'
2016-07-04 13:45:29 +00:00
];
$computed_array = \database\core\DatabaseDriver::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(){
2016-07-04 13:45:29 +00:00
$fetchData = [
'id' => '000001',
0 => '000001',
'nom' => 'Jean Dupont',
1 => 'Jean Dupont',
2 => 'Bla',
3 => 'Bla',
4 => 'Bla',
5 => 'Bla',
6 => 'Bla',
7 => 'Bla'
2016-07-04 13:45:29 +00:00
];
$computed_array = \database\core\DatabaseDriver::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 );
}
}
2016-07-04 13:45:29 +00:00
?>