diff --git a/.github/workflows/linters.yml b/.github/workflows/linters.yml index ef224a87c..243f0610a 100644 --- a/.github/workflows/linters.yml +++ b/.github/workflows/linters.yml @@ -21,7 +21,7 @@ jobs: # Steps represent a sequence of tasks that will be executed as part of the job steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 # Runs a single command using the runners shell - name: "Run a one-line script" @@ -35,7 +35,7 @@ jobs: steps: # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - name: "Checkout code" - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: "Setup Node" uses: actions/setup-node@v3 diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index d90ec3ec2..0af04bb44 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -10,7 +10,7 @@ jobs: runs-on: ubuntu-20.04 steps: - name: "Checkout" - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: "Publish new version to TER" uses: tomasnorre/typo3-upload-ter@v2 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f20411770..172c34bd1 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -16,17 +16,17 @@ jobs: fail-fast: true matrix: os: [ubuntu-latest] - php: [8.1, 8.2] + php: [8.1, 8.2, 8.3] typo3: [^12.2] name: P${{ matrix.php }} - T${{ matrix.typo3 }} steps: - name: "Checkout code" - uses: actions/checkout@v2 + uses: actions/checkout@v4 - name: "Cache dependencies" - uses: actions/cache@v1 + uses: actions/cache@v4 with: path: ~/.composer/cache/files key: dependencies-typo3-${{ matrix.typo3 }}-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }} diff --git a/.gitignore b/.gitignore index 449042127..53583ceed 100644 --- a/.gitignore +++ b/.gitignore @@ -29,3 +29,6 @@ sass-lint.html .devbox/.ddev/providers/ .devbox/.ddev/xhprof/ .devbox/.ddev/composer.lock +.phpunit.cache +coverage +.phpunit.result.cache diff --git a/Classes/Utility/ExtensionInstallationStatus.php b/Classes/Utility/ExtensionInstallationStatus.php index 6b27302f2..cc6a849c6 100644 --- a/Classes/Utility/ExtensionInstallationStatus.php +++ b/Classes/Utility/ExtensionInstallationStatus.php @@ -85,72 +85,8 @@ public function getStatusMessage(): string return $statusMessage; } - /*public function checkForDbUpdate(string $extensionKey): void - { - $this->dbUpdateNeeded = false; - if (ExtensionManagementUtility::isLoaded($extensionKey)) { - $sqlFile = ExtensionManagementUtility::extPath($extensionKey) . 'ext_tables.sql'; - if (@file_exists($sqlFile)) { - $sqlHandler = GeneralUtility::makeInstance(SqlSchemaMigrationService::class); - - $sqlContent = GeneralUtility::getUrl($sqlFile); - $fieldDefinitionsFromFile = $sqlHandler->getFieldDefinitions_fileContent($sqlContent); - if (count($fieldDefinitionsFromFile)) { - $fieldDefinitionsFromCurrentDatabase = $sqlHandler->getFieldDefinitions_database(); - $updateTableDefinition = $sqlHandler->getDatabaseExtra( - $fieldDefinitionsFromFile, - $fieldDefinitionsFromCurrentDatabase - ); - $this->updateStatements = $sqlHandler->getUpdateSuggestions($updateTableDefinition); - if (!empty($updateTableDefinition['extra']) || !empty($updateTableDefinition['diff']) || !empty($updateTableDefinition['diff_currentValues'])) { - $this->dbUpdateNeeded = true; - } - } - } - } - } - - public function performDbUpdates(array $params): array - { - $hasErrors = false; - if (!empty($params['updateStatements']) && !empty($params['extensionKey'])) { - $this->checkForDbUpdate($params['extensionKey']); - if ($this->dbUpdateNeeded) { - foreach ($this->updateStatements as $type => $statements) { - foreach ($statements as $key => $statement) { - if (in_array($type, ['change', 'add', 'create_table']) - && in_array($key, $params['updateStatements']) - ) { - $res = $this->getDatabaseConnection()->admin_query($statement); - if ($res === false) { - $hasErrors = true; - } elseif (is_resource($res) || is_a($res, mysqli_result::class)) { - $this->getDatabaseConnection()->sql_free_result($res); - } - } - } - } - } - } - if ($hasErrors) { - return ['error' => 'Database could not be updated. Please check it in the update wizzard of the install tool']; - } - - return ['success' => 'Database was successfully updated']; - }*/ - public function isDbUpdateNeeded(): bool { return $this->dbUpdateNeeded; } - - /*public function getUpdateStatements(): array - { - return $this->updateStatements; - } - - protected function getDatabaseConnection() - { - return $GLOBALS['TYPO3_DB']; - }*/ } diff --git a/Tests/BaseFunctionalTest.php b/Tests/BaseFunctionalTest.php index c77c7766c..eccd78dd2 100644 --- a/Tests/BaseFunctionalTest.php +++ b/Tests/BaseFunctionalTest.php @@ -213,6 +213,6 @@ protected function removeInitialModelClassFile(string $modelName): void if (@file_exists($file)) { unlink($file); } - self::assertFileNotExists($file, 'Dummy file could not be removed:' . $file); + self::assertFileDoesNotExist($file, 'Dummy file could not be removed:' . $file); } } diff --git a/Tests/Bootstrap.php b/Tests/Bootstrap.php new file mode 100644 index 000000000..edbda9ff5 --- /dev/null +++ b/Tests/Bootstrap.php @@ -0,0 +1,17 @@ +fileGenerator->generateDomainObjectCode($domainObject); - self::assertRegExp( - '/.*\* \@var bool.*/', + self::assertMatchesRegularExpression( + '/.*\* @var bool.*/', $classFileContent, 'var tag for boolean property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*protected \\$active = false;.*/', $classFileContent, 'boolean property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function getActive\(\).*/', $classFileContent, 'Getter for boolean property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function setActive\(bool \$active\).*/', $classFileContent, 'Setter for boolean property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function isActive\(\).*/', $classFileContent, 'is method for boolean property was not generated' @@ -105,24 +105,24 @@ public function writeModelClassWithColorPickerProperty(): void $classFileContent = $this->fileGenerator->generateDomainObjectCode($domainObject); - self::assertRegExp( - '/.*\* \@var string.*/', + self::assertMatchesRegularExpression( + '/.*\* @var string.*/', $classFileContent, 'var tag for color picker property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*protected \\$color = \'\';.*/', $classFileContent, 'color picker property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function getColor\(\).*/', $classFileContent, 'Getter for color picker property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function setColor\(string \$color\).*/', $classFileContent, 'Setter for color picker property was not generated' @@ -146,24 +146,24 @@ public function writeModelClassWithDateProperty(): void $classFileContent = $this->fileGenerator->generateDomainObjectCode($domainObject); - self::assertRegExp( - '/.*\* \@var \\\\DateTime.*/', + self::assertMatchesRegularExpression( + '/.*\* @var \\\\DateTime.*/', $classFileContent, 'var tag for date property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*protected \\$birthday = null;.*/', $classFileContent, 'string property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function getBirthday\(\).*/', $classFileContent, 'Getter for string property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function setBirthday\(\\\\DateTime \$birthday\).*/', $classFileContent, 'Setter for string property was not generated' @@ -187,24 +187,24 @@ public function writeModelClassWithDateTimeProperty(): void $classFileContent = $this->fileGenerator->generateDomainObjectCode($domainObject); - self::assertRegExp( - '/.*\* \@var \\\\DateTime.*/', + self::assertMatchesRegularExpression( + '/.*\* @var \\\\DateTime.*/', $classFileContent, 'var tag for date property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*protected \\$birthday = null;.*/', $classFileContent, 'date property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function getBirthday\(\).*/', $classFileContent, 'Getter for date property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function setBirthday\(\\\\DateTime \$birthday\).*/', $classFileContent, 'Setter for date property was not generated' @@ -228,24 +228,24 @@ public function writeModelClassWithEmailProperty(): void $classFileContent = $this->fileGenerator->generateDomainObjectCode($domainObject); - self::assertRegExp( - '/.*\* \@var string.*/', + self::assertMatchesRegularExpression( + '/.*\* @var string.*/', $classFileContent, 'var tag for email property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*protected \\$email = \'\';.*/', $classFileContent, 'email property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function getEmail\(\).*/', $classFileContent, 'Getter for email property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function setEmail\(string \$email\).*/', $classFileContent, 'Setter for email property was not generated' @@ -269,24 +269,24 @@ public function writeModelClassWithNullableEmailProperty(): void $classFileContent = $this->fileGenerator->generateDomainObjectCode($domainObject); - self::assertRegExp( - '/.*\* \@var string|null.*/', + self::assertMatchesRegularExpression( + '/.*\* @var string|null.*/', $classFileContent, 'var tag for email property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*protected \\$email = null;.*/', $classFileContent, 'email property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function getEmail\(\).*/', $classFileContent, 'Getter for email property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function setEmail\(\?string \$email\).*/', $classFileContent, 'Setter for email property was not generated' @@ -310,29 +310,29 @@ public function writeModelClassWithFileProperty(): void $classFileContent = $this->fileGenerator->generateDomainObjectCode($domainObject); - self::assertRegExp( - '/.*\* \@var \\\\TYPO3\\\\CMS\\\\Extbase\\\\Domain\\\\Model\\\\FileReference.*/', + self::assertMatchesRegularExpression( + '/.*\* @var \\\\TYPO3\\\\CMS\\\\Extbase\\\\Domain\\\\Model\\\\FileReference.*/', $classFileContent, 'var tag for file property was not generated' ); - self::assertRegExp( - '/.*\* \@TYPO3\\\\CMS\\\\Extbase\\\\Annotation\\\\ORM\\\\Cascade\("remove"\).*/', + self::assertMatchesRegularExpression( + '/.*\* @TYPO3\\\\CMS\\\\Extbase\\\\Annotation\\\\ORM\\\\Cascade\("remove"\).*/', $classFileContent, 'annotation for file property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*protected \\$file = null;.*/', $classFileContent, 'file property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function getFile\(\).*/', $classFileContent, 'Getter for file property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function setFile\(\\\\TYPO3\\\\CMS\\\\Extbase\\\\Domain\\\\Model\\\\FileReference \$file\).*/', $classFileContent, 'Setter for file property was not generated' @@ -356,24 +356,24 @@ public function writeModelClassWithFloatProperty(): void $classFileContent = $this->fileGenerator->generateDomainObjectCode($domainObject); - self::assertRegExp( - '/.*\* \@var float.*/', + self::assertMatchesRegularExpression( + '/.*\* @var float.*/', $classFileContent, 'var tag for float property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*protected \\$floatingNumber = 0\.0;.*/', $classFileContent, 'float property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function getFloatingNumber\(\).*/', $classFileContent, 'Getter for float property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function setFloatingNumber\(float \$floatingNumber\).*/', $classFileContent, 'Setter for float property was not generated' @@ -397,24 +397,24 @@ public function writeModelClassWithNullableFloatProperty(): void $classFileContent = $this->fileGenerator->generateDomainObjectCode($domainObject); - self::assertRegExp( - '/.*\* \@var float|null.*/', + self::assertMatchesRegularExpression( + '/.*\* @var float|null.*/', $classFileContent, 'var tag for float property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*protected \\$floatingNumber = null;.*/', $classFileContent, 'float property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function getFloatingNumber\(\).*/', $classFileContent, 'Getter for float property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function setFloatingNumber\(\?float \$floatingNumber\).*/', $classFileContent, 'Setter for float property was not generated' @@ -438,29 +438,29 @@ public function writeModelClassWithImageProperty(): void $classFileContent = $this->fileGenerator->generateDomainObjectCode($domainObject); - self::assertRegExp( - '/.*\* \@var \\\\TYPO3\\\\CMS\\\\Extbase\\\\Domain\\\\Model\\\\FileReference.*/', + self::assertMatchesRegularExpression( + '/.*\* @var \\\\TYPO3\\\\CMS\\\\Extbase\\\\Domain\\\\Model\\\\FileReference.*/', $classFileContent, 'var tag for image property was not generated' ); - self::assertRegExp( - '/.*\* \@TYPO3\\\\CMS\\\\Extbase\\\\Annotation\\\\ORM\\\\Cascade\("remove"\).*/', + self::assertMatchesRegularExpression( + '/.*\* @TYPO3\\\\CMS\\\\Extbase\\\\Annotation\\\\ORM\\\\Cascade\("remove"\).*/', $classFileContent, 'annotation for image property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*protected \\$image = null;.*/', $classFileContent, 'image property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function getImage\(\).*/', $classFileContent, 'Getter for image property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function setImage\(\\\\TYPO3\\\\CMS\\\\Extbase\\\\Domain\\\\Model\\\\FileReference \$image\).*/', $classFileContent, 'Setter for image property was not generated' @@ -484,24 +484,24 @@ public function writeModelClassWithInputLinkProperty(): void $classFileContent = $this->fileGenerator->generateDomainObjectCode($domainObject); - self::assertRegExp( - '/.*\* \@var string.*/', + self::assertMatchesRegularExpression( + '/.*\* @var string.*/', $classFileContent, 'var tag for link property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*protected \\$link = \'\';.*/', $classFileContent, 'link property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function getLink\(\).*/', $classFileContent, 'Getter for link property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function setLink\(string \$link\).*/', $classFileContent, 'Setter for link property was not generated' @@ -525,24 +525,24 @@ public function writeModelClassWithIntegerProperty(): void $classFileContent = $this->fileGenerator->generateDomainObjectCode($domainObject); - self::assertRegExp( - '/.*\* \@var int.*/', + self::assertMatchesRegularExpression( + '/.*\* @var int.*/', $classFileContent, 'var tag for int property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*protected \\$age = 0;.*/', $classFileContent, 'int property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function getAge\(\).*/', $classFileContent, 'Getter for int property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function setAge\(int \$age\).*/', $classFileContent, 'Setter for int property was not generated' @@ -566,24 +566,24 @@ public function writeModelClassWithNullableIntegerProperty(): void $classFileContent = $this->fileGenerator->generateDomainObjectCode($domainObject); - self::assertRegExp( - '/.*\* \@var int|null.*/', + self::assertMatchesRegularExpression( + '/.*\* @var int|null.*/', $classFileContent, 'var tag for int property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*protected \\$age = null;.*/', $classFileContent, 'int property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function getAge\(\).*/', $classFileContent, 'Getter for int property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function setAge\(\?int \$age\).*/', $classFileContent, 'Setter for int property was not generated' @@ -607,24 +607,24 @@ public function writeModelClassWithNativeDateProperty(): void $classFileContent = $this->fileGenerator->generateDomainObjectCode($domainObject); - self::assertRegExp( - '/.*\* \@var \\\\DateTime.*/', + self::assertMatchesRegularExpression( + '/.*\* @var \\\\DateTime.*/', $classFileContent, 'var tag for native date property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*protected \\$birthday = null;.*/', $classFileContent, 'native date property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function getBirthday\(\).*/', $classFileContent, 'Getter for native date property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function setBirthday\(\\\\DateTime \$birthday\).*/', $classFileContent, 'Setter for native date property was not generated' @@ -648,24 +648,24 @@ public function writeModelClassWithNativeDateTimeProperty(): void $classFileContent = $this->fileGenerator->generateDomainObjectCode($domainObject); - self::assertRegExp( - '/.*\* \@var \\\\DateTime.*/', + self::assertMatchesRegularExpression( + '/.*\* @var \\\\DateTime.*/', $classFileContent, 'var tag for native date time property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*protected \\$birthday = null;.*/', $classFileContent, 'native date time property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function getBirthday\(\).*/', $classFileContent, 'Getter for native date time property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function setBirthday\(\\\\DateTime \$birthday\).*/', $classFileContent, 'Setter for native date time property was not generated' @@ -689,24 +689,24 @@ public function writeModelClassWithNativeTimeProperty(): void $classFileContent = $this->fileGenerator->generateDomainObjectCode($domainObject); - self::assertRegExp( - '/.*\* \@var \\\\DateTime.*/', + self::assertMatchesRegularExpression( + '/.*\* @var \\\\DateTime.*/', $classFileContent, 'var tag for native time property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*protected \\$time = null;.*/', $classFileContent, 'native time property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function getTime\(\).*/', $classFileContent, 'Getter for native time property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function setTime\(\\\\DateTime \$time\).*/', $classFileContent, 'Setter for native time property was not generated' @@ -730,24 +730,24 @@ public function writeModelClassWithNoneProperty(): void $classFileContent = $this->fileGenerator->generateDomainObjectCode($domainObject); - self::assertRegExp( - '/.*\* \@var mixed.*/', + self::assertMatchesRegularExpression( + '/.*\* @var mixed.*/', $classFileContent, 'var tag for none property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*protected \\$none = null;.*/', $classFileContent, 'none property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function getNone\(\).*/', $classFileContent, 'Getter for none property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function setNone\(\$none\).*/', $classFileContent, 'Setter for none property was not generated' @@ -771,24 +771,24 @@ public function writeModelClassWithPassThroughProperty(): void $classFileContent = $this->fileGenerator->generateDomainObjectCode($domainObject); - self::assertRegExp( - '/.*\* \@var mixed.*/', + self::assertMatchesRegularExpression( + '/.*\* @var mixed.*/', $classFileContent, 'var tag for pass through property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*protected \\$passThrough = null;.*/', $classFileContent, 'pass through property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function getPassThrough\(\).*/', $classFileContent, 'Getter for pass through property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function setPassThrough\(\$passThrough\).*/', $classFileContent, 'Setter for pass through property was not generated' @@ -812,24 +812,24 @@ public function writeModelClassWithPasswordProperty(): void $classFileContent = $this->fileGenerator->generateDomainObjectCode($domainObject); - self::assertRegExp( - '/.*\* \@var string.*/', + self::assertMatchesRegularExpression( + '/.*\* @var string.*/', $classFileContent, 'var tag for password property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*protected \\$password = \'\';.*/', $classFileContent, 'password property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function getPassword\(\).*/', $classFileContent, 'Getter for password property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function setPassword\(string \$password\).*/', $classFileContent, 'Setter for password property was not generated' @@ -853,24 +853,24 @@ public function writeModelClassWithNullablePasswordProperty(): void $classFileContent = $this->fileGenerator->generateDomainObjectCode($domainObject); - self::assertRegExp( - '/.*\* \@var string|null.*/', + self::assertMatchesRegularExpression( + '/.*\* @var string|null.*/', $classFileContent, 'var tag for password property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*protected \\$password = null;.*/', $classFileContent, 'password property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function getPassword\(\).*/', $classFileContent, 'Getter for password property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function setPassword\(\?string \$password\).*/', $classFileContent, 'Setter for password property was not generated' @@ -894,24 +894,24 @@ public function writeModelClassWithRichTextProperty(): void $classFileContent = $this->fileGenerator->generateDomainObjectCode($domainObject); - self::assertRegExp( - '/.*\* \@var string.*/', + self::assertMatchesRegularExpression( + '/.*\* @var string.*/', $classFileContent, 'var tag for rich text property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*protected \\$content = \'\';.*/', $classFileContent, 'rich text property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function getContent\(\).*/', $classFileContent, 'Getter for rich text property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function setContent\(string \$content\).*/', $classFileContent, 'Setter for rich text property was not generated' @@ -935,24 +935,24 @@ public function writeModelClassWithSelectProperty(): void $classFileContent = $this->fileGenerator->generateDomainObjectCode($domainObject); - self::assertRegExp( - '/.*\* \@var int.*/', + self::assertMatchesRegularExpression( + '/.*\* @var int.*/', $classFileContent, 'var tag for select property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*protected \\$color = 0;.*/', $classFileContent, 'select property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function getColor\(\).*/', $classFileContent, 'Getter for select property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function setColor\(int \$color\).*/', $classFileContent, 'Setter for select property was not generated' @@ -976,24 +976,24 @@ public function writeModelClassWithSlugProperty(): void $classFileContent = $this->fileGenerator->generateDomainObjectCode($domainObject); - self::assertRegExp( - '/.*\* \@var string.*/', + self::assertMatchesRegularExpression( + '/.*\* @var string.*/', $classFileContent, 'var tag for slug property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*protected \\$slug = \'\';.*/', $classFileContent, 'slug property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function getSlug\(\).*/', $classFileContent, 'Getter for slug property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function setSlug\(string \$slug\).*/', $classFileContent, 'Setter for slug property was not generated' @@ -1017,24 +1017,24 @@ public function writeModelClassWithStringProperty(): void $classFileContent = $this->fileGenerator->generateDomainObjectCode($domainObject); - self::assertRegExp( - '/.*\* \@var string.*/', + self::assertMatchesRegularExpression( + '/.*\* @var string.*/', $classFileContent, 'var tag for string property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*protected \\$title = \'\';.*/', $classFileContent, 'string property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function getTitle\(\).*/', $classFileContent, 'Getter for string property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function setTitle\(string \$title\).*/', $classFileContent, 'Setter for string property was not generated' @@ -1058,24 +1058,24 @@ public function writeModelClassWithNullableStringProperty(): void $classFileContent = $this->fileGenerator->generateDomainObjectCode($domainObject); - self::assertRegExp( - '/.*\* \@var string|null.*/', + self::assertMatchesRegularExpression( + '/.*\* @var string|null.*/', $classFileContent, 'var tag for string property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*protected \\$title = null;.*/', $classFileContent, 'string property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function getTitle\(\).*/', $classFileContent, 'Getter for string property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function setTitle\(\?string \$title\).*/', $classFileContent, 'Setter for string property was not generated' @@ -1099,24 +1099,24 @@ public function writeModelClassWithTextProperty(): void $classFileContent = $this->fileGenerator->generateDomainObjectCode($domainObject); - self::assertRegExp( - '/.*\* \@var string.*/', + self::assertMatchesRegularExpression( + '/.*\* @var string.*/', $classFileContent, 'var tag for text property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*protected \\$text = \'\';.*/', $classFileContent, 'text property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function getText\(\).*/', $classFileContent, 'Getter for text property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function setText\(string \$text\).*/', $classFileContent, 'Setter for text property was not generated' @@ -1140,24 +1140,24 @@ public function writeModelClassWithNullableTextProperty(): void $classFileContent = $this->fileGenerator->generateDomainObjectCode($domainObject); - self::assertRegExp( - '/.*\* \@var string|null.*/', + self::assertMatchesRegularExpression( + '/.*\* @var string|null.*/', $classFileContent, 'var tag for text property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*protected \\$text = null;.*/', $classFileContent, 'text property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function getText\(\).*/', $classFileContent, 'Getter for text property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function setText\(\?string \$text\).*/', $classFileContent, 'Setter for text property was not generated' @@ -1181,24 +1181,24 @@ public function writeModelClassWithTimeProperty(): void $classFileContent = $this->fileGenerator->generateDomainObjectCode($domainObject); - self::assertRegExp( - '/.*\* \@var int.*/', + self::assertMatchesRegularExpression( + '/.*\* @var int.*/', $classFileContent, 'var tag for time property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*protected \\$time = 0;.*/', $classFileContent, 'time property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function getTime\(\).*/', $classFileContent, 'Getter for time property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function setTime\(int \$time\).*/', $classFileContent, 'Setter for time property was not generated' @@ -1222,24 +1222,24 @@ public function writeModelClassWithNullableTimeProperty(): void $classFileContent = $this->fileGenerator->generateDomainObjectCode($domainObject); - self::assertRegExp( - '/.*\* \@var int|null.*/', + self::assertMatchesRegularExpression( + '/.*\* @var int|null.*/', $classFileContent, 'var tag for time property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*protected \\$time = null;.*/', $classFileContent, 'time property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function getTime\(\).*/', $classFileContent, 'Getter for time property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function setTime\(\?int \$time\).*/', $classFileContent, 'Setter for time property was not generated' @@ -1263,24 +1263,24 @@ public function writeModelClassWithTimeSecProperty(): void $classFileContent = $this->fileGenerator->generateDomainObjectCode($domainObject); - self::assertRegExp( - '/.*\* \@var int.*/', + self::assertMatchesRegularExpression( + '/.*\* @var int.*/', $classFileContent, 'var tag for timeSec property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*protected \\$timeSec = 0;.*/', $classFileContent, 'timeSec property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function getTimeSec\(\).*/', $classFileContent, 'Getter for timeSec property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function setTimeSec\(int \$timeSec\).*/', $classFileContent, 'Setter for timeSec property was not generated' @@ -1304,24 +1304,24 @@ public function writeModelClassWithNullableTimeSecProperty(): void $classFileContent = $this->fileGenerator->generateDomainObjectCode($domainObject); - self::assertRegExp( - '/.*\* \@var int|null.*/', + self::assertMatchesRegularExpression( + '/.*\* @var int|null.*/', $classFileContent, 'var tag for timeSec property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*protected \\$timeSec = null;.*/', $classFileContent, 'timeSec property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function getTimeSec\(\).*/', $classFileContent, 'Getter for timeSec property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function setTimeSec\(\?int \$timeSec\).*/', $classFileContent, 'Setter for timeSec property was not generated' diff --git a/Tests/Functional/Service/FileGeneratorTest.php b/Tests/Functional/Service/FileGeneratorTest.php index 5c676a1d1..9c508213b 100755 --- a/Tests/Functional/Service/FileGeneratorTest.php +++ b/Tests/Functional/Service/FileGeneratorTest.php @@ -54,37 +54,37 @@ public function generateCodeForModelClassWithBooleanProperty(): void $classFileContent = $this->fileGenerator->generateDomainObjectCode($domainObject); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*class ModelCgt1.*/', $classFileContent, 'Class declaration was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*protected \\$blue.*/', $classFileContent, 'protected boolean property was not generated' ); - self::assertRegExp( - '/.*\* \@var bool.*/', + self::assertMatchesRegularExpression( + '/.*\* @var bool.*/', $classFileContent, 'var tag for boolean property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*\* @TYPO3\\\CMS\\\Extbase\\\Annotation\\\Validate\("NotEmpty"\).*/', $classFileContent, 'validate tag for required property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function getBlue\(\).*/', $classFileContent, 'Getter for boolean property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function setBlue\(bool \$blue\).*/', $classFileContent, 'Setter for boolean property was not generated' ); - self::assertRegExp( + self::assertMatchesRegularExpression( '/.*public function isBlue\(\).*/', $classFileContent, 'is method for boolean property was not generated' @@ -575,6 +575,6 @@ public function writeExtensionFilesOverWritesFilesWithDeprecatedExtensions(strin $extensionDir = $this->extension->getExtensionDir(); self::assertFileExists($extensionDir . 'Configuration/TypoScript/setup.' . $deprecatedExtension); - self::assertFileNotExists($extensionDir . 'Configuration/TypoScript/setup.typoscript'); + self::assertFileDoesNotExist($extensionDir . 'Configuration/TypoScript/setup.typoscript'); } } diff --git a/UnitTests.xml b/UnitTests.xml new file mode 100644 index 000000000..c78040368 --- /dev/null +++ b/UnitTests.xml @@ -0,0 +1,28 @@ + + + + + Tests/Unit/ + + + + + + Classes + + + diff --git a/composer.json b/composer.json index ca322b1aa..88c452846 100644 --- a/composer.json +++ b/composer.json @@ -35,13 +35,13 @@ "require-dev": { "friendsofphp/php-cs-fixer": "^v3.37", "roave/security-advisories": "dev-latest", - "sebastian/diff": "^5.0.3", "typo3/cms-frontend": "^12.4.11", "typo3/cms-install": "^12.4.11", "typo3/coding-standards": "v0.7.1", - "typo3/testing-framework": "^8.0.6", + "typo3/testing-framework": "^7.0.0", "ssch/typo3-rector": "^1.4", - "phpstan/phpstan": "^1.10" + "phpstan/phpstan": "^1.10", + "phpunit/phpunit": "^9.5" }, "autoload": { "psr-4": { @@ -78,7 +78,7 @@ "rm -rf crowdin.yaml", "rm -rf .php-cs-fixer.php", "rm -rf .phpstorm.meta.php" - ], + ], "post-autoload-dump": [ "@prepare-extension-test-structure" ],