/** * @file * @brief test the Card Properties */ /** * @testdox Test card : save attributes, insert card, create card category * @covers Card_Property * @backupGlobals enabled */ class Card_PropertyTest extends TestCase { const FICHE_DEF='TESTPROPERTY'; const FICHE_QCODE='PHPUNIT_CARD'; /** * @brief * @global type $g_connection */ static function setUpBeforeClass():void { global $g_connection; $g_connection=Dossier::connect(); // clean if exists $fiche_def_id=$g_connection->get_value("select fd_id from fiche_def where fd_label=$1", [self::FICHE_DEF]); if ($g_connection->size()>0) { $g_connection->exec_sql("delete from jnt_fic_attr where fd_id=$1", [$fiche_def_id]); $g_connection->exec_sql("delete from fiche_detail where f_id in (select f_id from fiche where fd_id=$1)", [$fiche_def_id]); $g_connection->exec_sql("delete from fiche where fd_id=$1", [$fiche_def_id]); $g_connection->exec_sql("delete from fiche_def where fd_id=$1", [$fiche_def_id]); } // create a category of card, type Charges $fiche_def=new Fiche_Def($g_connection); $aParam=["nom_mod"=>"TESTPROPERTY", "fd_description"=>'PHPUNIT test', 'class_base'=>'600', 'FICHE_REF'=>3, 'create'=>1]; $fiche_def->add($aParam); // add to this new categorie all the possible attributes $aProperty=$g_connection->get_array("select ad_id from attr_def where ad_id not in ( select ad_id from jnt_fic_attr where fd_id=$1)", [$fiche_def->id]); foreach ($aProperty as $property) { $fiche_def->InsertAttribut($property['ad_id']); } $fiche=new Fiche($g_connection); $fiche->set_fiche_def($fiche_def->id); $fiche->attribut=$fiche_def->getAttribut(); foreach ($fiche->attribut as $row) { $fiche->setAttribut($row->ad_id, "av_text = {$row->ad_id}"); } $fiche->setAttribut(ATTR_DEF_QUICKCODE, self::FICHE_QCODE); $fiche->setAttribut(ATTR_DEF_ACCOUNT, '600'); $fiche->setAttribut(ATTR_DEF_TVA, ''); $fiche->insert($fiche_def->id, $fiche->to_array()); $fiche->load(); } public static function tearDownAfterClass():void { global $g_connection; $g_connection=Dossier::connect(); // clean if exists $fiche_def_id=$g_connection->get_value("select fd_id from fiche_def where fd_label=$1", [self::FICHE_DEF]); if ($g_connection->size()>0) { $g_connection->exec_sql("delete from jnt_fic_attr where fd_id=$1", [$fiche_def_id]); $g_connection->exec_sql("delete from fiche_detail where f_id in (select f_id from fiche where fd_id=$1)", [$fiche_def_id]); $g_connection->exec_sql("delete from fiche where fd_id=$1", [$fiche_def_id]); $g_connection->exec_sql("delete from fiche_def where fd_id=$1", [$fiche_def_id]); } } public function getFicheDef() { global $g_connection; $g_connection=Dossier::connect(); $fiche_def_id=$g_connection->get_value("select fd_id from fiche_def where fd_label=$1", [self::FICHE_DEF]); $this->assertEquals($g_connection->size(), 1, 'find fiche_def.fd_id'); $fiche_def=new Fiche_Def($g_connection, $fiche_def_id); return $fiche_def; } public function getFiche() { global $g_connection; $g_connection=Dossier::connect(); $fiche_id=$g_connection->get_value("select f_id from fiche_detail where ad_id=23 and ad_value=$1 ", [self::FICHE_QCODE]); $this->assertEquals($g_connection->size(), 1, 'find fiche.f_id'); $fiche=new Fiche($g_connection, $fiche_id); return $fiche; } public function testPrint() { $fiche=$this->getFiche(); foreach ($fiche->attribut as $row) { $result=$row->print(); $this->assertStringStartsWith("