object=new Fiche($g_connection); } /** * Tears down the fixture, for example, closes a network connection. * This method is called after a test is executed. */ protected function tearDown() { } /** * @covers Fiche::cmp_name */ public function testCmp_name() { global $g_connection; $fiche=new \Fiche($g_connection,21); $fiche_2=new \Fiche($g_connection,25); $this->assertGreaterThan(\Fiche::cmp_name($fiche, $fiche_2),0); } /** * @covers Fiche::get_bk_account */ public function testGet_bk_account() { include 'global.php'; $this->object=new Fiche($g_connection); $result=$this->object->get_bk_account(); $this->assertEquals(gettype($result),'array'); $count = count($result); $this->assertGreaterThan(0,$count); } /** * @covers Fiche::get_row */ public function testGet_row() { include 'global.php'; $card_count=$g_connection->get_array("select count(*),f_id ". " from jrnx ". " where ". " f_id is not null ". "group by f_id order by count(*) desc"); $a=new Fiche($g_connection,$card_count[0]['f_id']); try { $a->get_row(235,238); $this->assertFalse(TRUE,"Exception periode invalide"); } catch (\Exception $e) { $this->assertTrue(TRUE); } $a_result= $a->get_row(92,131); // Size == 25 $nb_result=count($a_result); $this->assertEquals ($nb_result,3,"Size array not correct "); $this->assertEquals(198.74,$a_result[0][13]["deb_montant"],"Debit from operation 12"); } /** * @covers Fiche::count_by_modele() */ public function testCount_by_modele() { $nb=$this->object->count_by_modele(1,"",""); $this->assertEquals(4,$nb,"number of Sales Card "); $nb=$this->object->count_by_modele(3,"eau",""); $this->assertEquals(1,$nb,"Purchase card water "); $nb=$this->object->count_by_modele(3,"EAU",""); $this->assertEquals(1,$nb,"Purchase card water "); $nb=$this->object->count_by_modele(3,"ZZ",""); $this->assertEquals(0,$nb,"no card found"); $nb=$this->object->count_by_modele(3000,"",""); $this->assertEquals(0,$nb,"no card found"); $nb=$this->object->count_by_modele(3,"",""); $this->assertEquals(7,$nb,"Purchase cards "); // attempt to inject SQL command, you must get an error try { $nb=@$this->object->count_by_modele(3,""," ;delete from jrn;"); $this->assertFalse(true,"Inject SQL command not found"); } catch(Exception $e) { $this->assertTrue(true,"Inject SQL command found"); } } /** * @covers Fiche->Summary * @covers Fiche->get_by_category * @covers Fiche::GetByDef */ public function testSummary() { $_REQUEST['ac']="CARD"; $this->object->fiche_def_ref=-1; $r=$this->object->summary(); $this->assertEquals('',$r); $this->object->fiche_def_ref=9; $r=$this->object->summary(); $this->assertContains('',$r); } }