[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Noalyss-commit] [noalyss] 27/27: Test unitaire avec PHPUNIT
From: |
Dany De Bontridder |
Subject: |
[Noalyss-commit] [noalyss] 27/27: Test unitaire avec PHPUNIT |
Date: |
Sun, 02 Nov 2014 11:08:54 +0000 |
sparkyx pushed a commit to branch master
in repository noalyss.
commit f6a3b1e5e342678f85dc67465bb5bff6b7f1d680
Author: Dany De Bontridder <address@hidden>
Date: Sun Nov 2 12:04:32 2014 +0100
Test unitaire avec PHPUNIT
---
unit-test/README | 13 +
unit-test/bootstrap.php.example | 154 ++++++++++
unit-test/include/class_acc_accountTest.php | 144 ++++++++++
unit-test/include/class_acc_account_ledgerTest.php | 299 ++++++++++++++++++++
4 files changed, 610 insertions(+), 0 deletions(-)
diff --git a/unit-test/README b/unit-test/README
new file mode 100644
index 0000000..ff98d8a
--- /dev/null
+++ b/unit-test/README
@@ -0,0 +1,13 @@
+Ce répertoire sert aux tests unitaires avec PHPUNIT, il faut d'abord changer
dans le bootstrap.php pour que le path soit correct.
+Il faut configurer Netbeans pour pouvoir l'utiliser :
+1 . Activer PHPUNIT,
+2 . dans GLOBAL PATH (propriété du projet) ajouter le fichier phpunit.phar
+3. Donner unit-test comme répertoire de test
+
+Ensuite copier bootstrap.php.example vers bootstrap.php et modifier les
variables (le dossier à utiliser, include_path ...)
+
+Testing commande en ligne
+=========================
+Génération
+ php <chemin>/phpunit-skelgen.phar --bootstrap bootstrap.php --test --
Intervat ../include/class_transform_intervat.php
+ php <chemin>/phpunit.phar --tap --colors --bootstrap ../bootstrap.php
class_acc_accountTest.php
\ No newline at end of file
diff --git a/unit-test/bootstrap.php.example b/unit-test/bootstrap.php.example
new file mode 100644
index 0000000..62936a0
--- /dev/null
+++ b/unit-test/bootstrap.php.example
@@ -0,0 +1,154 @@
+<?php
+
+/*
+ * This file is part of NOALYSS.
+ *
+ * NOALYSS is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * NOALYSS is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with NOALYSS; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+*/
+
+// Copyright Author Dany De Bontridder address@hidden
+
+$path='/home/dany/developpement/phpcompta/noalyss/include:..:../include:/home/dany/Program/phpunit.phar';
+$old_path= get_include_path();
+set_include_path($old_path.':'.$path);
+
+define ("DOSSIER",37);
+
+/**
+ * Class to include,
+ */
+require_once 'class_acc_account.php';
+require_once 'class_acc_balance.php';
+require_once 'class_acc_bilan.php';
+require_once 'class_acc_compute.php';
+require_once 'class_acc_ledger_fin.php';
+require_once 'class_acc_ledger_info.php';
+require_once 'class_acc_ledger.php';
+require_once 'class_acc_ledger_purchase.php';
+require_once 'class_acc_ledger_sold.php';
+require_once 'class_acc_operation.php';
+require_once 'class_acc_parm_code.php';
+require_once 'class_acc_payment.php';
+require_once 'class_acc_reconciliation.php';
+require_once 'class_acc_report.php';
+require_once 'class_acc_report_row.php';
+require_once 'class_acc_tva.php';
+require_once 'class_admin.php';
+require_once 'class_anc_acc_link.php';
+require_once 'class_anc_acc_list.php';
+require_once 'class_anc_account.php';
+require_once 'class_anc_balance_double.php';
+require_once 'class_anc_balance_simple.php';
+require_once 'class_anc_grandlivre.php';
+require_once 'class_anc_group_operation.php';
+require_once 'class_anc_group.php';
+require_once 'class_anc_key.php';
+require_once 'class_anc_key_sql.php';
+require_once 'class_anc_listing.php';
+require_once 'class_anc_operation.php';
+require_once 'class_anc_plan.php';
+require_once 'class_anc_print.php';
+require_once 'class_anc_table.php';
+require_once 'class_anticipation.php';
+require_once 'class_bank.php';
+require_once 'class_calendar.php';
+require_once 'class_contact.php';
+require_once 'class_customer.php';
+require_once 'class_database.php';
+require_once 'class_default_menu.php';
+require_once 'class_default_menu_sql.php';
+require_once 'class_document_export.php';
+require_once 'class_document_modele.php';
+require_once 'class_document.php';
+require_once 'class_document_type.php';
+require_once 'class_dossier.php';
+require_once 'class_exercice.php';
+require_once 'class_extension.php';
+require_once 'class_fiche_attr.php';
+require_once 'class_fiche_def.php';
+require_once 'class_fiche_def_ref.php';
+require_once 'class_fiche.php';
+require_once 'class_filetosend.php';
+require_once 'class_follow_up_detail.php';
+require_once 'class_follow_up.php';
+require_once 'class_forecast_cat.php';
+require_once 'class_forecast_item.php';
+require_once 'class_forecast.php';
+require_once 'class_gestion_purchase.php';
+require_once 'class_gestion_sold.php';
+require_once 'class_gestion_table.php';
+require_once 'class_html_input.php';
+require_once 'class_html_table.php';
+require_once 'class_iaction.php';
+require_once 'class_ianccard.php';
+require_once 'class_ibutton.php';
+require_once 'class_icard.php';
+require_once 'class_icheckbox.php';
+require_once 'class_iconcerned.php';
+require_once 'class_idate.php';
+require_once 'class_ifile.php';
+require_once 'class_ihidden.php';
+require_once 'class_impress.php';
+require_once 'class_inum.php';
+require_once 'class_iperiod.php';
+require_once 'class_ipopup.php';
+require_once 'class_iposte.php';
+require_once 'class_iradio.php';
+require_once 'class_irelated_action.php';
+require_once 'class_iselect.php';
+require_once 'class_ispan.php';
+require_once 'class_itextarea.php';
+require_once 'class_itext.php';
+require_once 'class_itva_popup.php';
+require_once 'class_jrn_def_sql.php';
+require_once 'class_lettering.php';
+require_once 'class_manager.php';
+require_once 'class_menu_ref.php';
+require_once 'class_menu_ref_sql.php';
+require_once 'class_noalyss_sql.php';
+require_once 'class_own.php';
+require_once 'class_pdf.php';
+require_once 'class_periode.php';
+require_once 'class_pre_op_ach.php';
+require_once 'class_pre_op_advanced.php';
+require_once 'class_pre_operation.php';
+require_once 'class_pre_op_fin.php';
+require_once 'class_pre_op_ods.php';
+require_once 'class_pre_op_ven.php';
+require_once 'class_print_ledger_detail_item.php';
+require_once 'class_print_ledger_detail.php';
+require_once 'class_print_ledger_fin.php';
+require_once 'class_print_ledger_misc.php';
+require_once 'class_print_ledger.php';
+require_once 'class_print_ledger_simple.php';
+require_once 'class_print_ledger_simple_without_vat.php';
+require_once 'class_profile_menu.php';
+require_once 'class_profile_menu_sql.php';
+require_once 'class_profile_sql.php';
+require_once 'class_sendmail.php';
+require_once 'class_sort_table.php';
+require_once 'class_stock_goods.php';
+require_once 'class_stock_goods_sql.php';
+require_once 'class_stock.php';
+require_once 'class_stock_sql.php';
+require_once 'class_supplier.php';
+require_once 'class_tag.php';
+require_once 'class_tag_sql.php';
+require_once 'class_todo_list.php';
+require_once 'class_tool_uos.php';
+require_once 'class_user.php';
+require_once 'class_zip_extended.php';
+
+
diff --git a/unit-test/include/class_acc_accountTest.php
b/unit-test/include/class_acc_accountTest.php
new file mode 100644
index 0000000..0f231c5
--- /dev/null
+++ b/unit-test/include/class_acc_accountTest.php
@@ -0,0 +1,144 @@
+<?php
+/**
+ * Generated by PHPUnit_SkeletonGenerator on 2014-10-31 at 20:32:58.
+ * @backupGlobals enabled
+ */
+class Acc_AccountTest extends PHPUnit_Framework_TestCase
+{
+
+ /**
+ * @var Acc_Account
+ */
+ protected $object;
+
+ /**
+ * Sets up the fixture, for example, opens a network connection.
+ * This method is called before a test is executed.
+ * @backupGlobals enabled
+ */
+ protected function setUp()
+ {
+ global $g_connection;
+ $_REQUEST['gDossier'] = 36;
+ $g_connection=new Database(36);
+ $this->object=new Acc_Account($g_connection,400);
+ $this->object->load();
+ }
+
+ /**
+ * Tears down the fixture, for example, closes a network connection.
+ * This method is called after a test is executed.
+ */
+ protected function tearDown()
+ {
+
+ }
+
+ /**
+ * @covers Acc_Account::get_parameter
+ * @todo Implement testGet_parameter().
+ * @backupGlobals enabled
+ */
+ public function testGet_parameter()
+ {
+ $value=$this->object->get_parameter("value");
+ $this->assertEquals($value,'400');
+
+ }
+
+ /**
+ * @covers Acc_Account::set_parameter
+ * @todo Implement testSet_parameter().
+ * @backupGlobals enabled
+ */
+ public function testSet_parameter()
+ {
+ $this->object->set_parameter("value",500);
+ $value=$this->object->get_parameter("value");
+ $this->assertEquals($value,500);
+ }
+
+ /**
+ * @covers Acc_Account::get_lib
+ * @todo Implement testGet_lib().
+ */
+ public function testGet_lib()
+ {
+ $value=$this->object->get_lib();
+ $this->assertEquals($value,'Clients');
+ }
+
+ /**
+ * @covers Acc_Account::check
+ * @todo Implement testCheck().
+ */
+ public function testCheck()
+ {
+ $value=$this->object->check('pcm_val');
+ $this->assertTrue($value);
+ $value=$this->object->check('pcm_lib');
+ $this->assertTrue($value);
+ $value=$this->object->check('pcm_val_parent');
+ $this->assertTrue($value);
+ $value=$this->object->check('pcm_type','CHA');
+ $this->assertTrue($value);
+ $this->setExpectedException("Exception");
+ $value=$this->object->check('unknown');
+
+ }
+
+ /**
+ * @covers Acc_Account::load
+ * @todo Implement testLoad().
+ */
+ public function testLoad()
+ {
+ $this->object->load();
+ }
+
+ /**
+ * @covers Acc_Account::form
+ * @todo Implement testForm().
+ */
+ public function testForm()
+ {
+ $_REQUEST['gDossier']=36;
+ $this->object->form();
+ }
+
+ /**
+ * @covers Acc_Account::count
+ * @todo Implement testCount().
+ */
+ public function testCount()
+ {
+
+ $this->assertEquals($this->object->count('550'),1);
+ $this->assertEquals($this->object->count('500'),0);
+ }
+
+ /**
+ * @covers Acc_Account::test_me
+ * @todo Implement testTest_me().
+ */
+ public function testTest_me()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ /**
+ * @covers Acc_Account::update
+ * @todo Implement testUpdate().
+ */
+ public function testUpdate()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+}
diff --git a/unit-test/include/class_acc_account_ledgerTest.php
b/unit-test/include/class_acc_account_ledgerTest.php
new file mode 100644
index 0000000..e49e39e
--- /dev/null
+++ b/unit-test/include/class_acc_account_ledgerTest.php
@@ -0,0 +1,299 @@
+<?php
+/**
+ * Generated by PHPUnit_SkeletonGenerator on 2014-10-31 at 20:33:22.
+ * @backupGlobals enabled
+ */
+class Acc_Account_LedgerTest extends PHPUnit_Framework_TestCase
+{
+
+ /**
+ * @var Acc_Account_Ledger
+ */
+ protected $object;
+
+ /**
+ * Sets up the fixture, for example, opens a network connection.
+ * This method is called before a test is executed.
+ *
+ */
+ protected function setUp()
+ {
+ global $g_connection, $g_parameter;
+ $_REQUEST['gDossier']=DOSSIER;
+ $g_connection=new Database(DOSSIER);
+ $g_parameter=new Own($g_connection);
+ $this->object=new Acc_Account_Ledger($g_connection, 400);
+ }
+
+ /**
+ * Tears down the fixture, for example, closes a network connection.
+ * This method is called after a test is executed.
+ */
+ protected function tearDown()
+ {
+
+ }
+
+ /**
+ * @covers Acc_Account_Ledger::get_row
+ * @todo Implement testGet_row().
+ */
+ public function testGet_row()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ /**
+ * @covers Acc_Account_Ledger::get_row_date
+ * @todo Implement testGet_row_date().
+ */
+ public function testGet_row_date()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+ function dataGet_Name()
+ {
+ return array(
+ array('10','Capital '),
+ array('01','Poste inconnu')
+ );
+ }
+ /**
+ * @covers Acc_Account_Ledger::get_name
+ * @todo Implement testGet_name().
+ * @dataProvider dataGet_Name
+ */
+ public function testGet_name($id,$result)
+ {
+ $this->object->id=$id;
+ $this->assertEquals($this->object->get_name(),$result);
+ }
+
+ /**
+ * @covers Acc_Account_Ledger::do_exist
+ * @todo Implement testDo_exist().
+ * @dataProvider dataDo_exist
+ */
+ public function testDo_exist($p_value, $result)
+ {
+ $this->object->id=$p_value;
+ $this->assertEquals($this->object->do_exist(), $result);
+ }
+
+ function dataDo_exist()
+ {
+ return array(
+ array('400', 1),
+ array('400A', 0),
+ array('550', 1),
+ array('60BXX', 0)
+ );
+ }
+
+ /**
+ * @covers Acc_Account_Ledger::load
+ * @todo Implement testLoad().
+ */
+ public function testLoad()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ /**
+ * @covers Acc_Account_Ledger::get
+ * @todo Implement testGet().
+ */
+ public function testGet()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ /**
+ * @covers Acc_Account_Ledger::get_solde
+ * @todo Implement testGet_solde().
+ */
+ public function testGet_solde()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ /**
+ * @covers Acc_Account_Ledger::get_solde_detail
+ * @todo Implement testGet_solde_detail().
+ */
+ public function testGet_solde_detail()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ /**
+ * @covers Acc_Account_Ledger::isTVA
+ * @todo Implement testIsTVA().
+ */
+ public function testIsTVA()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ /**
+ * @covers Acc_Account_Ledger::HtmlTable
+ * @todo Implement testHtmlTable().
+ */
+ public function testHtmlTable()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+ public function dataGet_amount_side()
+ {
+ return array (
+ array(0,"="),
+ array(1000,D),
+ array(-1000,C),
+ );
+ }
+ /**
+ * @covers Acc_Account_Ledger::get_amount_side
+ * @todo Implement testGet_amount_side().
+ * @dataProvider dataGet_amount_side
+ */
+ public function testGet_amount_side($amount,$result)
+ {
+ $this->assertEquals($this->object->get_amount_side($amount),$result);
+ }
+
+ /**
+ * @covers Acc_Account_Ledger::HtmlTableHeader
+ * @todo Implement testHtmlTableHeader().
+ */
+ public function testHtmlTableHeader()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+ /**
+ * @covers Acc_Account_Ledger::belong_ledger
+ * @todo Implement testBelong_ledger().
+ * @dataProvider DataBelong_ledger
+ */
+ public function testBelong_ledger($p_jrn, $result)
+ {
+ $this->assertEquals($this->object->belong_ledger($p_jrn), $result);
+ }
+
+ function DataBelong_ledger()
+ {
+ return array(
+ array(0, -1),
+ array(1, -1),
+ array(3, -1),
+ array(2, 0),
+ array(4, 0)
+ );
+ }
+ public function dataGet_account_ledger()
+ {
+ return array(
+ array(0,array()),
+ array(1,array('5*','')),
+ array(2,array('4*')),
+ array(3,array('6*'))
+
+ );
+ }
+ /**
+ * @covers Acc_Account_Ledger::get_account_ledger
+ * @todo Implement testGet_account_ledger().
+ * @dataProvider dataGet_account_ledger
+ */
+ public function testGet_account_ledger($p_jrn,$result)
+ {
+ echo "ledger $p_jrn";
+ $this->assertEquals($this->object->get_account_ledger($p_jrn),$result);
+ printf ("\n");
+ }
+
+ /**
+ * @covers Acc_Account_Ledger::build_sql_account
+ * @todo Implement testBuild_sql_account().
+ * @dataProvider DataBuild_Sql_account
+ */
+ public function testBuild_sql_account($p_jrn, $result)
+ {
+ print "\n--------------------\n";
+ $value=$this->object->build_sql_account($p_jrn);
+ printf(" ledger %s [%s]", $p_jrn, $value);
+ $this->assertEquals(trim($value), $result);
+ }
+
+ public function DataBuild_Sql_account()
+ {
+ return array(
+ array(0, ""),
+ array(1, "pcm_val::text like '5%'"),
+ array(2, "pcm_val::text like '4%'"),
+ array(3, "pcm_val::text like '6%'"),
+ array(4, "")
+ );
+ }
+
+ function dataFind_Card()
+ {
+ return array(
+ array('6191', '22'),
+ array('6192', '23'),
+ array('4400004', '25')
+ );
+ }
+
+ /**
+ * @covers Acc_Account_Ledger::find_card
+ * @todo Implement testFind_card().
+ * @dataProvider dataFind_Card()
+ */
+ public function testFind_card($p_value, $p_card)
+ {
+ $this->object->id=$p_value;
+ $result=$this->object->find_card();
+ $this->assertEquals($p_card, $result[0]['f_id']);
+ }
+
+ /**
+ * @covers Acc_Account_Ledger::test_me
+ * @todo Implement testTest_me().
+ */
+ public function testTest_me()
+ {
+ // Remove the following lines when you implement this test.
+ $this->markTestIncomplete(
+ 'This test has not been implemented yet.'
+ );
+ }
+
+}
- [Noalyss-commit] [noalyss] 19/27: Last version of prototype + patch, (continued)
- [Noalyss-commit] [noalyss] 19/27: Last version of prototype + patch, Dany De Bontridder, 2014/11/02
- [Noalyss-commit] [noalyss] 23/27: Documentation, Dany De Bontridder, 2014/11/02
- [Noalyss-commit] [noalyss] 18/27: Documentation, Dany De Bontridder, 2014/11/02
- [Noalyss-commit] [noalyss] 22/27: Documentation, Dany De Bontridder, 2014/11/02
- [Noalyss-commit] [noalyss] 24/27: Code rewriting, Dany De Bontridder, 2014/11/02
- [Noalyss-commit] [noalyss] 16/27: Search by accounting Task #1038 - Recherche de fiche par poste comptable, Dany De Bontridder, 2014/11/02
- [Noalyss-commit] [noalyss] 25/27: Code rewriting : accept table with a text PK, Dany De Bontridder, 2014/11/02
- [Noalyss-commit] [noalyss] 26/27: Code rewriting : change due to change of menu_ref_sql, Dany De Bontridder, 2014/11/02
- [Noalyss-commit] [noalyss] 15/27: Button_image for search card, Dany De Bontridder, 2014/11/02
- [Noalyss-commit] [noalyss] 21/27: New functionnal test, Dany De Bontridder, 2014/11/02
- [Noalyss-commit] [noalyss] 27/27: Test unitaire avec PHPUNIT,
Dany De Bontridder <=
- [Noalyss-commit] [noalyss] 20/27: Translation progress, Dany De Bontridder, 2014/11/02
- [Noalyss-commit] [noalyss] 05/27: Mise a jour traduction, Dany De Bontridder, 2014/11/02