diff --git a/test/phpunit/AllTests.php b/test/phpunit/AllTests.php index 5dcabf6cf6e..ba4d743f603 100644 --- a/test/phpunit/AllTests.php +++ b/test/phpunit/AllTests.php @@ -277,7 +277,7 @@ class AllTests // Website require_once dirname(__FILE__).'/WebsiteTest.php'; - $suite->addTestSuite('Website'); + $suite->addTestSuite('WebsiteTest'); return $suite; } diff --git a/test/phpunit/WebsiteTest.class.php b/test/phpunit/WebsiteTest.php similarity index 91% rename from test/phpunit/WebsiteTest.class.php rename to test/phpunit/WebsiteTest.php index 4fcf14f9eb1..4383d844ed8 100644 --- a/test/phpunit/WebsiteTest.class.php +++ b/test/phpunit/WebsiteTest.php @@ -55,6 +55,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/core/lib/website2.lib.php'; +require_once dirname(__FILE__).'/../../htdocs/website/class/website.class.php'; if (empty($user->id)) { @@ -110,7 +111,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. @@ -123,7 +124,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(); @@ -136,7 +137,7 @@ class WebsiteTest extends PHPUnit\Framework\TestCase * * @return void */ - protected function setUp() + protected function setUp(): void { global $conf,$user,$langs,$db; $conf=$this->savconf; @@ -152,7 +153,7 @@ class WebsiteTest extends PHPUnit\Framework\TestCase * * @return void */ - protected function tearDown() + protected function tearDown(): void { print __METHOD__."\n"; } @@ -165,14 +166,16 @@ 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"; /* - var_dump($s); - var_dump($db->escapeforlike($s)); - var_dump($db->escape($db->escapeforlike($s))); - */ + var_dump($s); + var_dump($db->escapeforlike($s)); + var_dump($db->escape($db->escapeforlike($s))); + */ $res = getPagesFromSearchCriterias('page,blogpost', 'meta,content', $s, 2, 'date_creation', 'DESC', 'en'); //var_dump($res);