diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..a2e0f86 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,55 @@ +# This is a basic workflow to help you get started with Actions + +name: CI + +# Controls when the action will run. +on: + # Triggers the workflow on push or pull request events but only for the master branch + push: + branches: + - master + - maintaina-composerfixed + - FRAMEWORK_6_0 + pull_request: + branches: + - master + - maintaina-composerfixed + - FRAMEWORK_6_0 + + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + run: + runs-on: ${{ matrix.operating-system }} + strategy: + matrix: + operating-system: ['ubuntu-20.04'] + php-versions: ['7.4', '8.0', '8.1', 'latest'] + phpunit-versions: ['latest', '9.5'] + steps: + - name: Setup github ssh key + run: mkdir -p ~/.ssh/ && ssh-keyscan -t rsa github.com > ~/.ssh/known_hosts + - name: Checkout + uses: actions/checkout@v2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + extensions: bcmath, ctype, curl, dom, gd, gettext, iconv, imagick, json, ldap, mbstring, mysql, opcache, openssl, pcntl, pdo, posix, redis, soap, sockets, sqlite, tokenizer, xmlwriter + ini-values: post_max_size=512M, max_execution_time=360 + coverage: xdebug + tools: php-cs-fixer, phpunit:${{ matrix.phpunit-versions }}, composer:v2 + - name: Setup Github Token as composer credential + run: composer config -g github-oauth.github.com ${{ secrets.GITHUB_TOKEN }} + - name: Install horde/test dependency and other dependencies + run: | + ## For unclear reasons, github action fails randomly if we do not install before we require. + COMPOSER_ROOT_VERSION=dev-FRAMEWORK_6_0 composer config minimum-stability dev + COMPOSER_ROOT_VERSION=dev-FRAMEWORK_6_0 composer config allow-plugins true + COMPOSER_ROOT_VERSION=dev-FRAMEWORK_6_0 composer install + - name: run phpunit + run: phpunit --bootstrap test/bootstrap.php diff --git a/.github/workflows/phpdoc.yml b/.github/workflows/phpdoc.yml new file mode 100644 index 0000000..365812f --- /dev/null +++ b/.github/workflows/phpdoc.yml @@ -0,0 +1,69 @@ +# This is a basic workflow to help you get started with Actions + +name: PHPDOC + +# Controls when the action will run. +on: + # Triggers the workflow on push or pull request events but only for the master branch + push: + branches: + - master + - maintaina-composerfixed + - FRAMEWORK_6_0 + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + run: + runs-on: ubuntu-20.04 + steps: + - name: Setup github ssh key + run: mkdir -p ~/.ssh/ && ssh-keyscan -t rsa github.com > ~/.ssh/known_hosts + - name: Setup uut dir + run: | + export REPO=$(echo "$GITHUB_REPOSITORY" | awk -F / '{print $2}' | sed -e "s/:refs//") + export UUT_DIR=$(pwd) + export WORK_DIR=~ + export BIN_DIR="${WORK_DIR}/bin" + mkdir -p $BIN_DIR + git config --global user.name "PHPDOC CI Job" + git config --global user.email "ci-job@maintaina.com" + - name: Checkout + uses: actions/checkout@v2 + - name: Checkout Doc Dir + uses: actions/checkout@v2 + with: + repository: maintaina/phpdoc + token: ${{secrets.PHPDOC_TOKEN}} + path: "phpdoc-git" + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 7.4 + extensions: bcmath, ctype, curl, dom, gd, gettext, iconv, imagick, json, ldap, mbstring, mysql, opcache, openssl, pcntl, pdo, posix, redis, soap, sockets, sqlite, tokenizer, xmlwriter + ini-values: post_max_size=512M, max_execution_time=360 + coverage: xdebug + tools: composer:v2 + - name: Setup Github Token as composer credential + run: composer config -g github-oauth.github.com ${{ secrets.GITHUB_TOKEN }} + - name: phpdocumentor run + run: | + export UUT_DIR=$(pwd) + export REPO=$(echo "$GITHUB_REPOSITORY" | awk -F / '{print $2}' | sed -e "s/:refs//") + export WORK_DIR=/home/runner/ + export BIN_DIR="${WORK_DIR}/bin" + wget https://phpdoc.org/phpDocumentor.phar + mkdir "${WORK_DIR}/phpdoc-out" + mv phpDocumentor.phar $BIN_DIR/phpdocumentor + chmod +x "${BIN_DIR}/phpdocumentor" + echo "Creating UUT related dir in docu repo" + mkdir -p $UUT_DIR/phpdoc-git/${GITHUB_REF##*/}/${REPO}/ + ## Look into any of lib, src, app (if they exist) but not test, migration, bin, locale or script dirs + $BIN_DIR/phpdocumentor -d $UUT_DIR/lib/ -d $UUT_DIR/src/ -d $UUT_DIR/app/ -t "${UUT_DIR}/phpdoc-git/${GITHUB_REF##*/}/${REPO}/" + cd ${UUT_DIR}/phpdoc-git + git add "${GITHUB_REF##*/}/${REPO}" + php indexer.php ${GITHUB_REF##*/} $REPO + git add index.html index.json + git commit -m "Updated phpdoc for $GITHUB_REPOSITORY (${GITHUB_REF##*/} branch) from ci" + git push diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..784f8fe --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,63 @@ +--- +name: make release + +# manual workflow to make a new release for the default branch +on: + workflow_dispatch: + branches: + - FRAMEWORK_6_0 +env: + components: "/home/runner/.composer/web/components/bin/horde-components -c /home/runner/.composer/web/components/config/maintaina.conf.dist" + +jobs: + run: + runs-on: ${{ matrix.operating-system }} + strategy: + matrix: + operating-system: ['ubuntu-20.04'] + php-versions: ['7.4'] + steps: + - name: Setup git + run: | + mkdir -p ~/.ssh/ && ssh-keyscan -t rsa github.com > ~/.ssh/known_hosts + git config --global user.name "Github CI Runner" + git config --global user.email "ci-job@maintaina.com" + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 0 + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php-versions }} + extensions: gettext + ini-values: post_max_size=512M, max_execution_time=360 + tools: composer:v2 + - name: Setup composer + run: | + composer config -g github-oauth.github.com ${{ secrets.GITHUB_TOKEN }} + composer global config repositories.0 composer https://horde-satis.maintaina.com + composer global config minimum-stability dev + composer config --no-plugins --global allow-plugins true + composer global require horde/components "dev-FRAMEWORK_6_0" + - name: write changelog + run: | + entries_amount=0; max_entries=100 + PATTERN="^\[.*\] .*" + + for commit in $(git rev-list FRAMEWORK_6_0) + do + msg=$(git log --format=%B -n 1 $commit | head -n 1) + if [ $entries_amount -gt $max_entries ]; then break; fi + if [[ $msg == 'Released'* ]]; then break; fi + if [[ $msg == 'Development mode for'* ]]; then break; fi + if [[ $msg =~ $PATTERN ]]; then + $components changed "$msg" + let "entries_amount+=1" + fi + done + - name: make release and push + run: | + $components release for maintaina + git push + git push origin --tags diff --git a/.github/workflows/update-satis.yml b/.github/workflows/update-satis.yml new file mode 100644 index 0000000..e105aae --- /dev/null +++ b/.github/workflows/update-satis.yml @@ -0,0 +1,60 @@ +# This is a basic workflow to help you get started with Actions + +name: Update Satis + +# Controls when the action will run. +on: + # Triggers the workflow on push or pull request events but only for the master branch + push: + branches: + - FRAMEWORK_6_0 + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + run: + runs-on: ubuntu-20.04 + steps: + - name: Setup github ssh key + run: mkdir -p ~/.ssh/ && ssh-keyscan -t rsa github.com > ~/.ssh/known_hosts + - name: Setup uut dir + run: | + export REPO=$(echo "$GITHUB_REPOSITORY" | awk -F / '{print $2}' | sed -e "s/:refs//") + export UUT_DIR=$(pwd) + export WORK_DIR=~ + export BIN_DIR="${WORK_DIR}/bin" + mkdir -p $BIN_DIR + git config --global user.name "Satis Repository CI Job" + git config --global user.email "ci-job@maintaina.com" + - name: Checkout + uses: actions/checkout@v2 + - name: Checkout satis web dir + uses: actions/checkout@v2 + with: + repository: maintaina-com/maintaina-com.github.io + token: ${{secrets.PHPDOC_TOKEN}} + path: "maintaina-com.github.io" + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: 7.4 + extensions: bcmath, ctype, curl, dom, gd, gettext, iconv, imagick, json, ldap, mbstring, mysql, opcache, openssl, pcntl, pdo, posix, redis, soap, sockets, sqlite, tokenizer, xmlwriter + ini-values: post_max_size=512M, max_execution_time=3600 + coverage: xdebug + tools: composer:v2 + - name: Setup Github Token as composer credential + run: composer config -g github-oauth.github.com ${{ secrets.GITHUB_TOKEN }} + - name: Run Satis + run: | + export UUT_DIR=$(pwd) + export REPO=$(echo "$GITHUB_REPOSITORY" | awk -F / '{print $2}' | sed -e "s/:refs//") + export WORK_DIR=/home/runner/ + export BIN_DIR="${WORK_DIR}/bin" + composer create-project composer/satis:dev-main + composer global config --no-plugins allow-plugins true + php satis/bin/satis build -vvv maintaina-com.github.io/satis.json maintaina-com.github.io/ horde/${REPO,,} + cd maintaina-com.github.io + git add include/ index.html p2/ packages.json + git commit -m "Update for horde/${REPO,,}" + git push diff --git a/.gitignore b/.gitignore index 4e78ae3..3a7a91f 100644 --- a/.gitignore +++ b/.gitignore @@ -27,3 +27,10 @@ run-tests.log /test/*/*/*/*.log /test/*/*/*/*.out +# Ignore test harness / quality tools output +.php-cs-fixer.cache +.phpunit.cache/ + +# ignore composer artifacts +composer.lock +vendor/ diff --git a/.horde.yml b/.horde.yml index c377e95..c3c2ed5 100644 --- a/.horde.yml +++ b/.horde.yml @@ -20,24 +20,29 @@ authors: active: false role: lead version: - release: 2.4.2 - api: 2.4.0 + release: 3.0.0alpha5 + api: 3.0.0alpha1 state: - release: stable - api: stable + release: alpha + api: alpha license: - identifier: LGPL-2.1 + identifier: LGPL-2.1-only uri: http://www.horde.org/licenses/lgpl21 dependencies: required: - php: ^5.3 || ^7 - pear: - pear.horde.org/Horde_Exception: ^2 - pear.horde.org/Horde_Nls: ^2 - pear.horde.org/Horde_Translation: ^2.2 + php: ^7.4 || ^8 + composer: + horde/exception: ^3 + horde/nls: ^3 + horde/translation: ^3 optional: - pear: - pear.horde.org/Horde_Icalendar: ^2 - pear.horde.org/Horde_Test: ^2.1 + composer: + horde/icalendar: ^3 + ext: + calendar: '*' + dev: + composer: + horde/icalendar: ^3 + horde/test: ^3 ext: calendar: '*' diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php new file mode 100644 index 0000000..e3aa45a --- /dev/null +++ b/.php-cs-fixer.dist.php @@ -0,0 +1,25 @@ +exclude('lib') + // doc may contain ancient examples or illustrational shorthand + ->exclude('doc') + ->notPath('src/Symfony/Component/Translation/Tests/fixtures/resources.php') + ->in(__DIR__) +; + +$config = new PhpCsFixer\Config(); +return $config->setRules([ + '@PSR12' => true, + '@PHP81Migration' => true, + 'ordered_imports' => true, + 'strict_param' => true, + 'declare_strict_types' => true, + 'method_argument_space' => true, + 'array_syntax' => ['syntax' => 'short'], + ]) + ->setFinder($finder)->setFormat('txt')->setRiskyAllowed(true); +; diff --git a/composer.json b/composer.json index 1563dab..c496501 100644 --- a/composer.json +++ b/composer.json @@ -3,7 +3,7 @@ "description": "Date library", "type": "library", "homepage": "https://www.horde.org/libraries/Horde_Date", - "license": "LGPL-2.1", + "license": "LGPL-2.1-only", "authors": [ { "name": "Jan Schneider", @@ -16,32 +16,43 @@ "role": "lead" } ], - "version": "2.4.2", - "time": "2017-11-11", + "time": "2022-10-10", "repositories": [ { - "type": "pear", - "url": "https://pear.horde.org" + "type": "composer", + "url": "https://horde-satis.maintaina.com" } ], "require": { - "php": "^5.3 || ^7", - "pear-pear.horde.org/Horde_Exception": "^2", - "pear-pear.horde.org/Horde_Nls": "^2", - "pear-pear.horde.org/Horde_Translation": "^2.2" + "php": "^7.4 || ^8", + "horde/exception": "^3 || dev-FRAMEWORK_6_0", + "horde/nls": "^3 || dev-FRAMEWORK_6_0", + "horde/translation": "^3 || dev-FRAMEWORK_6_0" }, - "suggest": { - "pear-pear.horde.org/Horde_Icalendar": "^2", - "pear-pear.horde.org/Horde_Test": "^2.1", + "require-dev": { + "horde/icalendar": "^3 || dev-FRAMEWORK_6_0", + "horde/test": "^3 || dev-FRAMEWORK_6_0", "ext-calendar": "*" }, - "replace": { - "pear-pear.horde.org/Horde_Date": "2.*", - "pear-horde/Horde_Date": "2.*" + "suggest": { + "horde/icalendar": "^3 || dev-FRAMEWORK_6_0", + "horde/test": "^3 || dev-FRAMEWORK_6_0", + "ext-calendar": "*" }, "autoload": { "psr-0": { "Horde_Date": "lib/" } - } + }, + "autoload-dev": { + "psr-4": { + "Horde\\Date\\Test\\": "test/" + } + }, + "config": { + "allow-plugins": { + "horde/horde-installer-plugin": true + } + }, + "minimum-stability": "dev" } diff --git a/doc/Horde/Date/CHANGES b/doc/Horde/Date/CHANGES index 50ac84b..23e9037 100644 --- a/doc/Horde/Date/CHANGES +++ b/doc/Horde/Date/CHANGES @@ -1,3 +1,37 @@ +------------ +v3.0.0alpha5 +------------ + + + + +------------ +v3.0.0alpha4 +------------ + +[rla] Fix some PHP 8.1 issues. +|+ + + +------------ +v3.0.0alpha3 +------------ + +|+ + +------------ +v3.0.0alpha2 +------------ + +|+ + +------------ +v3.0.0alpha1 +------------ + +[rla] Begin conversion for composer usage. + + ------ v2.4.2 ------ @@ -6,7 +40,6 @@ v2.4.2 #14768). - ------ v2.4.1 ------ diff --git a/doc/Horde/Date/changelog.yml b/doc/Horde/Date/changelog.yml index b6f982d..4f98f7f 100644 --- a/doc/Horde/Date/changelog.yml +++ b/doc/Horde/Date/changelog.yml @@ -1,4 +1,58 @@ --- +3.0.0alpha5: + api: 3.0.0alpha1 + state: + release: alpha + api: alpha + date: 2022-10-08 + license: + identifier: LGPL-2.1 + uri: http://www.horde.org/licenses/lgpl21 + notes: |+ + +3.0.0alpha4: + api: 3.0.0alpha1 + state: + release: alpha + api: alpha + date: 2022-10-08 + license: + identifier: LGPL-2.1 + uri: http://www.horde.org/licenses/lgpl21 + notes: | + [rla] Fix some PHP 8.1 issues. + |+ +3.0.0alpha3: + api: 3.0.0alpha1 + state: + release: alpha + api: alpha + date: 2021-03-13 + license: + identifier: LGPL-2.1 + uri: http://www.horde.org/licenses/lgpl21 + notes: |+ +3.0.0alpha2: + api: 3.0.0alpha1 + state: + release: alpha + api: alpha + date: 2021-02-24 + license: + identifier: LGPL-2.1 + uri: http://www.horde.org/licenses/lgpl21 + notes: |+ +3.0.0alpha1: + api: 3.0.0alpha1 + state: + release: stable + api: stable + date: 2021-02-24 + license: + identifier: LGPL-2.1 + uri: http://www.horde.org/licenses/lgpl21 + notes: | + [rla] Begin conversion for composer usage. 2.4.2: api: 2.4.0 state: @@ -8,9 +62,8 @@ license: identifier: LGPL-2.1 uri: http://www.horde.org/licenses/lgpl21 - notes: |+ + notes: | [jan] Allow passing a time format to Horde_Date_Recurrence#toString() (Bug #14768). - 2.4.1: api: 2.4.0 state: diff --git a/lib/Horde/Date.php b/lib/Horde/Date.php index 2b267f3..f8bccbf 100644 --- a/lib/Horde/Date.php +++ b/lib/Horde/Date.php @@ -555,7 +555,7 @@ public function __toString() public function toDateTime() { try { - $date = new DateTime(null, new DateTimeZone($this->_timezone)); + $date = new DateTime('now', new DateTimeZone($this->_timezone)); $date->setDate($this->_year, $this->_month, $this->_mday); $date->setTime($this->_hour, $this->_min, $this->_sec); } catch (Exception $e) { @@ -824,6 +824,13 @@ public static function getTimezoneAlias($timezone) $timezone = reset(self::$_timezoneAbbreviations[$lower]); $timezone = $timezone['timezone_id']; } + + // Map timezones of the form `GMT-0800` + // (which sometimes appear in events imported from airplane flights). + // to corresponding Olson names. + if (preg_match('/^GMT([+-])(\d\d)00$/', $timezone, $matches)) + $timezone = 'Etc/GMT' . $matches[1] . ltrim($matches[2], '0'); + return $timezone; } diff --git a/lib/Horde/Date/Utils.php b/lib/Horde/Date/Utils.php index fd76244..4321de7 100644 --- a/lib/Horde/Date/Utils.php +++ b/lib/Horde/Date/Utils.php @@ -135,7 +135,7 @@ public static function relativeDateTime($time, $date_format = '%x', */ public static function strftime2date($format) { - $replace = array( + $replace = [ '/%a/' => 'D', '/%A/' => 'l', '/%d/' => 'd', @@ -151,7 +151,7 @@ public static function strftime2date($format) '/%h/' => 'M', '/%m/' => 'm', '/%C/' => '', - '/%g/' => '', + '/%g/' => 'y', '/%G/' => 'o', '/%y/' => 'y', '/%Y/' => 'Y', @@ -165,20 +165,52 @@ public static function strftime2date($format) '/%R/' => 'H:i', '/%S/' => 's', '/%T/' => 'H:i:s', - '/%X/e' => 'Horde_Date_Utils::strftime2date(Horde_Nls::getLangInfo(T_FMT))', '/%z/' => 'O', '/%Z/' => '', '/%c/' => '', '/%D/' => 'm/d/y', '/%F/' => 'Y-m-d', '/%s/' => 'U', - '/%x/e' => 'Horde_Date_Utils::strftime2date(Horde_Nls::getLangInfo(D_FMT))', '/%n/' => "\n", '/%t/' => "\t", '/%%/' => '%' - ); + ]; + + $callbackPatterns = [ + '/%X/' => function() { return Horde_Nls::getLangInfo(T_FMT); }, + '/%x/' => function() { return Horde_Nls::getLangInfo(D_FMT); }, + ]; - return preg_replace(array_keys($replace), array_values($replace), $format); + $pass1 = preg_replace_callback_array($callbackPatterns, $format); + $pass2 = preg_replace(array_keys($replace), array_values($replace), $pass1); + return $pass2; } + /** + * Unify date formatters and then format the date. + * + * Facilitates upgrades from strftime to date_format style placeholders by accepting both. + * Some formats are not supported and will be dropped + * Will produce undesirable results for date_format style format strings that contain % characters + * + * @param string $pattern A date/time format pattern either in strftime or date_format style + * @param string|Horde_Date|DateTimeInterface $date + * @return void + */ + public static function legacyDateFormatter( + string $pattern = 'Y-m-d H:i:s', + Horde_Date|DateTimeInterface|int|string|null $date = 'now', + $timezone = null + ) + { + if (is_null($date) || $date === 'now') { + $date = new Horde_Date(time(), $timezone); + } elseif (is_object($date) && $date instanceof DateTimeInterface) { + $timezone = $timezone ?? $date->getTimezone()->getName(); + $date = new Horde_Date($date, $timezone); + } elseif (is_int($date) || is_string($date)) { + $date = new Horde_Date($date, $timezone ?? 'UTC'); + } + return $date->format(self::strftime2date($pattern)); + } } diff --git a/package.xml b/package.xml index 168e5cd..758e9c0 100644 --- a/package.xml +++ b/package.xml @@ -3,7 +3,7 @@ Horde_Date pear.horde.org Date library - Package for creating and manipulating dates. + A library for creating and manipulating dates. Jan Schneider jan @@ -14,23 +14,30 @@ Chuck Hagenbuch chuck chuck@horde.org - yes + no - 2017-11-11 + 2022-10-08 - 2.4.2 - 2.4.0 + 3.0.0alpha5 + 3.0.0alpha1 - stable - stable + alpha + alpha - LGPL-2.1 + LGPL-2.1-only -* [jan] Allow passing a time format to Horde_Date_Recurrence#toString() (Bug #14768). +* + + + + + + + @@ -322,6 +329,7 @@ + @@ -349,50 +357,15 @@ - 5.3.0 - 8.0.0alpha1 - 8.0.0alpha1 + 7.4.0 + 9.0.0alpha1 + 9.0.0alpha1 1.7.0 - - Horde_Exception - pear.horde.org - 2.0.0 - 3.0.0alpha1 - 3.0.0alpha1 - - - Horde_Nls - pear.horde.org - 2.0.0 - 3.0.0alpha1 - 3.0.0alpha1 - - - Horde_Translation - pear.horde.org - 2.2.0 - 3.0.0alpha1 - 3.0.0alpha1 - - - Horde_Icalendar - pear.horde.org - 2.0.0 - 3.0.0alpha1 - 3.0.0alpha1 - - - Horde_Test - pear.horde.org - 2.1.0 - 3.0.0alpha1 - 3.0.0alpha1 - calendar @@ -400,6 +373,9 @@ + + + @@ -505,6 +481,7 @@ + @@ -520,6 +497,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1.0.0alpha1 @@ -1221,5 +1247,81 @@ * [jan] Allow passing a time format to Horde_Date_Recurrence#toString() (Bug #14768). + + + 3.0.0alpha1 + 3.0.0alpha1 + + + stable + stable + + 2021-02-24 + LGPL-2.1 + +* [rla] Begin conversion for composer usage. + + + + + 3.0.0alpha2 + 3.0.0alpha1 + + + alpha + alpha + + 2021-02-24 + LGPL-2.1 + +* |+ + + + + + 3.0.0alpha3 + 3.0.0alpha1 + + + alpha + alpha + + 2021-03-13 + LGPL-2.1 + +* |+ + + + + + 3.0.0alpha4 + 3.0.0alpha1 + + + alpha + alpha + + 2022-10-08 + LGPL-2.1 + +* [rla] Fix some PHP 8.1 issues. +* |+ + + + + + 3.0.0alpha5 + 3.0.0alpha1 + + + alpha + alpha + + 2022-10-08 + LGPL-2.1 + +* + + diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 376111c..0830fc2 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,12 +1,26 @@ - - - - test - - - - - lib - - - \ No newline at end of file + + + + + test + + + + + + src + + + diff --git a/src/DateTime.php b/src/DateTime.php new file mode 100644 index 0000000..0a04cf7 --- /dev/null +++ b/src/DateTime.php @@ -0,0 +1,11 @@ +run(); diff --git a/test/Horde/Date/AllTests.php b/test/Horde/Date/AllTests.php deleted file mode 100644 index 49583c8..0000000 --- a/test/Horde/Date/AllTests.php +++ /dev/null @@ -1,3 +0,0 @@ -run(); diff --git a/test/Horde/Date/bootstrap.php b/test/Horde/Date/bootstrap.php deleted file mode 100644 index 4e19e93..0000000 --- a/test/Horde/Date/bootstrap.php +++ /dev/null @@ -1,3 +0,0 @@ -_oldTimezone = date_default_timezone_get(); date_default_timezone_set('Europe/Berlin'); } - public function tearDown() + public function tearDown(): void { date_default_timezone_set($this->_oldTimezone); } @@ -299,6 +308,22 @@ public function testGetTimezoneAlias() 'UTC', Horde_Date::getTimezoneAlias('UTC') ); + $this->assertEquals( + 'Etc/GMT-8', + Horde_Date::getTimezoneAlias('GMT-0800') + ); + $this->assertEquals( + 'Etc/GMT+1', + Horde_Date::getTimezoneAlias('GMT+0100') + ); + $this->assertEquals( + 'Etc/GMT+10', + Horde_Date::getTimezoneAlias('GMT+1000') + ); + $this->assertEquals( + 'GMT+1030', + Horde_Date::getTimezoneAlias('GMT+1030') + ); } public function testSetTimezone() diff --git a/test/Horde/Date/RecurrenceTest.php b/test/Unnamespaced/RecurrenceTest.php similarity index 98% rename from test/Horde/Date/RecurrenceTest.php rename to test/Unnamespaced/RecurrenceTest.php index bb63ac6..ea67d87 100644 --- a/test/Horde/Date/RecurrenceTest.php +++ b/test/Unnamespaced/RecurrenceTest.php @@ -4,22 +4,30 @@ * @package Date * @subpackage UnitTests */ +namespace Horde\Date\Test; +use \Horde_Test_Case as TestCase; +use \Horde_Date; +use \Horde_Date_Recurrence; +use \Horde_Icalendar; +use \Horde_Icalendar_Vevent; +use \date_default_timezone_get; +use \date_default_timezone_set; /** * @category Horde * @package Date * @subpackage UnitTests */ -class Horde_Date_RecurrenceTest extends Horde_Test_Case +class RecurrenceTest extends TestCase { - protected function setUp() + protected function setUp(): void { $this->ical = new Horde_Icalendar(); $this->_oldTimezone = date_default_timezone_get(); date_default_timezone_set('Europe/Berlin'); } - public function tearDown() + public function tearDown(): void { date_default_timezone_set($this->_oldTimezone); } @@ -991,7 +999,7 @@ public function testCompletions() public function testBug2813RecurrenceEndFromIcalendar() { $iCal = new Horde_Icalendar(); - $iCal->parsevCalendar(file_get_contents(__DIR__ . '/fixtures/bug2813.ics')); + $iCal->parsevCalendar(file_get_contents(__DIR__ . '/../fixtures/bug2813.ics')); $components = $iCal->getComponents(); date_default_timezone_set('US/Eastern'); @@ -1068,7 +1076,7 @@ public function testBug12869RecurrenceEndFromIcalendar() { date_default_timezone_set('Europe/Amsterdam'); $iCal = new Horde_Icalendar(); - $iCal->parsevCalendar(file_get_contents(__DIR__ . '/fixtures/bug12869.ics')); + $iCal->parsevCalendar(file_get_contents(__DIR__ . '/../fixtures/bug12869.ics')); $components = $iCal->getComponents(); foreach ($components as $content) { if ($content instanceof Horde_Icalendar_Vevent) { @@ -1098,7 +1106,7 @@ public function testBug15054ThunderbirdWorkday() { date_default_timezone_set('Europe/Berlin'); $iCal = new Horde_Icalendar(); - $iCal->parsevCalendar(file_get_contents(__DIR__ . '/fixtures/bug15054.ics')); + $iCal->parsevCalendar(file_get_contents(__DIR__ . '/../fixtures/bug15054.ics')); $components = $iCal->getComponents(); foreach ($components as $content) { if ($content instanceof Horde_Icalendar_Vevent) { diff --git a/test/Horde/Date/Repeater/DayNameTest.php b/test/Unnamespaced/Repeater/DayNameTest.php similarity index 87% rename from test/Horde/Date/Repeater/DayNameTest.php rename to test/Unnamespaced/Repeater/DayNameTest.php index 1755675..fe40e31 100644 --- a/test/Horde/Date/Repeater/DayNameTest.php +++ b/test/Unnamespaced/Repeater/DayNameTest.php @@ -4,15 +4,19 @@ * @package Date * @subpackage UnitTests */ +namespace Horde\Date\Test\Repeater; +use \PHPUnit\Framework\TestCase; +use \Horde_Date; +use \Horde_Date_Repeater_DayName; /** * @category Horde * @package Date * @subpackage UnitTests */ -class Horde_Date_Repeater_DayNameTest extends PHPUnit_Framework_TestCase +class DayNameTest extends TestCase { - public function setUp() + public function setUp(): void { $this->now = new Horde_Date('2006-08-16 14:00:00'); } diff --git a/test/Horde/Date/Repeater/DayTest.php b/test/Unnamespaced/Repeater/DayTest.php similarity index 82% rename from test/Horde/Date/Repeater/DayTest.php rename to test/Unnamespaced/Repeater/DayTest.php index 3f7987d..e64bd66 100644 --- a/test/Horde/Date/Repeater/DayTest.php +++ b/test/Unnamespaced/Repeater/DayTest.php @@ -4,13 +4,17 @@ * @package Date * @subpackage UnitTests */ +namespace Horde\Date\Test\Repeater; +use \PHPUnit\Framework\TestCase; +use \Horde_Date; +use \Horde_Date_Repeater_Day; /** * @category Horde * @package Date * @subpackage UnitTests */ -class Horde_Date_Repeater_DayTest extends PHPUnit_Framework_TestCase +class DayTest extends TestCase { public function testNextFuture() { diff --git a/test/Horde/Date/Repeater/HourTest.php b/test/Unnamespaced/Repeater/HourTest.php similarity index 92% rename from test/Horde/Date/Repeater/HourTest.php rename to test/Unnamespaced/Repeater/HourTest.php index 44cb99f..8aa0f4c 100644 --- a/test/Horde/Date/Repeater/HourTest.php +++ b/test/Unnamespaced/Repeater/HourTest.php @@ -4,15 +4,20 @@ * @package Date * @subpackage UnitTests */ +namespace Horde\Date\Test\Repeater; +use \PHPUnit\Framework\TestCase; +use \Horde_Date; +use \Horde_Date_Span; +use \Horde_Date_Repeater_Hour; /** * @category Horde * @package Date * @subpackage UnitTests */ -class Horde_Date_Repeater_HourTest extends PHPUnit_Framework_TestCase +class HourTest extends TestCase { - public function setUp() + public function setUp(): void { $this->now = new Horde_Date('2006-08-16 14:00:00'); } diff --git a/test/Horde/Date/Repeater/MonthNameTest.php b/test/Unnamespaced/Repeater/MonthNameTest.php similarity index 91% rename from test/Horde/Date/Repeater/MonthNameTest.php rename to test/Unnamespaced/Repeater/MonthNameTest.php index 23045f2..0c64a2b 100644 --- a/test/Horde/Date/Repeater/MonthNameTest.php +++ b/test/Unnamespaced/Repeater/MonthNameTest.php @@ -4,15 +4,19 @@ * @package Date * @subpackage UnitTests */ +namespace Horde\Date\Test\Repeater; +use \PHPUnit\Framework\TestCase; +use \Horde_Date; +use \Horde_Date_Repeater_MonthName; /** * @category Horde * @package Date * @subpackage UnitTests */ -class Horde_Date_Repeater_MonthNameTest extends PHPUnit_Framework_TestCase +class MonthNameTest extends TestCase { - public function setUp() + public function setUp(): void { $this->now = new Horde_Date('2006-08-16 14:00:00'); } diff --git a/test/Horde/Date/Repeater/MonthTest.php b/test/Unnamespaced/Repeater/MonthTest.php similarity index 83% rename from test/Horde/Date/Repeater/MonthTest.php rename to test/Unnamespaced/Repeater/MonthTest.php index 5d82da8..5c8d93a 100644 --- a/test/Horde/Date/Repeater/MonthTest.php +++ b/test/Unnamespaced/Repeater/MonthTest.php @@ -4,15 +4,20 @@ * @package Date * @subpackage UnitTests */ +namespace Horde\Date\Test\Repeater; +use \PHPUnit\Framework\TestCase; +use \Horde_Date; +use \Horde_Date_Span; +use \Horde_Date_Repeater_Month; /** * @category Horde * @package Date * @subpackage UnitTests */ -class Horde_Date_Repeater_MonthTest extends PHPUnit_Framework_TestCase +class MonthTest extends TestCase { - public function setUp() + public function setUp(): void { $this->now = new Horde_Date('2006-08-16 14:00:00'); } diff --git a/test/Horde/Date/Repeater/TimeTest.php b/test/Unnamespaced/Repeater/TimeTest.php similarity index 92% rename from test/Horde/Date/Repeater/TimeTest.php rename to test/Unnamespaced/Repeater/TimeTest.php index b02b911..56b7828 100644 --- a/test/Horde/Date/Repeater/TimeTest.php +++ b/test/Unnamespaced/Repeater/TimeTest.php @@ -4,15 +4,19 @@ * @package Date * @subpackage UnitTests */ +namespace Horde\Date\Test\Repeater; +use \PHPUnit\Framework\TestCase; +use \Horde_Date; +use \Horde_Date_Repeater_Time; /** * @category Horde * @package Date * @subpackage UnitTests */ -class Horde_Date_Repeater_TimeTest extends PHPUnit_Framework_TestCase +class TimeTest extends TestCase { - public function setUp() + public function setUp(): void { $this->now = new Horde_Date('2006-08-16 14:00:00'); } diff --git a/test/Horde/Date/Repeater/WeekTest.php b/test/Unnamespaced/Repeater/WeekTest.php similarity index 91% rename from test/Horde/Date/Repeater/WeekTest.php rename to test/Unnamespaced/Repeater/WeekTest.php index d11aa11..b1e9cf1 100644 --- a/test/Horde/Date/Repeater/WeekTest.php +++ b/test/Unnamespaced/Repeater/WeekTest.php @@ -4,15 +4,20 @@ * @package Date * @subpackage UnitTests */ +namespace Horde\Date\Test\Repeater; +use \PHPUnit\Framework\TestCase; +use \Horde_Date; +use \Horde_Date_Repeater_Week; +use \Horde_Date_Span; /** * @category Horde * @package Date * @subpackage UnitTests */ -class Horde_Date_Repeater_WeekTest extends PHPUnit_Framework_TestCase +class WeekTest extends TestCase { - public function setUp() + public function setUp(): void { $this->now = new Horde_Date('2006-08-16 14:00:00'); } diff --git a/test/Horde/Date/Repeater/WeekendTest.php b/test/Unnamespaced/Repeater/WeekendTest.php similarity index 92% rename from test/Horde/Date/Repeater/WeekendTest.php rename to test/Unnamespaced/Repeater/WeekendTest.php index de10f38..6d31de5 100644 --- a/test/Horde/Date/Repeater/WeekendTest.php +++ b/test/Unnamespaced/Repeater/WeekendTest.php @@ -4,15 +4,20 @@ * @package Date * @subpackage UnitTests */ +namespace Horde\Date\Test\Repeater; +use \PHPUnit\Framework\TestCase; +use \Horde_Date; +use \Horde_Date_Repeater_Weekend; +use \Horde_Date_Span; /** * @category Horde * @package Date * @subpackage UnitTests */ -class Horde_Date_Repeater_WeekendTest extends PHPUnit_Framework_TestCase +class WeekendTest extends TestCase { - public function setUp() + public function setUp(): void { $this->now = new Horde_Date('2006-08-16 14:00:00'); } diff --git a/test/Horde/Date/Repeater/YearTest.php b/test/Unnamespaced/Repeater/YearTest.php similarity index 92% rename from test/Horde/Date/Repeater/YearTest.php rename to test/Unnamespaced/Repeater/YearTest.php index 75a8c64..34e33c7 100644 --- a/test/Horde/Date/Repeater/YearTest.php +++ b/test/Unnamespaced/Repeater/YearTest.php @@ -4,15 +4,20 @@ * @package Date * @subpackage UnitTests */ +namespace Horde\Date\Test\Repeater; +use \PHPUnit\Framework\TestCase; +use \Horde_Date; +use \Horde_Date_Repeater_Year; +use \Horde_Date_Span; /** * @category Horde * @package Date * @subpackage UnitTests */ -class Horde_Date_Repeater_YearTest extends PHPUnit_Framework_TestCase +class YearTest extends TestCase { - public function setUp() + public function setUp(): void { $this->now = new Horde_Date('2006-08-16 14:00:00'); } diff --git a/test/Horde/Date/SpanTest.php b/test/Unnamespaced/SpanTest.php similarity index 89% rename from test/Horde/Date/SpanTest.php rename to test/Unnamespaced/SpanTest.php index bb10974..296142c 100644 --- a/test/Horde/Date/SpanTest.php +++ b/test/Unnamespaced/SpanTest.php @@ -4,13 +4,17 @@ * @package Date * @subpackage UnitTests */ +namespace Horde\Date\Test; +use \PHPUnit\Framework\TestCase; +use \Horde_Date; +use \Horde_Date_Span; /** * @category Horde * @package Date * @subpackage UnitTests */ -class Horde_Date_SpanTest extends PHPUnit_Framework_TestCase +class SpanTest extends TestCase { public function testWidth() { diff --git a/test/Horde/Date/UtilsTest.php b/test/Unnamespaced/UtilsTest.php similarity index 84% rename from test/Horde/Date/UtilsTest.php rename to test/Unnamespaced/UtilsTest.php index b714124..189aa5d 100644 --- a/test/Horde/Date/UtilsTest.php +++ b/test/Unnamespaced/UtilsTest.php @@ -4,13 +4,16 @@ * @package Date * @subpackage UnitTests */ +namespace Horde\Date\Test; +use \PHPUnit\Framework\TestCase; +use \Horde_Date_Utils; /** * @category Horde * @package Date * @subpackage UnitTests */ -class Horde_Date_UtilsTest extends PHPUnit_Framework_TestCase +class UtilsTest extends TestCase { public function testFirstDayOfWeek() { diff --git a/test/bootstrap.php b/test/bootstrap.php new file mode 100644 index 0000000..c92c4e9 --- /dev/null +++ b/test/bootstrap.php @@ -0,0 +1,14 @@ +