diff --git a/.docker/PHP83-Dockerfile b/.docker/PHP-Dockerfile similarity index 92% rename from .docker/PHP83-Dockerfile rename to .docker/PHP-Dockerfile index 4b2ffa60..713f7e9c 100644 --- a/.docker/PHP83-Dockerfile +++ b/.docker/PHP-Dockerfile @@ -1,4 +1,4 @@ -FROM php:8.3.3-fpm +FROM php:8.3-fpm RUN apt-get update RUN apt-get --yes --no-install-recommends install \ @@ -32,7 +32,7 @@ RUN docker-php-ext-install -j$(nproc) \ COPY build/php/opcache.ini /usr/local/etc/php/conf.d/ COPY build/php/custom.ini /usr/local/etc/php/conf.d/ -RUN pecl install xdebug-3.3.1 && docker-php-ext-enable xdebug +RUN pecl install xdebug-3.4.0 && docker-php-ext-enable xdebug RUN php --version diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f5dda41b..88a2f002 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -13,7 +13,7 @@ jobs: fail-fast: false matrix: operating-system: ["ubuntu-latest"] - php: ["7.4", "8.0", "8.1", "8.2", "8.3", "8.4"] + php: ["7.4", "8.0", "8.1", "8.2", "8.3", "8.4", "8.5"] steps: - name: Checkout @@ -37,6 +37,54 @@ jobs: - name: Run tests run: vendor/bin/phpunit --no-coverage + # This does not work + # behat: + # name: Tests (Behat with PHP ${{ matrix.php }}) + # runs-on: ubuntu-latest + + # services: + # redmine-60002: + # image: redmine:6.0.2 + # ports: + # - "6002:3000" + # env: + # # Workaround: Remove secret for Rails 7.2 so it will be generated automatically + # # @see https://github.com/docker-library/redmine/issues/349#issuecomment-2516634932 + # # REDMINE_SECRET_KEY_BASE: supersecretkey + # REDMINE_PLUGINS_MIGRATE: true + # volumes: + # - /home/runner/work/_temp/redmine-60002_data/files:/usr/src/redmine/files + # - /home/runner/work/_temp/redmine-60002_data/sqlite:/usr/src/redmine/sqlite + # options: --health-cmd="wget -O /dev/null http://localhost:3000" --health-start-period=30s --health-interval=30s --health-timeout=30s --health-retries=3 + + # strategy: + # fail-fast: false + # matrix: + # operating-system: ["ubuntu-latest"] + # php: ["8.3"] + + # steps: + # - name: Checkout + # uses: actions/checkout@v4 + # with: + # fetch-depth: 2 + + # - name: Setup PHP, with composer and extensions + # uses: shivammathur/setup-php@v2 #https://github.com/shivammathur/setup-php + # with: + # php-version: ${{ matrix.php }} + # tools: phpunit + # extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite + # coverage: xdebug + + # # Install composer dependencies and handle caching in one go. + # # @link https://github.com/marketplace/actions/install-composer-dependencies + # - name: "Install Composer dependencies" + # uses: "ramsey/composer-install@v2" + + # - name: Run behat + # run: vendor/bin/behat --config tests/Behat/behat.yml --profile=github-actions --suite=redmine_60002 + code-quality: name: Check ${{ matrix.tool }} (PHP ${{ matrix.php }}) runs-on: ubuntu-latest diff --git a/CHANGELOG.md b/CHANGELOG.md index e5f2938a..89d63116 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,11 +9,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added +- Added support for PHP 8.4 +- Support for Redmine 6.0.x was added. - New class `Redmine\Http\HttpFactory` to create `Redmine\Http\Request` and `Redmine\Http\Response` instances. ### Changed -- Behaviour-driven tests are run against Redmine 5.1.4, 5.0.10 and 4.2.10. +- Behaviour-driven tests are run against Redmine 6.0.2, 5.1.4, 5.0.10. ### Deprecated @@ -25,6 +27,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `Redmine\Client\Client::getLastResponseContentType()` is deprecated, use `\Redmine\Client\Client::request()` or `\Redmine\Api\AbstractApi::getLastResponse()->getContentType()` instead. - `Redmine\Client\Client::getLastResponseBody()` is deprecated, use `\Redmine\Client\Client::request()` or `\Redmine\Api\AbstractApi::getLastResponse()->getContent()` instead. +### Removed + +- Support for Redmine 4.2.x was dropped. + ## [v2.7.0](https://github.com/kbsali/php-redmine-api/compare/v2.6.0...v2.7.0) - 2024-07-10 ### Added diff --git a/README.md b/README.md index 58564f4e..7b08a74c 100644 --- a/README.md +++ b/README.md @@ -38,9 +38,9 @@ like [Guzzle](https://github.com/guzzle/guzzle) for handling http connections We support (and run tests against) the [latest supported Redmine versions](https://www.redmine.org/projects/redmine/wiki/Download#Versions-status-and-releases-policy) that receive security updates. +- Redmine 6.0.x - Redmine 5.1.x - Redmine 5.0.x -- Redmine 4.2.x Nevertheless, you can also use this library for all older Redmine versions. In this case, however, be aware that some features might not be supported by your Redmine server. diff --git a/composer.json b/composer.json index 1a618191..abfc01db 100644 --- a/composer.json +++ b/composer.json @@ -53,9 +53,9 @@ "scripts": { "bdt": [ "Composer\\Config::disableProcessTimeout", - "@behat --format=progress --suite=redmine_50104", - "@behat --format=progress --suite=redmine_50010", - "@behat --format=progress --suite=redmine_40210" + "@behat --format=progress --suite=redmine_60002", + "@behat --format=progress --suite=redmine_50105", + "@behat --format=progress --suite=redmine_50010" ], "behat": "behat --config tests/Behat/behat.yml", "codestyle": "php-cs-fixer fix", diff --git a/docker-compose.yml b/docker-compose.yml index 88a70c35..356a582c 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,7 +2,7 @@ services: php: build: # Info to build the Docker image context: ./.docker # Specify where the Dockerfile is located (e.g. in the root directory of the project) - dockerfile: PHP83-Dockerfile # Specify the name of the Dockerfile + dockerfile: PHP-Dockerfile # Specify the name of the Dockerfile ports: - 8111:80 depends_on: @@ -11,12 +11,13 @@ services: - ./:/var/www/project/ # Location of the project for php-fpm. Note this should be the same for NGINX.* redmine-dev: - image: redmine:5.1.4 - user: "1000:1000" + image: redmine:6.0.2 ports: - "3000:3000" environment: - REDMINE_SECRET_KEY_BASE: supersecretkey + # Workaround: Remove secret for Rails 7.2 so it will be generated automatically + # @see https://github.com/docker-library/redmine/issues/349#issuecomment-2516634932 + # REDMINE_SECRET_KEY_BASE: supersecretkey REDMINE_PLUGINS_MIGRATE: true volumes: - ./.docker/redmine-dev_data/files:/usr/src/redmine/files @@ -25,40 +26,39 @@ services: # Make sure the following services are configured in: # - /tests/Behat/behat.yml - redmine-50104: - image: redmine:5.1.4 - user: "1000:1000" + redmine-60002: + image: redmine:6.0.2 ports: - - "5103:3000" + - "6002:3000" environment: - REDMINE_SECRET_KEY_BASE: supersecretkey + # Workaround: Remove secret for Rails 7.2 so it will be generated automatically + # @see https://github.com/docker-library/redmine/issues/349#issuecomment-2516634932 + # REDMINE_SECRET_KEY_BASE: supersecretkey REDMINE_PLUGINS_MIGRATE: true volumes: - - ./.docker/redmine-50104_data/files:/usr/src/redmine/files - - ./.docker/redmine-50104_data/sqlite:/usr/src/redmine/sqlite + - ./.docker/redmine-60002_data/files:/usr/src/redmine/files + - ./.docker/redmine-60002_data/sqlite:/usr/src/redmine/sqlite - redmine-50010: - image: redmine:5.0.10 + redmine-50105: + image: redmine:5.1.5 user: "1000:1000" ports: - - "5009:3000" + - "5105:3000" environment: REDMINE_SECRET_KEY_BASE: supersecretkey REDMINE_PLUGINS_MIGRATE: true volumes: - - ./.docker/redmine-50010_data/files:/usr/src/redmine/files - - ./.docker/redmine-50010_data/sqlite:/usr/src/redmine/sqlite + - ./.docker/redmine-50105_data/files:/usr/src/redmine/files + - ./.docker/redmine-50105_data/sqlite:/usr/src/redmine/sqlite - redmine-40210: - # Redmine 4.2.11 is not available on Docker Hub - # @link https://hub.docker.com/_/redmine/tags?page=&page_size=&ordering=&name=4.2.11 - image: redmine:4.2.10 + redmine-50010: + image: redmine:5.0.10 user: "1000:1000" ports: - - "4210:3000" + - "5010:3000" environment: REDMINE_SECRET_KEY_BASE: supersecretkey REDMINE_PLUGINS_MIGRATE: true volumes: - - ./.docker/redmine-40210_data/files:/usr/src/redmine/files - - ./.docker/redmine-40210_data/sqlite:/usr/src/redmine/sqlite + - ./.docker/redmine-50010_data/files:/usr/src/redmine/files + - ./.docker/redmine-50010_data/sqlite:/usr/src/redmine/sqlite diff --git a/tests/Behat/Bootstrap/FeatureContext.php b/tests/Behat/Bootstrap/FeatureContext.php index 2dd5d193..b6e25fd9 100644 --- a/tests/Behat/Bootstrap/FeatureContext.php +++ b/tests/Behat/Bootstrap/FeatureContext.php @@ -81,7 +81,7 @@ public static function clean(AfterSuiteScope $scope) */ private array $lastReturnAsArray; - public function __construct(string $redmineVersion) + public function __construct(string $redmineVersion, string $rootPath) { $version = RedmineVersion::tryFrom($redmineVersion); @@ -89,7 +89,7 @@ public function __construct(string $redmineVersion) throw new InvalidArgumentException('Redmine ' . $redmineVersion . ' is not supported.'); } - $this->redmine = static::$tracer::getRedmineInstance($version); + $this->redmine = static::$tracer::getRedmineInstance($version, $rootPath); parent::__construct('BehatRedmine' . $version->asId()); } diff --git a/tests/Behat/behat.yml b/tests/Behat/behat.yml index da16bc83..58834adf 100644 --- a/tests/Behat/behat.yml +++ b/tests/Behat/behat.yml @@ -1,22 +1,38 @@ default: suites: - redmine_50104: + default: paths: - '%paths.base%/features' + redmine_60002: contexts: - Redmine\Tests\Behat\Bootstrap\FeatureContext: - redmineVersion: '5.1.4' + redmineVersion: '6.0.2' + rootPath: '%paths.base%/../../.docker' + redmine_50105: + contexts: + - Redmine\Tests\Behat\Bootstrap\FeatureContext: + redmineVersion: '5.1.5' + rootPath: '%paths.base%/../../.docker' redmine_50010: - paths: - - '%paths.base%/features' contexts: - Redmine\Tests\Behat\Bootstrap\FeatureContext: redmineVersion: '5.0.10' - redmine_40210: - paths: - - '%paths.base%/features' + rootPath: '%paths.base%/../../.docker' + +github-actions: + suites: + redmine_60002: contexts: - Redmine\Tests\Behat\Bootstrap\FeatureContext: - redmineVersion: '4.2.10' - filters: - tags: "~@since50000" + redmineVersion: '6.0.2' + rootPath: '/home/runner/work/_temp' + redmine_50105: + contexts: + - Redmine\Tests\Behat\Bootstrap\FeatureContext: + redmineVersion: '5.1.5' + rootPath: '/home/runner/work/_temp' + redmine_50010: + contexts: + - Redmine\Tests\Behat\Bootstrap\FeatureContext: + redmineVersion: '5.0.10' + rootPath: '/home/runner/work/_temp' diff --git a/tests/Behat/features/attachments.feature b/tests/Behat/features/attachments.feature index 215b4243..26b7ad2d 100644 --- a/tests/Behat/features/attachments.feature +++ b/tests/Behat/features/attachments.feature @@ -26,7 +26,6 @@ Feature: Interacting with the REST API for attachments | id | 1 | | token | 1.7b962f8af22e26802b87abfa0b07b21dbd03b984ec8d6888dabd3f69cff162f8 | - Scenario: Updating the details of an attachment Given I have a "NativeCurlClient" client And I create a project with name "Test Project" and identifier "test-project" diff --git a/tests/Behat/features/issue.feature b/tests/Behat/features/issue.feature index a8932171..40ecb6d6 100644 --- a/tests/Behat/features/issue.feature +++ b/tests/Behat/features/issue.feature @@ -77,26 +77,17 @@ Feature: Interacting with the REST API for issues And the returned data "status" property is an array And the returned data "status" property contains "1" items And the returned data "status.@attributes" property is an array - And the returned data "status.@attributes" property has only the following properties with Redmine version ">= 5.0.0" + And the returned data "status.@attributes" property has only the following properties """ id name is_closed """ - But the returned data "status.@attributes" property has only the following properties with Redmine version "< 5.0.0" - """ - id - name - """ - And the returned data "status.@attributes" property contains the following data with Redmine version ">= 5.0.0" + And the returned data "status.@attributes" property contains the following data | property | value | | id | 1 | | name | New | | is_closed | false | - But the returned data "status.@attributes" property contains the following data with Redmine version "< 5.0.0" - | property | value | - | id | 1 | - | name | New | And the returned data "priority" property is an array And the returned data "priority" property contains "1" items And the returned data "priority.@attributes" property is an array diff --git a/tests/Behat/features/projects.feature b/tests/Behat/features/projects.feature index 63612182..8aa43b47 100644 --- a/tests/Behat/features/projects.feature +++ b/tests/Behat/features/projects.feature @@ -183,7 +183,6 @@ Feature: Interacting with the REST API for projects And the response has the content "" And the returned data is exactly "" - @since50000 Scenario: Closing a project Given I have a "NativeCurlClient" client And I create a project with name "Test Project" and identifier "test-project" @@ -197,7 +196,6 @@ Feature: Interacting with the REST API for projects | property | value | | status | 5 | - @since50000 Scenario: Reopening a project Given I have a "NativeCurlClient" client And I create a project with name "Test Project" and identifier "test-project" @@ -212,7 +210,6 @@ Feature: Interacting with the REST API for projects | property | value | | status | 1 | - @since50000 Scenario: Archiving a project Given I have a "NativeCurlClient" client And I create a project with name "Test Project" and identifier "test-project" @@ -222,7 +219,7 @@ Feature: Interacting with the REST API for projects And the response has the content "" And the returned data is true - @since50000 @error + @error Scenario: Showing an archived project is not possible Given I have a "NativeCurlClient" client And I create a project with name "Test Project" and identifier "test-project" @@ -233,7 +230,6 @@ Feature: Interacting with the REST API for projects And the response has the content "" And the returned data is false - @since50000 Scenario: Unarchiving a project Given I have a "NativeCurlClient" client And I create a project with name "Test Project" and identifier "test-project" diff --git a/tests/Behat/features/tracker.feature b/tests/Behat/features/tracker.feature index a8a888e1..ef044510 100644 --- a/tests/Behat/features/tracker.feature +++ b/tests/Behat/features/tracker.feature @@ -31,7 +31,7 @@ Feature: Interacting with the REST API for trackers And the returned data "trackers" property is an array And the returned data "trackers" property contains "2" items And the returned data "trackers.0" property is an array - And the returned data "trackers.0" property has only the following properties with Redmine version ">= 5.0.0" + And the returned data "trackers.0" property has only the following properties """ id name @@ -39,13 +39,6 @@ Feature: Interacting with the REST API for trackers description enabled_standard_fields """ - But the returned data "trackers.0" property has only the following properties with Redmine version "< 5.0.0" - """ - id - name - default_status - description - """ And the returned data "trackers.0" property contains the following data | property | value | | id | 1 | diff --git a/tests/Behat/features/user.feature b/tests/Behat/features/user.feature index b1562081..07ccc515 100644 --- a/tests/Behat/features/user.feature +++ b/tests/Behat/features/user.feature @@ -120,7 +120,7 @@ Feature: Interacting with the REST API for users And the returned data "users" property is an array And the returned data "users" property contains "2" items And the returned data "users.0" property is an array - And the returned data "users.0" property has only the following properties + And the returned data "users.0" property has only the following properties with Redmine version ">= 6.0.0" """ id login @@ -133,8 +133,33 @@ Feature: Interacting with the REST API for users last_login_on passwd_changed_on twofa_scheme + status + """ + But the returned data "users.0" property has only the following properties with Redmine version "< 6.0.0" """ - And the returned data "users.0" property contains the following data + id + login + admin + firstname + lastname + mail + created_on + updated_on + last_login_on + passwd_changed_on + twofa_scheme + """ + And the returned data "users.0" property contains the following data with Redmine version ">= 6.0.0" + | property | value | + | id | 1 | + | login | admin | + | admin | true | + | firstname | Redmine | + | lastname | Admin | + | mail | admin@example.net | + | twofa_scheme | null | + | status | 1 | + But the returned data "users.0" property contains the following data with Redmine version "< 6.0.0" | property | value | | id | 1 | | login | admin | @@ -144,7 +169,7 @@ Feature: Interacting with the REST API for users | mail | admin@example.net | | twofa_scheme | null | And the returned data "users.1" property is an array - And the returned data "users.1" property has only the following properties + And the returned data "users.1" property has only the following properties with Redmine version ">= 6.0.0" """ id login @@ -157,8 +182,33 @@ Feature: Interacting with the REST API for users last_login_on passwd_changed_on twofa_scheme + status + """ + But the returned data "users.1" property has only the following properties with Redmine version "< 6.0.0" """ - And the returned data "users.1" property contains the following data + id + login + admin + firstname + lastname + mail + created_on + updated_on + last_login_on + passwd_changed_on + twofa_scheme + """ + And the returned data "users.1" property contains the following data with Redmine version ">= 6.0.0" + | property | value | + | id | 5 | + | login | username | + | admin | false | + | firstname | first | + | lastname | last | + | mail | mail@example.net | + | twofa_scheme | null | + | status | 1 | + And the returned data "users.1" property contains the following data with Redmine version "< 6.0.0" | property | value | | id | 5 | | login | username | diff --git a/tests/Behat/features/version.feature b/tests/Behat/features/version.feature index 263fd7e0..463dd4df 100644 --- a/tests/Behat/features/version.feature +++ b/tests/Behat/features/version.feature @@ -162,7 +162,6 @@ Feature: Interacting with the REST API for versions | id | 1 | | name | Test Project | - @wip Scenario: Listing of multiple version names Given I have a "NativeCurlClient" client And I create a project with name "Test Project 1" and identifier "test-project-1" diff --git a/tests/RedmineExtension/BehatHookTracer.php b/tests/RedmineExtension/BehatHookTracer.php index bb916de1..04215442 100644 --- a/tests/RedmineExtension/BehatHookTracer.php +++ b/tests/RedmineExtension/BehatHookTracer.php @@ -22,14 +22,14 @@ final class BehatHookTracer implements InstanceRegistration */ private static array $instances = []; - public static function getRedmineInstance(RedmineVersion $redmineVersion): RedmineInstance + public static function getRedmineInstance(RedmineVersion $redmineVersion, string $rootPath): RedmineInstance { if (static::$tracer === null) { throw new RuntimeException('You can only get a Redmine instance while a Behat Suite is running.'); } if (! array_key_exists($redmineVersion->asId(), static::$instances)) { - RedmineInstance::create(static::$tracer, $redmineVersion); + RedmineInstance::create(static::$tracer, $redmineVersion, $rootPath); } return static::$instances[$redmineVersion->asId()]; diff --git a/tests/RedmineExtension/RedmineInstance.php b/tests/RedmineExtension/RedmineInstance.php index fcb5b578..547917b7 100644 --- a/tests/RedmineExtension/RedmineInstance.php +++ b/tests/RedmineExtension/RedmineInstance.php @@ -7,22 +7,23 @@ use DateTimeImmutable; use InvalidArgumentException; use PDO; +use SQLite3; final class RedmineInstance { /** * @param InstanceRegistration $tracer Required to ensure that RedmineInstance is created while Test Runner is running */ - public static function create(InstanceRegistration $tracer, RedmineVersion $version): void + public static function create(InstanceRegistration $tracer, RedmineVersion $version, string $rootPath): void { - $tracer->registerInstance(new self($tracer, $version)); + $tracer->registerInstance(new self($tracer, $version, $rootPath)); } private InstanceRegistration $tracer; private RedmineVersion $version; - private string $rootPath; + private string $dataPath; private string $workingDB; @@ -40,14 +41,19 @@ public static function create(InstanceRegistration $tracer, RedmineVersion $vers private string $apiKey; - private function __construct(InstanceRegistration $tracer, RedmineVersion $version) + private function __construct(InstanceRegistration $tracer, RedmineVersion $version, string $rootPath) { $this->tracer = $tracer; $this->version = $version; $versionId = strval($version->asId()); - $this->rootPath = dirname(__FILE__, 3) . '/.docker/redmine-' . $versionId . '_data/'; + // Default to .docker folder + if ($rootPath === '') { + $rootPath = dirname(__FILE__, 3) . '/.docker'; + } + + $this->dataPath = $rootPath . '/redmine-' . $versionId . '_data/'; $this->workingDB = 'sqlite/redmine.db'; $this->migratedDB = 'sqlite/redmine-migrated.db'; @@ -107,10 +113,10 @@ private function runHealthChecks(RedmineVersion $version): void )); } - if (! file_exists($this->rootPath . $this->workingDB)) { + if (! file_exists($this->dataPath . $this->workingDB)) { throw new InvalidArgumentException(sprintf( 'Could not find database file in %s, please make sure that Redmine %s has a docker service in /docker-composer.yml and is correctly configured in /tests/Behat/behat.yml.', - $this->rootPath . $this->workingDB, + $this->dataPath . $this->workingDB, $version->asString(), )); } @@ -143,9 +149,9 @@ public function shutdown(InstanceRegistration $tracer): void /** * Allows tests to prepare the database */ - public function excecuteDatabaseQuery(string $query, array $options = [], array $params = null): void + public function excecuteDatabaseQuery(string $query, array $options = [], ?array $params = null): void { - $pdo = new PDO('sqlite:' . $this->rootPath . $this->workingDB); + $pdo = new PDO('sqlite:' . $this->dataPath . $this->workingDB); $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $stmt = $pdo->prepare($query, $options); @@ -155,7 +161,7 @@ public function excecuteDatabaseQuery(string $query, array $options = [], array private function runDatabaseMigration() { $now = new DateTimeImmutable(); - $pdo = new PDO('sqlite:' . $this->rootPath . $this->workingDB); + $pdo = new PDO('sqlite:' . $this->dataPath . $this->workingDB); // Get admin user to check sqlite connection $stmt = $pdo->prepare('SELECT * FROM users WHERE login = :login;'); @@ -190,7 +196,14 @@ private function runDatabaseMigration() */ private function createDatabaseBackup() { - copy($this->rootPath . $this->workingDB, $this->rootPath . $this->backupDB); + $workingDB = new SQLite3($this->dataPath . $this->workingDB); + + $backupDB = new SQLite3($this->dataPath . $this->backupDB); + + $workingDB->backup($backupDB); + + $workingDB->close(); + $backupDB->close(); } /** @@ -198,33 +211,54 @@ private function createDatabaseBackup() */ private function saveMigratedDatabase() { - copy($this->rootPath . $this->workingDB, $this->rootPath . $this->migratedDB); + $workingDB = new SQLite3($this->dataPath . $this->workingDB); + + $migratedDB = new SQLite3($this->dataPath . $this->migratedDB); + + $workingDB->backup($migratedDB); + + $workingDB->close(); + $migratedDB->close(); } private function restoreFromMigratedDatabase(): void { - copy($this->rootPath . $this->migratedDB, $this->rootPath . $this->workingDB); + $workingDB = new SQLite3($this->dataPath . $this->workingDB); + + $migratedDB = new SQLite3($this->dataPath . $this->migratedDB); + + $migratedDB->backup($workingDB); + + $workingDB->close(); + $migratedDB->close(); } private function restoreDatabaseFromBackup(): void { - copy($this->rootPath . $this->backupDB, $this->rootPath . $this->workingDB); + $workingDB = new SQLite3($this->dataPath . $this->workingDB); + + $backupDB = new SQLite3($this->dataPath . $this->backupDB); + + $backupDB->backup($workingDB); + + $workingDB->close(); + $backupDB->close(); } private function removeDatabaseBackups(): void { - unlink($this->rootPath . $this->migratedDB); - unlink($this->rootPath . $this->backupDB); + unlink($this->dataPath . $this->migratedDB); + unlink($this->dataPath . $this->backupDB); } private function createFilesBackup() { // Add an empty file to avoid warnings about copying and removing content from an empty folder - touch($this->rootPath . $this->workingFiles . 'empty'); + touch($this->dataPath . $this->workingFiles . 'empty'); exec(sprintf( 'cp -r %s %s', - $this->rootPath . $this->workingFiles, - $this->rootPath . rtrim($this->backupFiles, '/'), + $this->dataPath . $this->workingFiles, + $this->dataPath . rtrim($this->backupFiles, '/'), )); } @@ -232,8 +266,8 @@ private function saveMigratedFiles() { exec(sprintf( 'cp -r %s %s', - $this->rootPath . $this->workingFiles, - $this->rootPath . rtrim($this->migratedFiles, '/'), + $this->dataPath . $this->workingFiles, + $this->dataPath . rtrim($this->migratedFiles, '/'), )); } @@ -241,13 +275,13 @@ private function restoreFromMigratedFiles(): void { exec(sprintf( 'rm -r %s', - $this->rootPath . $this->workingFiles . '*', + $this->dataPath . $this->workingFiles . '*', )); exec(sprintf( 'cp -r %s %s', - $this->rootPath . $this->migratedFiles . '*', - $this->rootPath . rtrim($this->workingFiles, '/'), + $this->dataPath . $this->migratedFiles . '*', + $this->dataPath . rtrim($this->workingFiles, '/'), )); } @@ -255,13 +289,13 @@ private function restoreFilesFromBackup(): void { exec(sprintf( 'rm -r %s', - $this->rootPath . $this->workingFiles . '*', + $this->dataPath . $this->workingFiles . '*', )); exec(sprintf( 'cp -r %s %s', - $this->rootPath . $this->backupFiles . '*', - $this->rootPath . rtrim($this->workingFiles, '/'), + $this->dataPath . $this->backupFiles . '*', + $this->dataPath . rtrim($this->workingFiles, '/'), )); } @@ -269,10 +303,10 @@ private function removeFilesBackups(): void { exec(sprintf( 'rm -r %s %s', - $this->rootPath . $this->migratedFiles, - $this->rootPath . $this->backupFiles, + $this->dataPath . $this->migratedFiles, + $this->dataPath . $this->backupFiles, )); - unlink($this->rootPath . $this->workingFiles . 'empty'); + unlink($this->dataPath . $this->workingFiles . 'empty'); } } diff --git a/tests/RedmineExtension/RedmineVersion.php b/tests/RedmineExtension/RedmineVersion.php index 2278bb08..13f3f6d8 100644 --- a/tests/RedmineExtension/RedmineVersion.php +++ b/tests/RedmineExtension/RedmineVersion.php @@ -6,6 +6,38 @@ enum RedmineVersion: string { + /** + * Redmine 6.0.2 + * + * @link https://www.redmine.org/versions/202 + * @link https://www.redmine.org/projects/redmine/wiki/Changelog_6_0#602-2024-12-11 + */ + case V6_0_2 = '6.0.2'; + + /** + * Redmine 6.0.1 + * + * @link https://www.redmine.org/versions/201 + * @link https://www.redmine.org/projects/redmine/wiki/Changelog_6_0#601-2024-11-12 + */ + case V6_0_1 = '6.0.1'; + + /** + * Redmine 6.0.0 + * + * @link https://www.redmine.org/versions/175 + * @link https://www.redmine.org/projects/redmine/wiki/Changelog_6_0#600-2024-11-10 + */ + case V6_0_0 = '6.0.0'; + + /** + * Redmine 5.1.5 + * + * @link https://www.redmine.org/versions/199 + * @link https://www.redmine.org/projects/redmine/wiki/Changelog_5_1#515-2024-12-11 + */ + case V5_1_5 = '5.1.5'; + /** * Redmine 5.1.4 * @@ -47,22 +79,22 @@ enum RedmineVersion: string case V5_1_0 = '5.1.0'; /** - * Redmine 5.0.9 + * Redmine 5.0.10 * - * @link https://www.redmine.org/versions/194 - * @link https://www.redmine.org/projects/redmine/wiki/Changelog_5_0#509-2024-06-11 + * @link https://www.redmine.org/versions/196 + * @link https://www.redmine.org/projects/redmine/wiki/Changelog_5_0#5010-2024-11-03 */ - case V5_0_9 = '5.0.9'; + case V5_0_10 = '5.0.10'; /** - * Redmine 5.0.10 + * Redmine 5.0.9 * - * @link https://www.redmine.org/versions/196 - * @link https://www.redmine.org/projects/redmine/wiki/Changelog_5_0#5010-2024-11-03 + * @link https://www.redmine.org/versions/194 + * @link https://www.redmine.org/projects/redmine/wiki/Changelog_5_0#509-2024-06-11 */ - case V5_0_10 = '5.0.10'; + case V5_0_9 = '5.0.9'; /** * Redmine 5.0.8