assertEquals( [], \database\core\Database::delNumeric(10) ); } public function testTypeString(){ $this->assertEquals( [], \database\core\Database::delNumeric('notarray') ); } /* [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 = \database\core\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 = \database\core\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 = \database\core\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 = \database\core\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 ); } } ?>