diff --git a/.github/workflows/typo3_13.yml b/.github/workflows/typo3_13.yml index 248d63c..ee546dc 100644 --- a/.github/workflows/typo3_13.yml +++ b/.github/workflows/typo3_13.yml @@ -68,3 +68,28 @@ jobs: - name: 'Execute unit tests' run: Build/Scripts/runTests.sh -p ${{ matrix.php }} -s unit + + functional-tests: + name: Functional tests + needs: code-quality + runs-on: self-hosted + + strategy: + matrix: + php: + - '8.2' + - '8.3' + + vendor: + - mysql + - mariadb + + steps: + - name: 'Checkout' + uses: actions/checkout@v4 + + - name: 'Install testing system' + run: Build/Scripts/runTests.sh -p ${{ matrix.php }} -s composerUpdate + + - name: 'Execute functional tests' + run: Build/Scripts/runTests.sh -p ${{ matrix.php }} -d ${{ matrix.vendor }} -s functional diff --git a/Classes/Helper/ExplainQueryHelper.php b/Classes/Helper/ExplainQueryHelper.php index 9d8fa85..771d355 100644 --- a/Classes/Helper/ExplainQueryHelper.php +++ b/Classes/Helper/ExplainQueryHelper.php @@ -14,8 +14,7 @@ use Doctrine\DBAL\Exception; use StefanFroemken\Mysqlreport\Configuration\ExtConf; use StefanFroemken\Mysqlreport\Domain\Model\QueryInformation; -use TYPO3\CMS\Core\Database\Connection; -use TYPO3\CMS\Core\Database\ConnectionPool; +use StefanFroemken\Mysqlreport\Traits\DatabaseConnectionTrait; use TYPO3\CMS\Core\Utility\GeneralUtility; /** @@ -23,6 +22,8 @@ */ readonly class ExplainQueryHelper { + use DatabaseConnectionTrait; + /** * @param QueryInformation $queryInformation */ @@ -77,10 +78,4 @@ private function getExtConf(): ExtConf { return GeneralUtility::makeInstance(ExtConf::class); } - - private function getDefaultConnection(): Connection - { - return GeneralUtility::makeInstance(ConnectionPool::class) - ->getConnectionByName(ConnectionPool::DEFAULT_CONNECTION_NAME); - } } diff --git a/Tests/Functional/Configuration/ExtConfTest.php b/Tests/Functional/Configuration/ExtConfTest.php new file mode 100644 index 0000000..8d83e35 --- /dev/null +++ b/Tests/Functional/Configuration/ExtConfTest.php @@ -0,0 +1,140 @@ +subject = $this->get(ExtConf::class); + } + + protected function tearDown(): void + { + unset( + $this->subject, + ); + + parent::tearDown(); + } + + #[Test] + public function isEnableFrontendLoggingInitiallyReturnsFalse(): void + { + self::assertFalse( + $this->subject->isEnableFrontendLogging(), + ); + } + + #[Test] + public function setEnableFrontendLoggingSetsEnableFrontendLogging(): void + { + $this->subject->setEnableFrontendLogging('1'); + + self::assertTrue( + $this->subject->isEnableFrontendLogging(), + ); + } + + #[Test] + public function isEnableBackendLoggingInitiallyReturnsFalse(): void + { + self::assertFalse( + $this->subject->isEnableBackendLogging(), + ); + } + + #[Test] + public function setEnableBackendLoggingSetsEnableBackendLogging(): void + { + $this->subject->setEnableBackendLogging('1'); + + self::assertTrue( + $this->subject->isEnableBackendLogging(), + ); + } + + #[Test] + public function isActivateExplainQueryInitiallyReturnsFalse(): void + { + self::assertFalse( + $this->subject->isActivateExplainQuery(), + ); + } + + #[Test] + public function setActivateExplainQuerySetsActivateExplainQuery(): void + { + $this->subject->setActivateExplainQuery('1'); + + self::assertTrue( + $this->subject->isActivateExplainQuery(), + ); + } + + #[Test] + public function getSlowQueryThresholdInitiallyReturns10Seconds(): void + { + self::assertSame( + 10.0, + $this->subject->getSlowQueryThreshold(), + ); + } + + #[Test] + public function setSlowQueryThresholdWithIntegerSetsSlowQueryThreshold(): void + { + $this->subject->setSlowQueryThreshold('1'); + + self::assertSame( + 1.0, + $this->subject->getSlowQueryThreshold(), + ); + } + + #[Test] + public function setSlowQueryThresholdWithFloatSetsSlowQueryThreshold(): void + { + $this->subject->setSlowQueryThreshold('1.25'); + + self::assertSame( + 1.25, + $this->subject->getSlowQueryThreshold(), + ); + } + + #[Test] + public function setSlowQueryThresholdWithCommaFloatSetsSlowQueryThreshold(): void + { + $this->subject->setSlowQueryThreshold('5,38'); + + self::assertSame( + 5.38, + $this->subject->getSlowQueryThreshold(), + ); + } +} diff --git a/ext_emconf.php b/ext_emconf.php index 438c03b..af5e50e 100644 --- a/ext_emconf.php +++ b/ext_emconf.php @@ -14,7 +14,7 @@ 'typo3' => '13.0.0-13.4.99', ], 'conflicts' => [ - 'adminpanel', + 'adminpanel' => '13.0.0-13.4.99', ], 'suggests' => [ ],