From 592b3ba033566110666177fe75b735a9d540993c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roger=20Vil=C3=A0?= Date: Mon, 6 Nov 2023 17:55:09 +0100 Subject: [PATCH] wip --- .github/workflows/ci.yml | 4 ++++ composer.json | 4 +++- src/Sermepa/Tpv/Tpv.php | 5 +++-- tests/TpvTest.php | 6 +++--- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 74b5e56..9831076 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,6 +40,10 @@ jobs: - name: PHP Version run: php --version + - name: Execute static analysis tests + if: matrix.php-versions == '8.2' + run: composer test-static + # Code quality - name: Execute tests (Unit and Feature tests) via PHPUnit # Set environment diff --git a/composer.json b/composer.json index 63ab33f..8a9ea4b 100755 --- a/composer.json +++ b/composer.json @@ -41,8 +41,10 @@ "fix": [ "@php ./vendor/bin/php-cs-fixer fix --allow-risky=yes" ], + "test-static": [ + "@php ./vendor/bin/php-cs-fixer check --allow-risky=yes" + ], "test": [ - "@php ./vendor/bin/php-cs-fixer check --allow-risky=yes", "@php ./vendor/bin/phpunit --testdox" ] } diff --git a/src/Sermepa/Tpv/Tpv.php b/src/Sermepa/Tpv/Tpv.php index 38320e3..4bc923b 100644 --- a/src/Sermepa/Tpv/Tpv.php +++ b/src/Sermepa/Tpv/Tpv.php @@ -139,7 +139,7 @@ public function setSumtotal($sumTotal) */ public function setChargeExpiryDate($date) { - if (! $this->isValidDate($date)) { + if (!$this->isValidDate($date)) { throw new TpvException('Date is not valid.'); } @@ -517,7 +517,8 @@ public function getEnvironment() * @param string $version JavaScript file version: 2 or 3. * @return string JavaScript file path. */ - public static function getJsPath($environment = 'test', $version = '2'){ + public static function getJsPath($environment = 'test', $version = '2') + { // Stores the array of JavaScript file paths. static $jsPaths = [ diff --git a/tests/TpvTest.php b/tests/TpvTest.php index 00f860a..c44fab4 100644 --- a/tests/TpvTest.php +++ b/tests/TpvTest.php @@ -605,7 +605,7 @@ public function jsPathProvider() * @test * @dataProvider jsPathProvider */ - public function should_return_the_correct_js_path($environment, $version, $expectedPath) + public function should_return_the_correct_js_path($environment, $version, $expectedPath): void { $redsys = new Tpv(); $actualPath = $redsys->getJsPath($environment, $version); @@ -613,7 +613,7 @@ public function should_return_the_correct_js_path($environment, $version, $expec $this->assertEquals($expectedPath, $actualPath); } - public function invalidEnvironmentVersionPathJs() + public static function invalidEnvironmentVersionPathJs() { return [ ['test', '1'], @@ -633,7 +633,7 @@ public function invalidEnvironmentVersionPathJs() * @test * @dataProvider invalidEnvironmentVersionPathJs */ - public function throw_when_set_environment_or_version_is_invalid($environment, $version) + public function throw_when_set_environment_or_version_is_invalid($environment, $version): void { $this->expectExceptionMessage("Invalid environment or version"); $this->expectException(\Sermepa\Tpv\TpvException::class);