From 128d6533fc68ce10042a693d9caa429e643d5729 Mon Sep 17 00:00:00 2001 From: Clemens Schwaighofer Date: Wed, 4 Oct 2023 14:49:49 +0900 Subject: [PATCH] Remove composer install phan/phpstan/etc and switch to phive install --- .phive/phars.xml | 8 ++++ ReadMe.md | 18 +++++++ composer.json | 4 -- phpunit.xml | 1 + test/phpunit/DB/CoreLibsDBIOTest.php | 3 +- .../Debug/CoreLibsDebugSupportTest.php | 48 +++++++++++-------- test/phpunit/Get/CoreLibsGetSystemTest.php | 2 +- .../Logging/CoreLibsLoggingLoggingTest.php | 2 +- test/phpunit/bootstrap.php | 15 ++++++ tools/phpcbf | 1 + tools/phpcs | 1 + tools/phpstan | 1 + tools/phpunit | 1 + tools/psalm | 1 + 14 files changed, 80 insertions(+), 26 deletions(-) create mode 100644 .phive/phars.xml create mode 100644 test/phpunit/bootstrap.php create mode 120000 tools/phpcbf create mode 120000 tools/phpcs create mode 120000 tools/phpstan create mode 120000 tools/phpunit create mode 120000 tools/psalm diff --git a/.phive/phars.xml b/.phive/phars.xml new file mode 100644 index 0000000..7e05d6d --- /dev/null +++ b/.phive/phars.xml @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/ReadMe.md b/ReadMe.md index 2c60931..355aea3 100644 --- a/ReadMe.md +++ b/ReadMe.md @@ -23,3 +23,21 @@ Alternative setup composer local zip file repot: ## Install package `composer require egrajp/corelibs-composer-all:^8.0` + +## Tests + +All tests must be run from the base folder + +### phan + +`phan --progress-bar -C --analyze-twic` + +### phpstan + +`phpstan` + +### phpunit + +PHP unit is installed via "phiev" + +`tools/phpunit test/phpunit` diff --git a/composer.json b/composer.json index e34000c..6867202 100644 --- a/composer.json +++ b/composer.json @@ -20,11 +20,7 @@ "psr/log": "^3.0@dev" }, "require-dev": { - "phpstan/phpstan": "^1.10", - "phan/phan": "v5.x-dev", - "phpunit/phpunit": "^9", "egrajp/smarty-extended": "^4.3", - "vimeo/psalm": "^5.0@dev", "gullevek/dotenv": "dev-master" }, "repositories": { diff --git a/phpunit.xml b/phpunit.xml index 23d3de4..3edd6bb 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -2,5 +2,6 @@ cacheResultFile="/tmp/phpunit-corelibs-composer.result.cache" colors="true" verbose="true" + bootstrap="test/phpunit/bootstrap.php" > diff --git a/test/phpunit/DB/CoreLibsDBIOTest.php b/test/phpunit/DB/CoreLibsDBIOTest.php index 40479e1..d1d598f 100644 --- a/test/phpunit/DB/CoreLibsDBIOTest.php +++ b/test/phpunit/DB/CoreLibsDBIOTest.php @@ -3907,7 +3907,8 @@ final class CoreLibsDBIOTest extends TestCase 'id' => '51', 'error' => 'Max query call needs to be set to at least 1', // run:: can be +1 if called in set and not direct - 'source' => "/^include::main::run::run::run::run::run::run::(run::)?runBare::runTest::testDbErrorHandling::dbSetMaxQueryCall$/", + // 'main::run::run::run::run::run::run::run::runBare::runTest::testDbErrorHandling::dbSetMaxQueryCall + 'source' => "/^(include::)?main::(run::)+runBare::runTest::testDbErrorHandling::dbSetMaxQueryCall$/", 'pg_error' => '', 'msg' => '', ] diff --git a/test/phpunit/Debug/CoreLibsDebugSupportTest.php b/test/phpunit/Debug/CoreLibsDebugSupportTest.php index 2420d5a..ab74df7 100644 --- a/test/phpunit/Debug/CoreLibsDebugSupportTest.php +++ b/test/phpunit/Debug/CoreLibsDebugSupportTest.php @@ -460,8 +460,8 @@ final class CoreLibsDebugSupportTest extends TestCase * Undocumented function * * @cover ::getCallerFileLine - * @testWith ["vendor/phpunit/phpunit/src/Framework/TestCase.php:"] - * @testdox getCallerFileLine check based on regex /[\w\-\/]/vendor/phpunit/phpunit/src/Framework/TestCase.php:\d+ [$_dataName] + * @testWith ["vendor/phpunit/phpunit/src/Framework/TestCase.php:6434","phar:///home/clemens/.phive/phars/phpunit-9.6.13.phar/phpunit/Framework/TestCase.php:6434"] + * @testdox getCallerFileLine check based on regex .../Framework/TestCase.php:\d+ [$_dataName] * * @param string $expected * @return void @@ -469,7 +469,14 @@ final class CoreLibsDebugSupportTest extends TestCase public function testGetCallerFileLine(): void { // regex prefix with path "/../" and then fixed vendor + \d+ - $regex = "/^\/[\w\-\/]+\/vendor\/phpunit\/phpunit\/src\/Framework\/TestCase.php:\d+$/"; + // or phar start if phiev installed + // phar:///home/clemens/.phive/phars/phpunit-9.6.13.phar/phpunit/Framework/TestCase.php + $regex = "/^(" + . "\/.*\/vendor\/phpunit\/phpunit\/src" + . "|" + . "phar:\/\/\/.*\.phive\/phars\/phpunit-\d+\.\d+\.\d+\.phar\/phpunit" + . ")" + . "\/Framework\/TestCase.php:\d+$/"; $this->assertMatchesRegularExpression( $regex, Support::getCallerFileLine() @@ -514,27 +521,30 @@ final class CoreLibsDebugSupportTest extends TestCase // add nothing $this->assertEquals( $expected, - Support::getCallerMethodList(), + $compare, 'assert expected 10' ); break; case 11: - // add one "run" before "runBare" - // array_splice( - // $expected, - // 7, - // 0, - // ['run'] - // ); - array_splice( - $expected, - 0, - 0, - ['include'] - ); + if ($compare[0] == 'include') { + // add include at first + array_splice( + $expected, + 0, + 0, + ['include'] + ); + } else { + array_splice( + $expected, + 6, + 0, + ['run'] + ); + } $this->assertEquals( $expected, - Support::getCallerMethodList(), + $compare, 'assert expected 11' ); break; @@ -554,7 +564,7 @@ final class CoreLibsDebugSupportTest extends TestCase ); $this->assertEquals( $expected, - Support::getCallerMethodList(), + $compare, 'assert expected 12' ); break; diff --git a/test/phpunit/Get/CoreLibsGetSystemTest.php b/test/phpunit/Get/CoreLibsGetSystemTest.php index 221553c..a73e91f 100644 --- a/test/phpunit/Get/CoreLibsGetSystemTest.php +++ b/test/phpunit/Get/CoreLibsGetSystemTest.php @@ -99,7 +99,7 @@ final class CoreLibsGetSystemTest extends TestCase 1 => 'phpunit', 2 => 'phpunit', // NOTE: this can change, so it is a regex check - 3 => "/^(\/?.*\/?)?vendor\/bin\/phpunit$/", + 3 => "/^(\/?.*\/?)?(vendor\/bin|tools)\/phpunit$/", ], 'some path with extension' => [ 0 => '/some/path/to/file.txt', diff --git a/test/phpunit/Logging/CoreLibsLoggingLoggingTest.php b/test/phpunit/Logging/CoreLibsLoggingLoggingTest.php index bf9a189..da99916 100644 --- a/test/phpunit/Logging/CoreLibsLoggingLoggingTest.php +++ b/test/phpunit/Logging/CoreLibsLoggingLoggingTest.php @@ -20,7 +20,7 @@ final class CoreLibsLoggingLoggingTest extends TestCase private const LOG_FOLDER = __DIR__ . DIRECTORY_SEPARATOR . 'log' . DIRECTORY_SEPARATOR; private const REGEX_BASE = "\[[\d\-\s\.:]+\]\s{1}" // date . "\[[\w\.]+(:\d+)?\]\s{1}" // host:port - . "\[[\w\-\.\/]+:\d+\]\s{1}" // folder/file + . "\[(phar:\/\/)?[\w\-\.\/]+:\d+\]\s{1}" // folder/file [note phar:// is for phpunit] . "\[\w+\]\s{1}" // run id . "{[\w\\\\]+((::|->)\w+)?}\s{1}"; // class diff --git a/test/phpunit/bootstrap.php b/test/phpunit/bootstrap.php new file mode 100644 index 0000000..97147d8 --- /dev/null +++ b/test/phpunit/bootstrap.php @@ -0,0 +1,15 @@ +