Test updates

This commit is contained in:
2026-06-25 17:26:48 +09:00
parent 55aebb5373
commit e881854583
5 changed files with 91 additions and 32 deletions
@@ -318,7 +318,11 @@ jobs:
fi fi
if [ -f phpunit-openclover.xml ]; then if [ -f phpunit-openclover.xml ]; then
cat code-coverage-summary.md >> $GITHUB_STEP_SUMMARY if [ -f code-coverage-summary.md ]; then
cat code-coverage-details.md >> $GITHUB_STEP_SUMMARY cat code-coverage-summary.md >> $GITHUB_STEP_SUMMARY
fi
if [ -f code-coverage-details.md ]; then
cat code-coverage-details.md >> $GITHUB_STEP_SUMMARY
fi
fi fi
+1 -1
View File
@@ -98,7 +98,7 @@ final class CoreLibsACLLoginTest extends TestCase
); );
} catch (\Exception $e) { } catch (\Exception $e) {
self::markTestSkipped( 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 // ALWAYS drop DB and RECREATE DB
+10 -4
View File
@@ -123,10 +123,16 @@ final class CoreLibsDBIOTest extends TestCase
'log_file_id' => 'CoreLibs-DB-IO-Test', 'log_file_id' => 'CoreLibs-DB-IO-Test',
]); ]);
// will be true, default logging is true // will be true, default logging is true
$db = new \CoreLibs\DB\IO( try {
self::$db_config['valid'], $db = new \CoreLibs\DB\IO(
self::$log 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()) { if (!$db->dbGetConnectionStatus()) {
self::markTestSkipped( self::markTestSkipped(
'Cannot connect to valid Test DB for DB\IO test.' 'Cannot connect to valid Test DB for DB\IO test.'
+24 -13
View File
@@ -551,19 +551,30 @@ final class CoreLibsDebugSupportTest extends TestCase
); );
break; break;
case 12: case 12:
// add two "run" before "runBare" // if compare starts with "main"
array_splice( if ($compare[0] == 'main') {
$expected, // add two more run after main
7, array_splice(
0, $expected,
['run'] 1,
); 0,
array_splice( ['run', 'run']
$expected, );
0, } else {
0, // add two "run" before "runBare"
['include'] array_splice(
); $expected,
7,
0,
['run']
);
array_splice(
$expected,
0,
0,
['include']
);
}
$this->assertEquals( $this->assertEquals(
$expected, $expected,
$compare, $compare,
@@ -58,6 +58,7 @@ final class CoreLibsUrlRequestsCurlTest extends TestCase
if ($handle === false) { if ($handle === false) {
continue; continue;
} }
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
$status = curl_exec($handle); $status = curl_exec($handle);
if ($status === false) { if ($status === false) {
continue; continue;
@@ -470,13 +471,13 @@ final class CoreLibsUrlRequestsCurlTest extends TestCase
* @dataProvider providerUrlRequestsCurlSetup * @dataProvider providerUrlRequestsCurlSetup
* @testdox UrlRequests\Curl Class setup tasks [$_dataName] * @testdox UrlRequests\Curl Class setup tasks [$_dataName]
* *
* @param null|array $config * @param null|array $config
* @param array $expected * @param array<string,mixed> $expected_set
* @param null|string $new_base_uri * @param null|string $new_base_uri
* @param null|array $set_header * @param null|array $set_header
* @param null|bool $set_header_add * @param null|bool $set_header_add
* @param null|array $remove_header * @param null|array $remove_header
* @param null|array $expected_change * @param null|array $expected_change
* @return void * @return void
*/ */
public function testUrlRequestsCurlSetupConfig( public function testUrlRequestsCurlSetupConfig(
@@ -496,10 +497,18 @@ final class CoreLibsUrlRequestsCurlTest extends TestCase
}; };
// if ($new_base_uri === null && $set_header === null && $remove_header === null) { // 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) { if ($new_base_uri !== null) {
$curl->setBaseUri($new_base_uri); $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 !== null) {
if ($set_header_add !== null) { if ($set_header_add !== null) {
@@ -507,11 +516,19 @@ final class CoreLibsUrlRequestsCurlTest extends TestCase
} else { } else {
$curl->setHeaders($set_header); $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) { if ($remove_header !== null) {
$curl->removeHeaders($remove_header); $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 string $return_content
) { ) {
if (!$this->url_basic) { 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(); $curl = new \CoreLibs\UrlRequests\Curl();
// options // options
@@ -964,6 +981,9 @@ final class CoreLibsUrlRequestsCurlTest extends TestCase
*/ */
public function testUrlRequestsCurlRequestMultiple() public function testUrlRequestsCurlRequestMultiple()
{ {
if (!$this->url_basic) {
$this->markTestSkipped('No backend interface setup for testing');
}
$curl = new \CoreLibs\UrlRequests\Curl(); $curl = new \CoreLibs\UrlRequests\Curl();
// get // get
$response = $curl->get($this->url_basic, [ $response = $curl->get($this->url_basic, [
@@ -1055,6 +1075,9 @@ final class CoreLibsUrlRequestsCurlTest extends TestCase
*/ */
public function testUrlRequestsCurlAuthHeader() public function testUrlRequestsCurlAuthHeader()
{ {
if (!$this->url_basic) {
$this->markTestSkipped('No backend interface setup for testing');
}
$curl = new \CoreLibs\UrlRequests\Curl([ $curl = new \CoreLibs\UrlRequests\Curl([
"auth" => ["user", "pass", "basic"], "auth" => ["user", "pass", "basic"],
"http_errors" => false, "http_errors" => false,
@@ -1121,6 +1144,9 @@ final class CoreLibsUrlRequestsCurlTest extends TestCase
*/ */
public function testExceptionInvalidHeaderKey(): void public function testExceptionInvalidHeaderKey(): void
{ {
if (!$this->url_basic) {
$this->markTestSkipped('No backend interface setup for testing');
}
$curl = new \CoreLibs\UrlRequests\Curl(); $curl = new \CoreLibs\UrlRequests\Curl();
$this->expectException(\RuntimeException::class); $this->expectException(\RuntimeException::class);
$this->expectExceptionMessageMatches("/InvalidHeaderKey/"); $this->expectExceptionMessageMatches("/InvalidHeaderKey/");
@@ -1141,6 +1167,9 @@ final class CoreLibsUrlRequestsCurlTest extends TestCase
*/ */
public function testExceptionInvalidHeaderValue(): void public function testExceptionInvalidHeaderValue(): void
{ {
if (!$this->url_basic) {
$this->markTestSkipped('No backend interface setup for testing');
}
$curl = new \CoreLibs\UrlRequests\Curl(); $curl = new \CoreLibs\UrlRequests\Curl();
$this->expectException(\RuntimeException::class); $this->expectException(\RuntimeException::class);
$this->expectExceptionMessageMatches("/InvalidHeaderValue/"); $this->expectExceptionMessageMatches("/InvalidHeaderValue/");
@@ -1190,6 +1219,9 @@ final class CoreLibsUrlRequestsCurlTest extends TestCase
*/ */
public function testExceptionBadRequest(): void public function testExceptionBadRequest(): void
{ {
if (!$this->url_basic) {
$this->markTestSkipped('No backend interface setup for testing');
}
$curl = new \CoreLibs\UrlRequests\Curl(["http_errors" => true]); $curl = new \CoreLibs\UrlRequests\Curl(["http_errors" => true]);
$this->expectException(\RuntimeException::class); $this->expectException(\RuntimeException::class);
$this->expectExceptionMessageMatches("/ClientError/"); $this->expectExceptionMessageMatches("/ClientError/");
@@ -1211,6 +1243,9 @@ final class CoreLibsUrlRequestsCurlTest extends TestCase
*/ */
public function testExceptionBadRequestEnable(): void public function testExceptionBadRequestEnable(): void
{ {
if (!$this->url_basic) {
$this->markTestSkipped('No backend interface setup for testing');
}
$curl = new \CoreLibs\UrlRequests\Curl(["http_errors" => false]); $curl = new \CoreLibs\UrlRequests\Curl(["http_errors" => false]);
$this->expectException(\RuntimeException::class); $this->expectException(\RuntimeException::class);
$this->expectExceptionMessageMatches("/ClientError/"); $this->expectExceptionMessageMatches("/ClientError/");
@@ -1233,6 +1268,9 @@ final class CoreLibsUrlRequestsCurlTest extends TestCase
*/ */
public function testExceptionBadRequestUnset(): void 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 // if true, with false it has to be off
$curl = new \CoreLibs\UrlRequests\Curl(["http_errors" => true]); $curl = new \CoreLibs\UrlRequests\Curl(["http_errors" => true]);
$response = $curl->request('get', $this->url_basic, [ $response = $curl->request('get', $this->url_basic, [