Skip to content

Commit

Permalink
Bugfix fix qa tools
Browse files Browse the repository at this point in the history
  • Loading branch information
hannesbochmann committed Oct 9, 2024
1 parent 19a87bc commit e118908
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 11 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
/.development/node_modules
/captainhook.config.json
/composer.lock
.phpunit.result.cache
1 change: 1 addition & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ include:
variables:
DISABLE_BUILD_NPM: 1
DISABLE_TEST_RECTOR: 1
DISABLE_TEST_PHPCPD: 1
BIN_PATH: ./.Build/bin
PHP_ANALYSE_PATHS: ./Classes
ANALYSE_YAML_PATHS: './Configuration ./Resources'
Expand Down
3 changes: 2 additions & 1 deletion Classes/Service/AiAltTextLogsService.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

use DMK\MkContentAi\Domain\Model\AltTextLog;
use DMK\MkContentAi\Domain\Repository\AltTextLogRepository;
use TYPO3\CMS\Core\Database\Connection;
use TYPO3\CMS\Core\Database\Query\QueryBuilder;

class AiAltTextLogsService
Expand All @@ -35,7 +36,7 @@ public function deleteRelatedChildren(int $parentId): void
$this->altTextLogsQueryBuilder
->delete('tx_mkcontentai_domain_model_alt_text_logs')
->where(
$this->altTextLogsQueryBuilder->expr()->eq('sys_file_metadata', $this->altTextLogsQueryBuilder->createNamedParameter($parentId, \PDO::PARAM_INT))
$this->altTextLogsQueryBuilder->expr()->eq('sys_file_metadata', $this->altTextLogsQueryBuilder->createNamedParameter($parentId, Connection::PARAM_INT))
);

$this->altTextLogsQueryBuilder->executeStatement();
Expand Down
12 changes: 8 additions & 4 deletions Classes/Service/FileService.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ public function saveTempBase64Image(string $base64): string
$base64Image = explode(';base64,', $base64)[1];
$binaryData = base64_decode($base64Image);
$tempFile = GeneralUtility::tempnam('contentai');
if (false === $tempFile) {
if (!$tempFile) {
$translatedMessage = LocalizationUtility::translate('labelErrorTempFile', 'mkcontentai') ?? '';

throw new \Exception($translatedMessage);
Expand Down Expand Up @@ -197,9 +197,13 @@ public function getFilePath(string $base64, ?File $file): string

private function getStorage(?string $storageIdentifier = null): ResourceStorage
{
$storage = (null === $storageIdentifier) ?
$this->storageRepository->getDefaultStorage() :
$this->storageRepository->findByCombinedIdentifier($storageIdentifier);
$storage = null;
if (null === $storageIdentifier) {
$storage = $this->storageRepository->getDefaultStorage();
}
if (is_string($storageIdentifier) && strlen($storageIdentifier) > 0) {
$storage = $this->storageRepository->findByCombinedIdentifier($storageIdentifier);
}

if (null === $storage) {
$translatedMessage = LocalizationUtility::translate('labelErrorStorage', 'mkcontentai') ?? '';
Expand Down
5 changes: 5 additions & 0 deletions Classes/ViewHelpers/IfOperationAllowedViewHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ public function initializeArguments(): void
$this->registerArgument('action', 'string', 'Action');
}

/**
* @param array<string, mixed>|null $arguments
*
* @return bool
*/
protected static function evaluateCondition($arguments = null)
{
if (!isset($arguments['client']) || !isset($arguments['action'])) {
Expand Down
1 change: 1 addition & 0 deletions Tests/Unit/ImageTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class ImageTest extends UnitTestCase

protected function setUp(): void
{
parent::setUp();
$this->image = new Image($this->url, $this->text);
}

Expand Down
7 changes: 1 addition & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
},
"require-dev": {
"typo3/testing-framework": "^6.16 || ^7.0 || ^8.0",
"sebastian/phpcpd": "^6.0",
"phpmd/phpmd": "^2.13",
"phpstan/phpstan": "^1.9",
"friendsofphp/php-cs-fixer": "^3.14",
Expand Down Expand Up @@ -133,11 +132,8 @@
"test:phpstan": [
".Build/bin/phpstan analyse -c phpstan.neon --memory-limit=512M"
],
"test:phpcpd": [
"(test \"$(php -v | grep \"Xdebug v3\" | wc -l)\" = 0 && .Build/bin/phpcpd ./Classes) | true"
],
"test:phpunit": [
"TYPO3_PATH_APP=$PWD/.Build TYPO3_PATH_WEB=$PWD/.Build/Web .Build/bin/phpunit -c phpunit.xml --whitelist=./Classes Tests"
"TYPO3_PATH_APP=$PWD/.Build TYPO3_PATH_WEB=$PWD/.Build/Web .Build/bin/phpunit -c phpunit.xml Tests"
],
"test:phpunit-coverage": [
"XDEBUG_MODE=coverage .Build/bin/phpunit --coverage-text --log-junit=.Build/junit.xml --coverage-clover=.Build/coverage.xml -c phpunit.xml --whitelist=./Classes Tests"
Expand All @@ -148,7 +144,6 @@
"@test:phpcompatibility",
"@test:phpmd",
"@test:phpstan",
"@test:phpcpd",
"@test:phpunit"
],
"fix:phpcs": [
Expand Down

0 comments on commit e118908

Please sign in to comment.