Test updates with skip for DB, URL check skip and lookup fix

curl fix for printing out response, we just want true/false if connect worked
skip curl tests where we need a base url
skip any DB tests if there is no DB
update the caller method list test
This commit is contained in:
2026-06-25 17:24:45 +09:00
parent e3306a096f
commit 3f02bee643
4 changed files with 85 additions and 30 deletions
+1 -1
View File
@@ -98,7 +98,7 @@ final class CoreLibsACLLoginTest extends TestCase
);
} catch (\Exception $e) {
self::markTestSkipped(
'Cannot connect to valid Test DB for ACL\Login test: ' . $e->getMessage()
'Cannot connect to Test DB for ACL\Login test: ' . $e->getMessage()
);
}
// ALWAYS drop DB and RECREATE DB
+6
View File
@@ -123,10 +123,16 @@ final class CoreLibsDBIOTest extends TestCase
'log_file_id' => 'CoreLibs-DB-IO-Test',
]);
// will be true, default logging is true
try {
$db = new \CoreLibs\DB\IO(
self::$db_config['valid'],
self::$log
);
} catch (\Exception $e) {
self::markTestSkipped(
'Cannot connect to Test DB for DB\IO test: ' . $e->getMessage()
);
}
if (!$db->dbGetConnectionStatus()) {
self::markTestSkipped(
'Cannot connect to valid Test DB for DB\IO test.'
@@ -551,6 +551,16 @@ final class CoreLibsDebugSupportTest extends TestCase
);
break;
case 12:
// if compare starts with "main"
if ($compare[0] == 'main') {
// add two more run after main
array_splice(
$expected,
1,
0,
['run', 'run']
);
} else {
// add two "run" before "runBare"
array_splice(
$expected,
@@ -564,6 +574,7 @@ final class CoreLibsDebugSupportTest extends TestCase
0,
['include']
);
}
$this->assertEquals(
$expected,
$compare,
@@ -58,6 +58,7 @@ final class CoreLibsUrlRequestsCurlTest extends TestCase
if ($handle === false) {
continue;
}
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
$status = curl_exec($handle);
if ($status === false) {
continue;
@@ -471,7 +472,7 @@ final class CoreLibsUrlRequestsCurlTest extends TestCase
* @testdox UrlRequests\Curl Class setup tasks [$_dataName]
*
* @param null|array $config
* @param array $expected
* @param array<string,mixed> $expected_set
* @param null|string $new_base_uri
* @param null|array $set_header
* @param null|bool $set_header_add
@@ -496,10 +497,18 @@ final class CoreLibsUrlRequestsCurlTest extends TestCase
};
// if ($new_base_uri === null && $set_header === null && $remove_header === null) {
// }
$this->assertEquals($expected_set, $curl->getConfig(), 'Class setup config mismatch');
$this->assertEquals(
$expected_set,
$curl->getConfig(),
'Class setup config mismatch'
);
if ($new_base_uri !== null) {
$curl->setBaseUri($new_base_uri);
$this->assertEquals($expected_change, $curl->getConfig(), 'new base_uri not matching');
$this->assertEquals(
$expected_change,
$curl->getConfig(),
'new base_uri not matching'
);
}
if ($set_header !== null) {
if ($set_header_add !== null) {
@@ -507,11 +516,19 @@ final class CoreLibsUrlRequestsCurlTest extends TestCase
} else {
$curl->setHeaders($set_header);
}
$this->assertEquals($expected_change, $curl->getConfig(), 'new headers not matching');
$this->assertEquals(
$expected_change,
$curl->getConfig(),
'new headers not matching'
);
}
if ($remove_header !== null) {
$curl->removeHeaders($remove_header);
$this->assertEquals($expected_change, $curl->getConfig(), 'removed headers not matching');
$this->assertEquals(
$expected_change,
$curl->getConfig(),
'removed headers not matching'
);
}
}
@@ -881,7 +898,7 @@ final class CoreLibsUrlRequestsCurlTest extends TestCase
string $return_content
) {
if (!$this->url_basic) {
$this->markTestSkipped('No backend interface setup for testing: GET');
$this->markTestSkipped('No backend interface setup for testing');
}
$curl = new \CoreLibs\UrlRequests\Curl();
// options
@@ -964,6 +981,9 @@ final class CoreLibsUrlRequestsCurlTest extends TestCase
*/
public function testUrlRequestsCurlRequestMultiple()
{
if (!$this->url_basic) {
$this->markTestSkipped('No backend interface setup for testing');
}
$curl = new \CoreLibs\UrlRequests\Curl();
// get
$response = $curl->get($this->url_basic, [
@@ -1055,6 +1075,9 @@ final class CoreLibsUrlRequestsCurlTest extends TestCase
*/
public function testUrlRequestsCurlAuthHeader()
{
if (!$this->url_basic) {
$this->markTestSkipped('No backend interface setup for testing');
}
$curl = new \CoreLibs\UrlRequests\Curl([
"auth" => ["user", "pass", "basic"],
"http_errors" => false,
@@ -1121,6 +1144,9 @@ final class CoreLibsUrlRequestsCurlTest extends TestCase
*/
public function testExceptionInvalidHeaderKey(): void
{
if (!$this->url_basic) {
$this->markTestSkipped('No backend interface setup for testing');
}
$curl = new \CoreLibs\UrlRequests\Curl();
$this->expectException(\RuntimeException::class);
$this->expectExceptionMessageMatches("/InvalidHeaderKey/");
@@ -1141,6 +1167,9 @@ final class CoreLibsUrlRequestsCurlTest extends TestCase
*/
public function testExceptionInvalidHeaderValue(): void
{
if (!$this->url_basic) {
$this->markTestSkipped('No backend interface setup for testing');
}
$curl = new \CoreLibs\UrlRequests\Curl();
$this->expectException(\RuntimeException::class);
$this->expectExceptionMessageMatches("/InvalidHeaderValue/");
@@ -1190,6 +1219,9 @@ final class CoreLibsUrlRequestsCurlTest extends TestCase
*/
public function testExceptionBadRequest(): void
{
if (!$this->url_basic) {
$this->markTestSkipped('No backend interface setup for testing');
}
$curl = new \CoreLibs\UrlRequests\Curl(["http_errors" => true]);
$this->expectException(\RuntimeException::class);
$this->expectExceptionMessageMatches("/ClientError/");
@@ -1211,6 +1243,9 @@ final class CoreLibsUrlRequestsCurlTest extends TestCase
*/
public function testExceptionBadRequestEnable(): void
{
if (!$this->url_basic) {
$this->markTestSkipped('No backend interface setup for testing');
}
$curl = new \CoreLibs\UrlRequests\Curl(["http_errors" => false]);
$this->expectException(\RuntimeException::class);
$this->expectExceptionMessageMatches("/ClientError/");
@@ -1233,6 +1268,9 @@ final class CoreLibsUrlRequestsCurlTest extends TestCase
*/
public function testExceptionBadRequestUnset(): void
{
if (!$this->url_basic) {
$this->markTestSkipped('No backend interface setup for testing');
}
// if true, with false it has to be off
$curl = new \CoreLibs\UrlRequests\Curl(["http_errors" => true]);
$response = $curl->request('get', $this->url_basic, [