From fa3e78054d67237f1092805c6d5f35bd7a8ca52d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 28 Mar 2023 12:10:00 +0200 Subject: [PATCH 1/4] Rename WebsiteTest.class.php to WebsiteTest.php --- test/phpunit/{WebsiteTest.class.php => WebsiteTest.php} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename test/phpunit/{WebsiteTest.class.php => WebsiteTest.php} (100%) diff --git a/test/phpunit/WebsiteTest.class.php b/test/phpunit/WebsiteTest.php similarity index 100% rename from test/phpunit/WebsiteTest.class.php rename to test/phpunit/WebsiteTest.php From 2c75dd80269c898b3c4befb490b1a71535a320e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20FRANCE?= Date: Tue, 28 Mar 2023 12:43:45 +0200 Subject: [PATCH 2/4] Update AllTests.php --- test/phpunit/AllTests.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/phpunit/AllTests.php b/test/phpunit/AllTests.php index 2c492da6aee..21c5c0f3658 100644 --- a/test/phpunit/AllTests.php +++ b/test/phpunit/AllTests.php @@ -273,7 +273,7 @@ class AllTests // Website require_once dirname(__FILE__).'/WebsiteTest.php'; - $suite->addTestSuite('Website'); + $suite->addTestSuite('WebsiteTest'); return $suite; } From 782c7ef55cf4e457f234d7dbb6477c8b2e7f8a59 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 28 Mar 2023 19:46:10 +0200 Subject: [PATCH 3/4] Fix php 8 --- test/phpunit/WebsiteTest.php | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/phpunit/WebsiteTest.php b/test/phpunit/WebsiteTest.php index 2f0afbbed96..a20a18dd987 100644 --- a/test/phpunit/WebsiteTest.php +++ b/test/phpunit/WebsiteTest.php @@ -105,7 +105,7 @@ class WebsiteTest extends PHPUnit\Framework\TestCase * * @return void */ - public static function setUpBeforeClass() + public static function setUpBeforeClass(): void { global $conf,$user,$langs,$db; $db->begin(); // This is to have all actions inside a transaction even if test launched without suite. @@ -118,7 +118,7 @@ class WebsiteTest extends PHPUnit\Framework\TestCase * * @return void */ - public static function tearDownAfterClass() + public static function tearDownAfterClass(): void { global $conf,$user,$langs,$db; $db->rollback(); @@ -131,7 +131,7 @@ class WebsiteTest extends PHPUnit\Framework\TestCase * * @return void */ - protected function setUp() + protected function setUp(): void { global $conf,$user,$langs,$db; $conf=$this->savconf; @@ -147,7 +147,7 @@ class WebsiteTest extends PHPUnit\Framework\TestCase * * @return void */ - protected function tearDown() + protected function tearDown(): void { print __METHOD__."\n"; } From 77910aad8cf5fcfe3ae94467425a4e82755c959a Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 28 Mar 2023 20:28:57 +0200 Subject: [PATCH 4/4] Fix phpunit --- test/phpunit/WebsiteTest.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/test/phpunit/WebsiteTest.php b/test/phpunit/WebsiteTest.php index a20a18dd987..d940133f349 100644 --- a/test/phpunit/WebsiteTest.php +++ b/test/phpunit/WebsiteTest.php @@ -54,6 +54,7 @@ if (! defined("NOSESSION")) { require_once dirname(__FILE__).'/../../htdocs/main.inc.php'; require_once dirname(__FILE__).'/../../htdocs/core/lib/website.lib.php'; +require_once dirname(__FILE__).'/../../htdocs/website/class/website.class.php'; if (empty($user->id)) { @@ -160,7 +161,9 @@ class WebsiteTest extends PHPUnit\Framework\TestCase */ public function testGetPagesFromSearchCriterias() { - global $db; + global $db, $website; + + $website = new Website($db); // $website must be defined globally for getPagesFromSearchCriterias() $s = "123') OR 1=1-- \' xxx"; /*