From b2d635dab793a84c904e47ce3ae0d194366d3644 Mon Sep 17 00:00:00 2001 From: eldy Date: Sat, 1 Oct 2011 01:40:15 +0200 Subject: [PATCH] Qual: More PHPUnit tests --- htdocs/product/class/product.class.php | 25 +++++++++++++++++++++++++ test/phpunit/AllTests.php | 3 +++ test/phpunit/ProductTest.php | 4 ---- 3 files changed, 28 insertions(+), 4 deletions(-) diff --git a/htdocs/product/class/product.class.php b/htdocs/product/class/product.class.php index b4ed55e0e72..fbf38befc79 100644 --- a/htdocs/product/class/product.class.php +++ b/htdocs/product/class/product.class.php @@ -2912,5 +2912,30 @@ class Product extends CommonObject } } + /** + * Initialise an instance with random values. + * Used to build previews or test instances. + * id must be 0 if object instance is a specimen. + * + * @return void + */ + function initAsSpecimen() + { + global $user,$langs,$conf,$mysoc; + + $now=dol_now(); + + // Initialize parameters + $this->id=0; + $this->ref = 'PRODUCT_SPEC'; + $this->libelle = 'PRODUCT SPECIMEN'; + $this->description = 'PRODUCT SPECIMEN '.dol_print_date($now,'dayhourlog'); + $this->specimen=1; + $this->country_id=1; + $this->tosell=1; + $this->tobuy=1; + $this->type=0; + $this->note='This is a comment (private)'; + } } ?> \ No newline at end of file diff --git a/test/phpunit/AllTests.php b/test/phpunit/AllTests.php index cc9921a0480..864315d3c86 100644 --- a/test/phpunit/AllTests.php +++ b/test/phpunit/AllTests.php @@ -75,6 +75,9 @@ class AllTests require_once dirname(__FILE__).'/DiscountTest.php'; $suite->addTestSuite('DiscountTest'); + require_once dirname(__FILE__).'/ProductTest.php'; + $suite->addTestSuite('ProductTest'); + require_once dirname(__FILE__).'/CommandeTest.php'; $suite->addTestSuite('CommandeTest'); require_once dirname(__FILE__).'/CommandeFournisseurTest.php'; diff --git a/test/phpunit/ProductTest.php b/test/phpunit/ProductTest.php index ae83bfa229a..353b19dfc06 100755 --- a/test/phpunit/ProductTest.php +++ b/test/phpunit/ProductTest.php @@ -145,10 +145,6 @@ class ProductTest extends PHPUnit_Framework_TestCase print __METHOD__." id=".$id." result=".$result."\n"; $this->assertLessThan($result, 0); - $result=$localobject->verify(); - print __METHOD__." id=".$id." result=".$result."\n"; - $this->assertEquals($result, 0); - return $localobject; }