Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/zabbix/zabbix.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/ui
diff options
context:
space:
mode:
authorAlexander Vladishev <aleksander.vladishev@zabbix.com>2021-12-30 22:58:02 +0300
committerAlexander Vladishev <aleksander.vladishev@zabbix.com>2021-12-30 22:58:02 +0300
commitfd8b34c8b58198931d8fabd4b591f1dfdefe1375 (patch)
treea7b460126f5db5e48d52001e2f8eb5f831a7322b /ui
parentd66b0426a8f951a05de3b0b7b1df082677d16b60 (diff)
.......... [ZBXNEXT-7081] added support of phpunit 8 for API tests
Diffstat (limited to 'ui')
-rw-r--r--ui/tests/api_json/ApiJsonTests.php4
-rw-r--r--ui/tests/api_json/testConfiguration.php2
-rw-r--r--ui/tests/api_json/testWebScenario.php8
-rw-r--r--ui/tests/frontend.php4
-rw-r--r--ui/tests/general/GeneralTests.php4
-rw-r--r--ui/tests/general/class_CDescription.php4
-rw-r--r--ui/tests/general/zbx_dbcast_2bigintTest.php4
-rw-r--r--ui/tests/include/CAPITest.php8
-rw-r--r--ui/tests/include/CIntegrationTest.php4
-rw-r--r--ui/tests/include/CLegacyWebTest.php4
-rw-r--r--ui/tests/include/CTest.php10
-rw-r--r--ui/tests/include/web/CElement.php2
-rw-r--r--ui/tests/include/web/CElementCollection.php2
-rw-r--r--ui/tests/include/web/elements/CFormElement.php2
-rw-r--r--ui/tests/include/web/elements/CSegmentedRadioElement.php2
-rw-r--r--ui/tests/integration/IntegrationTests.php4
-rw-r--r--ui/tests/selenium/SeleniumTests.php4
17 files changed, 44 insertions, 28 deletions
diff --git a/ui/tests/api_json/ApiJsonTests.php b/ui/tests/api_json/ApiJsonTests.php
index 87980295c1d..7f79033438b 100644
--- a/ui/tests/api_json/ApiJsonTests.php
+++ b/ui/tests/api_json/ApiJsonTests.php
@@ -54,9 +54,11 @@ require_once dirname(__FILE__).'/testMap.php';
require_once dirname(__FILE__).'/testDiscoveryRule.php';
require_once dirname(__FILE__).'/testDependentItems.php';
+use PHPUnit\Framework\TestSuite;
+
class ApiJsonTests {
public static function suite() {
- $suite = new PHPUnit_Framework_TestSuite('API_JSON');
+ $suite = new TestSuite('API_JSON');
$suite->addTestSuite('testJSONRPC');
$suite->addTestSuite('testAPIInfo');
diff --git a/ui/tests/api_json/testConfiguration.php b/ui/tests/api_json/testConfiguration.php
index 4330af869d4..3dec1105b3a 100644
--- a/ui/tests/api_json/testConfiguration.php
+++ b/ui/tests/api_json/testConfiguration.php
@@ -673,7 +673,7 @@ class testConfiguration extends CAPITest {
// Condition for different error message text.
if (array_key_exists('error_contains', $data)) {
- $this->assertContains($data['error_contains'], $result['error']['data']);
+ $this->assertStringContainsString($data['error_contains'], $result['error']['data']);
}
else {
$this->assertSame($data['error'], $result['error']['data']);
diff --git a/ui/tests/api_json/testWebScenario.php b/ui/tests/api_json/testWebScenario.php
index 5266f54830c..f078fd1e4df 100644
--- a/ui/tests/api_json/testWebScenario.php
+++ b/ui/tests/api_json/testWebScenario.php
@@ -1638,7 +1638,7 @@ class testWebScenario extends CAPITest {
'Incorrect item count for web scenario [httpstepid='.$httptestid.'].');
foreach ($db_httptest_items as $db_httptest_item) {
- $this->assertContains('"'.$db_httptest['name'].'"', $db_httptest_item['name']);
+ $this->assertStringContainsString('"'.$db_httptest['name'].'"', $db_httptest_item['name']);
$this->assertRegExp('/\['.preg_quote($db_httptest['name'],'/').'[,\]]/',
$db_httptest_item['key_']);
@@ -1684,11 +1684,11 @@ class testWebScenario extends CAPITest {
foreach ($db_httpstep['db_items'] as $db_httpstep_item) {
if (array_key_exists('name', $httptests[$key]) || array_key_exists('steps', $httptests[$key])) {
- $this->assertContains('"'.$db_httptest['name'].'"', $db_httpstep_item['name']);
- $this->assertContains('"'.$db_httpstep['name'].'"', $db_httpstep_item['name']);
+ $this->assertStringContainsString('"'.$db_httptest['name'].'"', $db_httpstep_item['name']);
+ $this->assertStringContainsString('"'.$db_httpstep['name'].'"', $db_httpstep_item['name']);
}
- $this->assertContains('['.$db_httptest['name'].',', $db_httpstep_item['key_']);
+ $this->assertStringContainsString('['.$db_httptest['name'].',', $db_httpstep_item['key_']);
$this->assertRegExp('/,'.preg_quote($db_httpstep['name'],'/').'[,\]]/',
$db_httpstep_item['key_']);
diff --git a/ui/tests/frontend.php b/ui/tests/frontend.php
index de30f870c07..d25b00b671a 100644
--- a/ui/tests/frontend.php
+++ b/ui/tests/frontend.php
@@ -21,9 +21,11 @@
require_once dirname(__FILE__).'/general/GeneralTests.php';
require_once dirname(__FILE__).'/selenium/SeleniumTests.php';
+use PHPUnit\Framework\TestSuite;
+
class All {
public static function suite() {
- $suite = new PHPUnit_Framework_TestSuite('Project');
+ $suite = new TestSuite('Project');
$suite->addTest(GeneralTests::suite());
$suite->addTest(SeleniumTests::suite());
diff --git a/ui/tests/general/GeneralTests.php b/ui/tests/general/GeneralTests.php
index 7fbfb47bd0d..e60943d6406 100644
--- a/ui/tests/general/GeneralTests.php
+++ b/ui/tests/general/GeneralTests.php
@@ -30,10 +30,12 @@ require_once dirname(__FILE__).'/dbConditionStringTest.php';
require_once dirname(__FILE__).'/testHistoryManager.php';
require_once dirname(__FILE__).'/urlParamTest.php';
+use PHPUnit\Framework\TestSuite;
+
class GeneralTests {
public static function suite() {
- $suite = new PHPUnit_Framework_TestSuite('general');
+ $suite = new TestSuite('general');
$suite->addTestSuite('function_DBconnect');
$suite->addTestSuite('function_DBclose');
diff --git a/ui/tests/general/class_CDescription.php b/ui/tests/general/class_CDescription.php
index 946c082b314..da454f54ba7 100644
--- a/ui/tests/general/class_CDescription.php
+++ b/ui/tests/general/class_CDescription.php
@@ -32,7 +32,9 @@ function error($error) {
return true;
}
-class class_CDescription extends PHPUnit_Framework_TestCase {
+use PHPUnit\Framework\TestCase;
+
+class class_CDescription extends TestCase {
public static function setUpBeforeClass() {
$app = new App();
diff --git a/ui/tests/general/zbx_dbcast_2bigintTest.php b/ui/tests/general/zbx_dbcast_2bigintTest.php
index 694c1b02f80..deb86e1d972 100644
--- a/ui/tests/general/zbx_dbcast_2bigintTest.php
+++ b/ui/tests/general/zbx_dbcast_2bigintTest.php
@@ -24,7 +24,9 @@ require_once dirname(__FILE__).'/../../include/defines.inc.php';
require_once dirname(__FILE__).'/../../include/db.inc.php';
-class zbx_dbcast_2bigintTest extends PHPUnit_Framework_TestCase {
+use PHPUnit\Framework\TestCase;
+
+class zbx_dbcast_2bigintTest extends TestCase {
/**
* Possible test values.
diff --git a/ui/tests/include/CAPITest.php b/ui/tests/include/CAPITest.php
index 4cbe3c3d1d5..d9a1447990f 100644
--- a/ui/tests/include/CAPITest.php
+++ b/ui/tests/include/CAPITest.php
@@ -121,12 +121,12 @@ class CAPITest extends CTest {
/**
* @inheritdoc
*/
- protected function onNotSuccessfulTest($e) {
- if ($e instanceof Exception && CAPIHelper::getDebugInfo()) {
- CExceptionHelper::setMessage($e, $e->getMessage()."\n\nAPI calls:\n".CAPIHelper::getDebugInfoAsString());
+ protected function onNotSuccessfulTest($t): void {
+ if ($t instanceof Exception && CAPIHelper::getDebugInfo()) {
+ CExceptionHelper::setMessage($t, $t->getMessage()."\n\nAPI calls:\n".CAPIHelper::getDebugInfoAsString());
}
- parent::onNotSuccessfulTest($e);
+ parent::onNotSuccessfulTest($t);
}
/**
diff --git a/ui/tests/include/CIntegrationTest.php b/ui/tests/include/CIntegrationTest.php
index b374990a71d..e96fbf9c9db 100644
--- a/ui/tests/include/CIntegrationTest.php
+++ b/ui/tests/include/CIntegrationTest.php
@@ -262,7 +262,7 @@ class CIntegrationTest extends CAPITest {
self::stopComponent($component);
}
catch (Exception $e) {
- self::addWarning($e->getMessage());
+ self::zbxAddWarning($e->getMessage());
}
}
@@ -293,7 +293,7 @@ class CIntegrationTest extends CAPITest {
self::stopComponent($component);
}
catch (Exception $e) {
- self::addWarning($e->getMessage());
+ self::zbxAddWarning($e->getMessage());
}
}
diff --git a/ui/tests/include/CLegacyWebTest.php b/ui/tests/include/CLegacyWebTest.php
index fb274fba3c2..e479526f9d8 100644
--- a/ui/tests/include/CLegacyWebTest.php
+++ b/ui/tests/include/CLegacyWebTest.php
@@ -442,7 +442,7 @@ class CLegacyWebTest extends CWebTest {
$caller = $trace[2];
if ($caller['class'] !== __CLASS__) {
- self::addWarning('Web driver selector should not be used in test cases.');
+ self::zbxAddWarning('Web driver selector should not be used in test cases.');
}
return $this->query($type, $locator);
@@ -694,7 +694,7 @@ class CLegacyWebTest extends CWebTest {
public function __get($attribute) {
if ($attribute === 'webDriver') {
- self::addWarning('Web driver should not be accessed directly from test cases.');
+ self::zbxAddWarning('Web driver should not be accessed directly from test cases.');
return CElementQuery::getDriver();
}
diff --git a/ui/tests/include/CTest.php b/ui/tests/include/CTest.php
index a96ad3e60b1..02c04a33883 100644
--- a/ui/tests/include/CTest.php
+++ b/ui/tests/include/CTest.php
@@ -38,7 +38,9 @@ define('USER_ACTION_REMOVE', 'remove');
/**
* Base class of php unit tests.
*/
-class CTest extends PHPUnit_Framework_TestCase {
+use PHPUnit\Framework\TestCase;
+
+class CTest extends TestCase {
// Table that should be backed up at the test suite level.
protected static $suite_backup = null;
@@ -174,7 +176,7 @@ class CTest extends PHPUnit_Framework_TestCase {
if (!$method) {
$error = 'Callback "'.$callback.'" is not defined in requested context.';
if (!$required) {
- self::addWarning($error);
+ self::zbxAddWarning($error);
}
else {
throw new Exception($error);
@@ -186,7 +188,7 @@ class CTest extends PHPUnit_Framework_TestCase {
} catch (Exception $e) {
$error = 'Failed to execute callback "'.$callback.'": '.$e->getMessage();
if (!$required) {
- self::addWarning($error);
+ self::zbxAddWarning($error);
}
else {
throw new Exception($error);
@@ -443,7 +445,7 @@ class CTest extends PHPUnit_Framework_TestCase {
*
* @param string $warning warning text
*/
- public static function addWarning($warning) {
+ public static function zbxAddWarning($warning) {
if (!in_array($warning, self::$warnings)) {
self::$warnings[] = $warning;
}
diff --git a/ui/tests/include/web/CElement.php b/ui/tests/include/web/CElement.php
index eb96361db58..1b174b93e17 100644
--- a/ui/tests/include/web/CElement.php
+++ b/ui/tests/include/web/CElement.php
@@ -655,7 +655,7 @@ class CElement extends CBaseElement implements IWaitable {
return $this->asInputGroup($options);
}
- CTest::addWarning('No specific element was detected');
+ CTest::zbxAddWarning('No specific element was detected');
return $this;
}
diff --git a/ui/tests/include/web/CElementCollection.php b/ui/tests/include/web/CElementCollection.php
index d0ed2aa47dc..a5803aa8b4c 100644
--- a/ui/tests/include/web/CElementCollection.php
+++ b/ui/tests/include/web/CElementCollection.php
@@ -380,7 +380,7 @@ class CElementCollection implements Iterator {
}
if (array_key_exists($key, $elements)) {
- CTest::addWarning('Element attribute "'.$name.'" values are not unique in element collection.');
+ CTest::zbxAddWarning('Element attribute "'.$name.'" values are not unique in element collection.');
}
$elements[$key] = $element;
diff --git a/ui/tests/include/web/elements/CFormElement.php b/ui/tests/include/web/elements/CFormElement.php
index 7b8dad68199..6d54bef85f0 100644
--- a/ui/tests/include/web/elements/CFormElement.php
+++ b/ui/tests/include/web/elements/CFormElement.php
@@ -141,7 +141,7 @@ class CFormElement extends CElement {
}
if ($labels->count() > 1) {
- CTest::addWarning('Form label "'.$name.'" is not unique.');
+ CTest::zbxAddWarning('Form label "'.$name.'" is not unique.');
}
}
diff --git a/ui/tests/include/web/elements/CSegmentedRadioElement.php b/ui/tests/include/web/elements/CSegmentedRadioElement.php
index 1f219a51236..31bf8fba977 100644
--- a/ui/tests/include/web/elements/CSegmentedRadioElement.php
+++ b/ui/tests/include/web/elements/CSegmentedRadioElement.php
@@ -55,7 +55,7 @@ class CSegmentedRadioElement extends CElement {
}
if ($radio->count() > 1) {
- CTest::addWarning('Selected element is not one.');
+ CTest::zbxAddWarning('Selected element is not one.');
}
}
diff --git a/ui/tests/integration/IntegrationTests.php b/ui/tests/integration/IntegrationTests.php
index d2b266f6f30..3f80df4c163 100644
--- a/ui/tests/integration/IntegrationTests.php
+++ b/ui/tests/integration/IntegrationTests.php
@@ -27,9 +27,11 @@ require_once dirname(__FILE__).'/testValuemaps.php';
require_once dirname(__FILE__).'/testEscalations.php';
require_once dirname(__FILE__).'/testTriggerState.php';
+use PHPUnit\Framework\TestSuite;
+
class IntegrationTests {
public static function suite() {
- $suite = new PHPUnit_Framework_TestSuite('Integration');
+ $suite = new TestSuite('Integration');
$suite->addTestSuite('testDataCollection');
$suite->addTestSuite('testDiagnosticDataTask');
$suite->addTestSuite('testLowLevelDiscovery');
diff --git a/ui/tests/selenium/SeleniumTests.php b/ui/tests/selenium/SeleniumTests.php
index 35c98e5ad6b..f10cfa9f026 100644
--- a/ui/tests/selenium/SeleniumTests.php
+++ b/ui/tests/selenium/SeleniumTests.php
@@ -187,9 +187,11 @@ require_once dirname(__FILE__).'/scheduledReports/testPageScheduledReport.php';
require_once dirname(__FILE__).'/scheduledReports/testScheduledReportPermissions.php';
require_once dirname(__FILE__).'/testSID.php';
+use PHPUnit\Framework\TestSuite;
+
class SeleniumTests {
public static function suite() {
- $suite = new PHPUnit_Framework_TestSuite('selenium');
+ $suite = new TestSuite('selenium');
$suite->addTestSuite('testGeneric');
$suite->addTestSuite('testGraphAxis');