From 557fe235d1deba57dc65c71f768c7fadc6ece156 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Sun, 10 Sep 2023 19:41:14 +0200 Subject: [PATCH] Fix warnings --- htdocs/core/class/commonobject.class.php | 2 +- test/phpunit/LangTest.php | 4 ++-- test/phpunit/SocieteTest.php | 8 ++++---- test/phpunit/functional/InstallTest.php | 18 +++++++++--------- .../functional/TakePosFunctionalTest.php | 12 ++++++------ 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/htdocs/core/class/commonobject.class.php b/htdocs/core/class/commonobject.class.php index f2a1bb49926..a6ecbb7f7d4 100644 --- a/htdocs/core/class/commonobject.class.php +++ b/htdocs/core/class/commonobject.class.php @@ -6156,7 +6156,7 @@ abstract class CommonObject //var_dump('key '.$key.' '.$value.' type='.$extrafields->attributes[$this->table_element]['type'][$key].' '.$this->array_options["options_".$key]); } - if ($extrafields->attributes[$this->table_element]['type'][$key] == 'password') { + if (!empty($extrafields->attributes[$this->table_element]['type'][$key]) && $extrafields->attributes[$this->table_element]['type'][$key] == 'password') { if (preg_match('/^dolcrypt:/', $value)) { $this->array_options["options_".$key] = dolDecrypt($value); } diff --git a/test/phpunit/LangTest.php b/test/phpunit/LangTest.php index 6ef14f7a227..c99368a78fe 100644 --- a/test/phpunit/LangTest.php +++ b/test/phpunit/LangTest.php @@ -196,11 +196,11 @@ class LangTest extends PHPUnit\Framework\TestCase $result=$tmplangs->transnoentitiesnoconv("SeparatorDecimal"); print __METHOD__." SeparatorDecimal=".$result."\n"; - $this->assertContains($result, array('.',',','/',' ','','None'), 'Error on decimal separator for lang code '.$code); // Note that ، that is coma for RTL languages is not supported + $this->assertTrue(in_array($result, array('.',',','/',' ','','None')), 'Error on decimal separator for lang code '.$code); // Note that ، that is coma for RTL languages is not supported $result=$tmplangs->transnoentitiesnoconv("SeparatorThousand"); print __METHOD__." SeparatorThousand=".$result."\n"; - $this->assertContains($result, array('.',',','/',' ','','\'','None','Space'), 'Error on thousand separator for lang code '.$code); // Note that ، that is coma for RTL languages is not supported + $this->assertTrue(in_array($result, array('.',',','/',' ','','\'','None','Space')), 'Error on thousand separator for lang code '.$code); // Note that ، that is coma for RTL languages is not supported // Test java string contains only d,M,y,/,-,. and not m,... $result=$tmplangs->transnoentitiesnoconv("FormatDateShortJava"); diff --git a/test/phpunit/SocieteTest.php b/test/phpunit/SocieteTest.php index 96d2071ce7d..ce086f179cc 100644 --- a/test/phpunit/SocieteTest.php +++ b/test/phpunit/SocieteTest.php @@ -462,7 +462,7 @@ class SocieteTest extends PHPUnit\Framework\TestCase $localobjectadd->town='New town'; $result=$localobjectadd->getFullAddress(1); print __METHOD__." id=".$localobjectadd->id." result=".$result."\n"; - $this->assertContains("New address\nNew zip New town\nFrance", $result); + $this->assertStringContainsString("New address\nNew zip New town\nFrance", $result); // Belgium unset($localobjectadd->country_code); @@ -473,7 +473,7 @@ class SocieteTest extends PHPUnit\Framework\TestCase $localobjectadd->town='New town'; $result=$localobjectadd->getFullAddress(1); print __METHOD__." id=".$localobjectadd->id." result=".$result."\n"; - $this->assertContains("New address\nNew zip New town\nBelgium", $result); + $this->assertStringContainsString("New address\nNew zip New town\nBelgium", $result); // Switzerland unset($localobjectadd->country_code); @@ -484,7 +484,7 @@ class SocieteTest extends PHPUnit\Framework\TestCase $localobjectadd->town='New town'; $result=$localobjectadd->getFullAddress(1); print __METHOD__." id=".$localobjectadd->id." result=".$result."\n"; - $this->assertContains("New address\nNew zip New town\nSwitzerland", $result); + $this->assertStringContainsString("New address\nNew zip New town\nSwitzerland", $result); // USA unset($localobjectadd->country_code); @@ -496,7 +496,7 @@ class SocieteTest extends PHPUnit\Framework\TestCase $localobjectadd->state='New state'; $result=$localobjectadd->getFullAddress(1); print __METHOD__." id=".$localobjectadd->id." result=".$result."\n"; - $this->assertContains("New address\nNew town, New state, New zip\nUnited States", $result); + $this->assertStringContainsString("New address\nNew town, New state, New zip\nUnited States", $result); return $localobjectadd->id; } diff --git a/test/phpunit/functional/InstallTest.php b/test/phpunit/functional/InstallTest.php index f1ecdc60914..315749aa76d 100644 --- a/test/phpunit/functional/InstallTest.php +++ b/test/phpunit/functional/InstallTest.php @@ -104,7 +104,7 @@ class InstallTest extends PHPUnit_Extensions_Selenium2TestCase public function testInstallRedirect() { $this->url('/'); - $this->assertContains('/install/index.php', $this->url()); + $this->assertStringContainsString('/install/index.php', $this->url()); } /** @@ -114,7 +114,7 @@ class InstallTest extends PHPUnit_Extensions_Selenium2TestCase */ public function testInstallPageTitle() { - $this->assertContains('Dolibarr', $this->title()); + $this->assertStringContainsString('Dolibarr', $this->title()); } /** @@ -126,7 +126,7 @@ class InstallTest extends PHPUnit_Extensions_Selenium2TestCase { // FIXME: the button itself should have an ID $this->byId('nextbutton')->byTag('input')->click(); - $this->assertContains('/install/check.php', $this->url()); + $this->assertStringContainsString('/install/check.php', $this->url()); } /** @@ -145,7 +145,7 @@ class InstallTest extends PHPUnit_Extensions_Selenium2TestCase $show_hide_choices->click(); $this->assertFalse($unavailable_choices->displayed()); $this->byClassName('button')->click(); - $this->assertContains('/install/fileconf.php', $this->url()); + $this->assertStringContainsString('/install/fileconf.php', $this->url()); } /** @@ -205,7 +205,7 @@ class InstallTest extends PHPUnit_Extensions_Selenium2TestCase public function testFormSubmit() { $this->byName('forminstall')->submit(); - $this->assertContains('/install/step1.php', $this->url()); + $this->assertStringContainsString('/install/step1.php', $this->url()); } /** @@ -221,7 +221,7 @@ class InstallTest extends PHPUnit_Extensions_Selenium2TestCase $this->byId('nextbutton')->byTag('input')->click(); $time = $start->diff(new DateTimeImmutable()); echo "\nPopulating the database took " . $time->format("%s seconds.\n"); - $this->assertContains('/install/step2.php', $this->url()); + $this->assertStringContainsString('/install/step2.php', $this->url()); } /** @@ -232,7 +232,7 @@ class InstallTest extends PHPUnit_Extensions_Selenium2TestCase public function testStep2() { $this->byName('forminstall')->submit(); - $this->assertContains('/install/step4.php', $this->url()); + $this->assertStringContainsString('/install/step4.php', $this->url()); } // There is no step 3 @@ -252,7 +252,7 @@ class InstallTest extends PHPUnit_Extensions_Selenium2TestCase $this->byName('pass_verif')->value(self::$dol_admin_pass); // FIXME: the button itself should have an ID $this->byId('nextbutton')->byTag('input')->click(); - $this->assertContains('/install/step5.php', $this->url()); + $this->assertStringContainsString('/install/step5.php', $this->url()); } /** @@ -264,7 +264,7 @@ class InstallTest extends PHPUnit_Extensions_Selenium2TestCase { // FIXME: this button should have an ID $this->byTag('a')->click(); - $this->assertContains('/admin/index.php', $this->url()); + $this->assertStringContainsString('/admin/index.php', $this->url()); } /** diff --git a/test/phpunit/functional/TakePosFunctionalTest.php b/test/phpunit/functional/TakePosFunctionalTest.php index 3cb46a04fdf..3ff050f8403 100644 --- a/test/phpunit/functional/TakePosFunctionalTest.php +++ b/test/phpunit/functional/TakePosFunctionalTest.php @@ -192,7 +192,7 @@ class TakePosFunctionalTest extends \PHPUnit_Extensions_Selenium2TestCase } // Page reloaded, we need a new Xpath $module_status_image = $this->byXPath($module_status_image_path); - $this->assertContains('switch_on.png', $module_status_image->attribute('src'), "Module enabled"); + $this->assertStringContainsString('switch_on.png', $module_status_image->attribute('src'), "Module enabled"); } /** @@ -206,7 +206,7 @@ class TakePosFunctionalTest extends \PHPUnit_Extensions_Selenium2TestCase { $this->url('/custom/takepos/admin/setup.php'); $this->authenticate(); - $this->assertContains('takepos/admin/setup.php', $this->url(), 'Configuration page'); + $this->assertStringContainsString('takepos/admin/setup.php', $this->url(), 'Configuration page'); } /** @@ -220,7 +220,7 @@ class TakePosFunctionalTest extends \PHPUnit_Extensions_Selenium2TestCase { $this->url('/custom/takepos/admin/about.php'); $this->authenticate(); - $this->assertContains('takepos/admin/about.php', $this->url(), 'About page'); + $this->assertStringContainsString('takepos/admin/about.php', $this->url(), 'About page'); } /** @@ -252,7 +252,7 @@ class TakePosFunctionalTest extends \PHPUnit_Extensions_Selenium2TestCase { $this->url('/admin/boxes.php'); $this->authenticate(); - $this->assertContains('takeposwidget1', $this->source(), "Box enabled"); + $this->assertStringContainsString('takeposwidget1', $this->source(), "Box enabled"); } /** @@ -266,7 +266,7 @@ class TakePosFunctionalTest extends \PHPUnit_Extensions_Selenium2TestCase { $this->url('/admin/triggers.php'); $this->authenticate(); - $this->assertContains( + $this->assertStringContainsString( 'interface_99_modTakePos_TakePosTriggers.class.php', $this->byTag('body')->text(), "Trigger declared" @@ -284,7 +284,7 @@ class TakePosFunctionalTest extends \PHPUnit_Extensions_Selenium2TestCase { $this->url('/admin/triggers.php'); $this->authenticate(); - $this->assertContains( + $this->assertStringContainsString( 'tick.png', $this->byXPath('//td[text()="interface_99_modTakePos_MyTrigger.class.php"]/following::img')->attribute('src'), "Trigger enabled"