diff --git a/.github/workflows/php.yml b/.github/workflows/php.yml new file mode 100644 index 0000000..15e1548 --- /dev/null +++ b/.github/workflows/php.yml @@ -0,0 +1,37 @@ +name: PHP Lint Check + +on: + push: + branches: [ "unittest" ] + pull_request: + branches: [ "unittest" ] + +permissions: + contents: read + +jobs: + build: + + runs-on: self-hosted + + steps: + + - name: Checkout code + uses: actions/checkout@v4 + + - name: Install PHP + uses: shivammathur/setup-php@v2 + with: + php-version: '7.4' + + - name: PHP lint + run: | + lint_errors=$(find app kero/sine -type f -name "*.php" -exec php -l {} \; 2>&1) + echo "$lint_errors" + if grep -q "Parse error" <<< "$lint_errors"; then + exit 1 + fi + + - name: Run PHPUnit tests + run: | + vendor\bin\phpunit.bat --configuration phpunit.xml --testsuite Dev diff --git a/dev/test/SENE_Controller_Test.php b/dev/test/SENE_Controller_Test.php index aecbcb2..3c1be2a 100644 --- a/dev/test/SENE_Controller_Test.php +++ b/dev/test/SENE_Controller_Test.php @@ -36,6 +36,10 @@ public function invokeMethod(&$object, $methodName, array $parameters = array()) return $method->invokeArgs($object, $parameters); } + /** + * @covers SENE_Controller::setTitle() + * @covers SENE_Controller::getTitle() + */ public function testTitle() { $tc = new SENE_Controller_Mock(); @@ -45,6 +49,10 @@ public function testTitle() $this->assertNotEquals(strtolower($ts), $this->invokeMethod($tc, 'getTitle', array())); } + /** + * @covers SENE_Controller::setDescription() + * @covers SENE_Controller::getDescription() + */ public function testDescription() { $tc = new SENE_Controller_Mock(); @@ -53,7 +61,11 @@ public function testDescription() $this->assertEquals($ts, $this->invokeMethod($tc, 'getDescription', array())); $this->assertNotEquals(strtolower($ts), $this->invokeMethod($tc, 'getDescription', array())); } - + + /** + * @covers SENE_Controller::setLang() + * @covers SENE_Controller::getLang() + */ public function testLang() { $tc = new SENE_Controller_Mock(); @@ -62,7 +74,11 @@ public function testLang() $this->assertEquals($ts, $this->invokeMethod($tc, 'getLang', array())); $this->assertNotEquals(strtolower($ts), $this->invokeMethod($tc, 'getLang', array())); } - + + /** + * @covers SENE_Controller::setRobots() + * @covers SENE_Controller::getRobots() + */ public function testRobots() { $tc = new SENE_Controller_Mock(); @@ -83,7 +99,11 @@ public function testRobots() $this->assertEquals('INDEX', $this->invokeMethod($tc, 'getRobots', array())); $this->assertNotEquals(strtolower(''), $this->invokeMethod($tc, 'getRobots', array())); } - + + /** + * @covers SENE_Controller::setAuthor() + * @covers SENE_Controller::getAuthor() + */ public function testAuthor() { $tc = new SENE_Controller_Mock(); @@ -93,9 +113,8 @@ public function testAuthor() } /** - * - * - * + * @covers SENE_Controller::setIcon() + * @covers SENE_Controller::getIcon() */ public function testIcon() { @@ -106,9 +125,8 @@ public function testIcon() } /** - * - * - * + * @covers SENE_Controller::setShortcutIcon() + * @covers SENE_Controller::getShortcutIcon() */ public function testShortcutIcon() { @@ -202,9 +220,8 @@ public function testTheme() } /** - * - * - * + * @covers SENE_Controller::setcanonical + * @covers SENE_Controller::getcanonical */ public function testCanonicalEmpty() { @@ -231,9 +248,8 @@ public function testCanonicalEmpty() } /** - * - * - * + * @covers SENE_Controller::setadditional + * @covers SENE_Controller::getadditional */ public function testSetAdditional() { @@ -245,9 +261,8 @@ public function testSetAdditional() } /** - * - * - * + * @covers SENE_Controller::setadditional + * @covers SENE_Controller::getadditional */ public function testGetAdditionalPlain() { @@ -261,9 +276,8 @@ public function testGetAdditionalPlain() } /** - * - * - * + * @covers SENE_Controller::setadditional + * @covers SENE_Controller::getadditional */ public function testGetAdditionalBaseUrl() { @@ -277,9 +291,8 @@ public function testGetAdditionalBaseUrl() } /** - * - * - * + * @covers SENE_Controller::setadditional + * @covers SENE_Controller::getadditional */ public function testGetAdditionalBaseUrlAdmin() { @@ -293,9 +306,8 @@ public function testGetAdditionalBaseUrlAdmin() } /** - * - * - * + * @covers SENE_Controller::setadditional + * @covers SENE_Controller::getadditional */ public function testGetAdditionalCdnUrl() { @@ -310,9 +322,7 @@ public function testGetAdditionalCdnUrl() } /** - * - * - * + * @covers SENE_Controller::setadditionalbefore */ public function testSetAdditionalBefore() { @@ -324,9 +334,8 @@ public function testSetAdditionalBefore() } /** - * - * - * + * @covers SENE_Controller::setadditionalbefore + * @covers SENE_Controller::getadditionalbefore */ public function testGetAdditionalBeforePlain() { diff --git a/dev/test/SENE_Input_Test.php b/dev/test/SENE_Input_Test.php index 6ba19d9..b7e5336 100644 --- a/dev/test/SENE_Input_Test.php +++ b/dev/test/SENE_Input_Test.php @@ -60,9 +60,8 @@ public function testPost() } /** - * - * - * + * @covers SENE_Input::get + * @covers SENE_Input::post */ public function testGet() { @@ -87,9 +86,7 @@ public function testGet() } /** - * - * - * + * @covers SENE_Input::request */ public function testRequest() { diff --git a/dev/test/SENE_MySQLi_Engine_Test.php b/dev/test/SENE_MySQLi_Engine_Test.php index f3f7f8b..fa21d27 100644 --- a/dev/test/SENE_MySQLi_Engine_Test.php +++ b/dev/test/SENE_MySQLi_Engine_Test.php @@ -3,7 +3,6 @@ declare(strict_types=1); // Path to run ./vendor/bin/phpunit --bootstrap vendor/autoload.php FileName.php // Butuh Framework PHPUnit -use PHPUnit\Framework\TestCase; require_once $GLOBALS['SEMEDIR']->kero_sine.'SENE_Sql.php'; require_once $GLOBALS['SEMEDIR']->kero_sine.'SENE_Sql_Select.php'; @@ -24,7 +23,7 @@ public function __construct() #[UsesClass('SENE_MySQLi_Engine_Mock')] #[CoversClass('SENE_MySQLi_Engine')] #[CoversClass('SENE_Model')] -final class SENE_MySQLi_Engine_Test extends TestCase +final class SENE_MySQLi_Engine_Test extends PHPUnit\Framework\TestCase { /** * Call protected/private method of a class. @@ -44,7 +43,7 @@ public function invokeMethod(&$object, $methodName, array $parameters = array()) } /** - * + * @covers SENE_MySQLi_Engine::flushQuery * */ public function testFlushQuery() @@ -64,7 +63,7 @@ public function testFlushQuery() } /** - * + * @covers SENE_MySQLi_Engine::flushQuery * */ public function testFlushQueryAfter() @@ -87,7 +86,7 @@ public function testFlushQueryAfter() } /** - * + * @covers SENE_MySQLi_Engine::flushQuery * */ public function testWhereIsNull() @@ -113,7 +112,9 @@ public function testWhereIsNull() } /** - * + * @covers SENE_MySQLi_Engine::select + * @covers SENE_MySQLi_Engine::from + * @covers SENE_MySQLi_Engine::where * */ public function testWhereIsNotNull() @@ -139,7 +140,9 @@ public function testWhereIsNotNull() } /** - * + * @covers SENE_MySQLi_Engine::select + * @covers SENE_MySQLi_Engine::from + * @covers SENE_MySQLi_Engine::where * */ public function testWhereAsIsNull() @@ -165,7 +168,8 @@ public function testWhereAsIsNull() } /** - * + * @covers SENE_MySQLi_Engine::where_as + * @covers SENE_MySQLi_Engine::where * */ public function testWhereAsIsNotNull() @@ -191,7 +195,9 @@ public function testWhereAsIsNotNull() } /** - * + * @covers SENE_MySQLi_Engine::select + * @covers SENE_MySQLi_Engine::from + * @covers SENE_MySQLi_Engine::where * */ public function testWhere() @@ -302,7 +308,8 @@ public function testWhere() } /** - * + * @covers SENE_MySQLi_Engine::where_as + * @covers SENE_MySQLi_Engine::where * */ public function testWhereAs()