Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
9f4d2ff
[TASK] Initial changes for typo3 v10 & v11 support
Jstockfisch Nov 30, 2021
c20ab69
[TASK] Drop LocalizationUtilityFacade and fix check for if git is ava…
Jstockfisch Nov 30, 2021
293dc17
[TASK] Fix ProjectVersionTest
Jstockfisch Nov 30, 2021
90836be
[TASK] Fix most tests
Jstockfisch Nov 30, 2021
709802b
[#17] Update copyright comments of php-files
KamiYang Jun 6, 2022
c135288
[#17] Make classes php7.2 compatible
KamiYang Jun 6, 2022
7d23fc4
[#17] Fix tests
KamiYang Jun 6, 2022
cdca72b
[#17] Cleanup
KamiYang Jun 6, 2022
81a1b18
[#17] Raise typo3 versions in .travis.yaml
KamiYang Jun 6, 2022
6dd73bf
[#17] Fix version numbers in .travis.yml
KamiYang Jun 6, 2022
215e86f
[#17] Ignore root .ddev folder from git
KamiYang Jun 6, 2022
0ad0b5b
[#17] Introduce GHA
KamiYang Jun 6, 2022
98bb015
[#17] Fix typo3 versions
KamiYang Jun 6, 2022
02b87b2
[#17] Dont preserve newlines
KamiYang Jun 6, 2022
fb10209
[#17] Dont use multiline string
KamiYang Jun 6, 2022
f76d4f5
[#17] Run tests on two versions
KamiYang Jun 6, 2022
f7eb74b
[#17] Dont use multiline string
KamiYang Jun 6, 2022
58cd080
[#17] Dont use multiline string
KamiYang Jun 6, 2022
b49b907
[#17] Run actions for all supported typo3 versions
KamiYang Jun 6, 2022
5c155a9
[#17] Don't run tests for typo3 v11
KamiYang Jun 6, 2022
9433028
[#17] Remove unnecessary lines
KamiYang Jun 6, 2022
5551918
[#17] Optimize CI
KamiYang Jun 6, 2022
bfbb1f6
[#17] Fix "needs"
KamiYang Jun 6, 2022
a457df2
[#17] Try to add composer cache
KamiYang Jun 6, 2022
3dff1b9
[#17] Remove name from workflow stage
KamiYang Jun 6, 2022
c17dd50
[#17] Remove not existing stage build
KamiYang Jun 6, 2022
8ea9a1e
[#17] Remove stuff
KamiYang Jun 6, 2022
88db036
[#17] Set coverage: xdebug
KamiYang Jun 6, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Unit tests

on:
push:
branches: [ "master" ]
pull_request:

jobs:
test:
runs-on: ubuntu-18.04
strategy:
matrix:
typo3_version:
- 10.4.20
- 10.4.21
- 10.4.22
- 10.4.23
- 10.4.24
- 10.4.25
- 10.4.26
- 10.4.27
- 10.4.28
# - 11.5.0
# - 11.5.1
# - 11.5.2
# - 11.5.3
# - 11.5.4
# - 11.5.5
# - 11.5.6
# - 11.5.7
# - 11.5.8
# - 11.5.9
# - 11.5.10
# - dev-master

steps:
- uses: actions/checkout@v3

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.2
tools: composer:v1
coverage: xdebug

- name: Validate composer.json
run: composer validate --strict

- name: Setup problem matchers for PHPUnit
run: echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json"

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache composer dependencies
uses: actions/cache@v3
with:
path: ${{ steps.composer-cache.outputs.dir }}
# Use composer.json for key, if composer.lock is not committed.
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}-${{ matrix.typo3_version }}
restore-keys: ${{ runner.os }}-composer-

- name: Install dependencies for TYPO3 version "${{ matrix.typo3_version }}"
run: composer require typo3/cms-backend:${{ matrix.typo3_version }} typo3/cms-core:${{ matrix.typo3_version }} typo3/cms-extbase:${{ matrix.typo3_version }} typo3/cms-extensionmanager:${{ matrix.typo3_version }} typo3/cms-filelist:${{ matrix.typo3_version }} typo3/cms-fluid:${{ matrix.typo3_version }} typo3/cms-frontend:${{ matrix.typo3_version }} typo3/cms-install:${{ matrix.typo3_version }} typo3/cms-recordlist:${{ matrix.typo3_version }} typo3/cms-lowlevel:${{ matrix.typo3_version }} typo3/cms-about:${{ matrix.typo3_version }} typo3/cms-belog:${{ matrix.typo3_version }} typo3/cms-beuser:${{ matrix.typo3_version }} typo3/cms-felogin:${{ matrix.typo3_version }} typo3/cms-fluid-styled-content:${{ matrix.typo3_version }} typo3/cms-form:${{ matrix.typo3_version }} typo3/cms-impexp:${{ matrix.typo3_version }} typo3/cms-info:${{ matrix.typo3_version }} typo3/cms-rte-ckeditor:${{ matrix.typo3_version }} typo3/cms-setup:${{ matrix.typo3_version }} typo3/cms-seo:${{ matrix.typo3_version }} typo3/cms-sys-note:${{ matrix.typo3_version }} typo3/cms-t3editor:${{ matrix.typo3_version }} typo3/cms-tstemplate:${{ matrix.typo3_version }} typo3/cms-viewpage:${{ matrix.typo3_version }} typo3/cms-adminpanel:${{ matrix.typo3_version }} typo3/cms-redirects:${{ matrix.typo3_version }} typo3/cms-workspaces:${{ matrix.typo3_version }} typo3/cms-reports:${{ matrix.typo3_version }} typo3/cms-scheduler:${{ matrix.typo3_version }} typo3/cms-recycler:${{ matrix.typo3_version }} typo3/cms-opendocs:${{ matrix.typo3_version }} typo3/cms-linkvalidator:${{ matrix.typo3_version }}

- name: Unit tests
run: .Build/bin/phpunit --colors -c phpunit.xml --coverage-text
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/.ddev
/.Build/
/.idea/
/composer.lock
Expand Down
72 changes: 42 additions & 30 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,27 +1,21 @@
# .travis.yml
language: php

sudo: false

php:
- 7.2

matrix:
fast_finish: true

addons:
apt:
packages:
- parallel
cache:
directories:
- $HOME/.composer/cache

install:
- composer require typo3/cms-backend:${TYPO3_VERSION} typo3/cms-core:${TYPO3_VERSION} typo3/cms-extbase:${TYPO3_VERSION} typo3/cms-extensionmanager:${TYPO3_VERSION} typo3/cms-filelist:${TYPO3_VERSION} typo3/cms-fluid:${TYPO3_VERSION} typo3/cms-frontend:${TYPO3_VERSION} typo3/cms-install:${TYPO3_VERSION} typo3/cms-recordlist:${TYPO3_VERSION} typo3/cms-lowlevel:${TYPO3_VERSION} typo3/cms-about:${TYPO3_VERSION} typo3/cms-belog:${TYPO3_VERSION} typo3/cms-beuser:${TYPO3_VERSION} typo3/cms-felogin:${TYPO3_VERSION} typo3/cms-fluid-styled-content:${TYPO3_VERSION} typo3/cms-form:${TYPO3_VERSION} typo3/cms-impexp:${TYPO3_VERSION} typo3/cms-info:${TYPO3_VERSION} typo3/cms-rte-ckeditor:${TYPO3_VERSION} typo3/cms-setup:${TYPO3_VERSION} typo3/cms-seo:${TYPO3_VERSION} typo3/cms-sys-note:${TYPO3_VERSION} typo3/cms-t3editor:${TYPO3_VERSION} typo3/cms-tstemplate:${TYPO3_VERSION} typo3/cms-viewpage:${TYPO3_VERSION} typo3/cms-adminpanel:${TYPO3_VERSION} typo3/cms-redirects:${TYPO3_VERSION} typo3/cms-workspaces:${TYPO3_VERSION} typo3/cms-reports:${TYPO3_VERSION} typo3/cms-scheduler:${TYPO3_VERSION} typo3/cms-recycler:${TYPO3_VERSION} typo3/cms-opendocs:${TYPO3_VERSION} typo3/cms-linkvalidator:${TYPO3_VERSION}

- git checkout composer.json
- export TYPO3_PATH_WEB="$PWD/.Build/web"
- export TYPO3_PATH_WEB="$PWD/.Build/public"

script:
- >
Expand All @@ -46,30 +40,48 @@ jobs:
allow_failures:
- env: TYPO3_VERSION=dev-master
include:
- stage: test
php: 7.2
env: TYPO3_VERSION=9.5.0
- stage: test
php: 7.2
env: TYPO3_VERSION=9.5.1
- stage: test
php: 7.2
env: TYPO3_VERSION=9.5.2
- stage: test
php: 7.2
env: TYPO3_VERSION=9.5.3
- stage: test
php: 7.2
env: TYPO3_VERSION=9.5.4
- stage: test
php: 7.2
env: TYPO3_VERSION=9.5.5
- stage: test
php: 7.2
env: TYPO3_VERSION=9.5.6
- stage: test
- &test
stage: test
php: 7.2
env: TYPO3_VERSION=9.5.7
env: TYPO3_VERSION=10.5.20
- *test
env: TYPO3_VERSION=10.5.21
- *test
env: TYPO3_VERSION=10.5.22
- *test
env: TYPO3_VERSION=10.5.23
- *test
env: TYPO3_VERSION=10.5.24
- *test
env: TYPO3_VERSION=10.5.25
- *test
env: TYPO3_VERSION=10.5.26
- *test
env: TYPO3_VERSION=10.5.27
- *test
env: TYPO3_VERSION=10.5.28
- *test
env: TYPO3_VERSION=11.5.0
- *test
env: TYPO3_VERSION=11.5.1
- *test
env: TYPO3_VERSION=11.5.2
- *test
env: TYPO3_VERSION=11.5.3
- *test
env: TYPO3_VERSION=11.5.4
- *test
env: TYPO3_VERSION=11.5.5
- *test
env: TYPO3_VERSION=11.5.6
- *test
env: TYPO3_VERSION=11.5.7
- *test
env: TYPO3_VERSION=11.5.8
- *test
env: TYPO3_VERSION=11.5.9
- *test
env: TYPO3_VERSION=11.5.10
- stage: test
php: 7.2
env: TYPO3_VERSION=dev-master
52 changes: 0 additions & 52 deletions Classes/Backend/ToolbarItems/ProjectVersionSlot.php

This file was deleted.

87 changes: 30 additions & 57 deletions Classes/Configuration/ExtensionConfiguration.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php
declare(strict_types=1);

namespace KamiYang\ProjectVersion\Configuration;
declare(strict_types=1);

/*
* This file is part of the ProjectVersion project.
Expand All @@ -15,6 +14,8 @@
* LICENSE file that was distributed with this source code.
*/

namespace KamiYang\ProjectVersion\Configuration;

use KamiYang\ProjectVersion\Enumeration\ProjectVersionModeEnumeration;
use TYPO3\CMS\Core\SingletonInterface;
use TYPO3\CMS\Core\Utility\GeneralUtility;
Expand All @@ -25,124 +26,96 @@
*/
final class ExtensionConfiguration implements SingletonInterface
{
private const DEFAULT_VERSION_FILE = 'VERSION';

/**
* Extension configuration.
*
* @var array
*/
private static $configuration = [];
private $configuration;

/**
* Relative file path of the VERSION-file. Blank equals const 'PATH_site'.
*
* @var string
*/
private static $versionFilePath = '';
private $versionFilePath;

/**
* Indicator for the fetching method.
*
* @var string
* @see \KamiYang\ProjectVersion\Enumeration\ProjectVersionModeEnumeration
* @see ProjectVersionModeEnumeration
*/
private static $mode = ProjectVersionModeEnumeration::FILE;
private $mode;

/**
* @var string
*/
private static $gitFormat = '';
private $gitFormat;

/**
* @var string
*/
private static $staticVersion = '';
private $staticVersion;

/**
* Fetch absolute version filename.
*
* @return string
*/
public static function getAbsVersionFilePath(): string
public function getAbsVersionFilePath(): string
{
return GeneralUtility::getFileAbsFileName(self::getVersionFilePath());
return GeneralUtility::getFileAbsFileName($this->getVersionFilePath());
}

/**
* @return string
*/
public static function getVersionFilePath(): string
public function getVersionFilePath(): string
{
return self::$versionFilePath;
return $this->versionFilePath;
}

/**
* @return string
*/
public static function getMode(): string
public function getMode(): string
{
return self::$mode;
return $this->mode;
}

/**
* @return string
*/
public static function getGitFormat(): string
public function getGitFormat(): string
{
return self::$gitFormat;
return $this->gitFormat;
}

/**
* @return string
*/
public static function getStaticVersion(): string
public function getStaticVersion(): string
{
return self::$staticVersion;
return $this->staticVersion;
}

public function __construct()
{
self::$configuration = $this->getExtensionConfigurationFromGlobals();

self::$versionFilePath = $this->resolveVersionFilePath();
self::$mode = self::$configuration['mode'];
self::$gitFormat = self::$configuration['gitFormat'];
self::$staticVersion = self::$configuration['staticVersion'];
$this->configuration = $this->getExtensionConfigurationFromGlobals();
$this->versionFilePath = $this->resolveVersionFilePath();
$this->mode = $this->configuration['mode'] ?? ProjectVersionModeEnumeration::FILE;
$this->gitFormat = $this->configuration['gitFormat'] ?? '';
$this->staticVersion = $this->configuration['staticVersion'] ?? '';
}

/**
* @return array
*/
private function getExtensionConfigurationFromGlobals(): array
{
$configuration = $GLOBALS['TYPO3_CONF_VARS']['EXT']['extConf']['project_version'];

if (is_string($configuration)) {
$configuration = @unserialize($configuration);
}

return $configuration ?? [];
return $GLOBALS['TYPO3_CONF_VARS']['EXTENSIONS']['project_version'] ?? [];
}

/**
* @return string
*/
private function resolveVersionFilePath(): string
{
$pathFromConfiguration = self::$configuration['versionFilePath'] ?? '';

$pathFromConfiguration = $this->configuration['versionFilePath'] ?? '';
if (empty($pathFromConfiguration) || $this->isDirectory($pathFromConfiguration)) {
$pathFromConfiguration .= 'VERSION';
$pathFromConfiguration .= self::DEFAULT_VERSION_FILE;
}

return $pathFromConfiguration;
}

/**
* @param string $pathFromConfiguration
* @return bool
*/
private function isDirectory(string $pathFromConfiguration): bool
{
return StringUtility::endsWith($pathFromConfiguration, '/') === true;
return StringUtility::endsWith($pathFromConfiguration, '/');
}
}
Loading