summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--php-cs-fixer.spec48
1 files changed, 36 insertions, 12 deletions
diff --git a/php-cs-fixer.spec b/php-cs-fixer.spec
index fa2b301..1b69e2c 100644
--- a/php-cs-fixer.spec
+++ b/php-cs-fixer.spec
@@ -20,11 +20,9 @@
%global gh_diff_commit f0ef6133d674137e902fdf8a6f2e8e97e14a087b
%global gh_diff_short %(c=%{gh_diff_commit}; echo ${c:0:7})
-# TODO: gecko-packages/gecko-php-unit v3 to use phpunit6
-
Name: php-cs-fixer
Version: 2.8.0
-Release: 1%{?gh_date:.%{gh_date}git%{gh_short}}%{?dist}
+Release: 2%{?gh_date:.%{gh_date}git%{gh_short}}%{?dist}
Summary: A tool to automatically fix PHP code style
Group: Development/Tools
@@ -41,14 +39,24 @@ Patch0: %{name}-autoload.patch
BuildArch: noarch
%if %{with_tests}
# For tests
+%if 0%{?fedora} >= 26
+BuildRequires: php(language) >= 7.0
+%global phpunit %{_bindir}/phpunit6
+%global gecko_min 3.0
+%global gecko_max 4
+%else
BuildRequires: php(language) >= 5.6
+%global phpunit %{_bindir}/phpunit
+%global gecko_min 2.0
+%global gecko_max 3
+%endif
BuildRequires: php-tokenizer
BuildRequires: php-composer(composer/semver) < 2
BuildRequires: php-composer(composer/semver) >= 1.4
BuildRequires: php-composer(doctrine/annotations) < 2
BuildRequires: php-composer(doctrine/annotations) >= 1.2
-BuildRequires: php-composer(gecko-packages/gecko-php-unit) < 3
-BuildRequires: php-composer(gecko-packages/gecko-php-unit) >= 2.0
+BuildRequires: php-composer(gecko-packages/gecko-php-unit) < %{gecko_max}
+BuildRequires: php-composer(gecko-packages/gecko-php-unit) >= %{gecko_min}
BuildRequires: php-composer(symfony/console) < 4
BuildRequires: php-composer(symfony/console) >= 3.0
BuildRequires: php-composer(symfony/event-dispatcher) < 4
@@ -93,7 +101,7 @@ BuildRequires: php-composer(justinrainbow/json-schema) < 6
BuildRequires: php-composer(justinrainbow/json-schema) >= 5.0
BuildRequires: php-composer(php-cs-fixer/accessible-object) < 2
BuildRequires: php-composer(php-cs-fixer/accessible-object) >= 1.0
-BuildRequires: php-composer(phpunit/phpunit) >= 4.5
+BuildRequires: %{phpunit}
BuildRequires: php-composer(symfony/phpunit-bridge) < 4
BuildRequires: php-composer(symfony/phpunit-bridge) >= 3.2
# Autoloader
@@ -126,8 +134,8 @@ Requires: php-composer(composer/semver) < 2
Requires: php-composer(composer/semver) >= 1.4
Requires: php-composer(doctrine/annotations) < 2
Requires: php-composer(doctrine/annotations) >= 1.2
-Requires: php-composer(gecko-packages/gecko-php-unit) < 3
-Requires: php-composer(gecko-packages/gecko-php-unit) >= 2.0
+Requires: php-composer(gecko-packages/gecko-php-unit) < %{gecko_max}
+Requires: php-composer(gecko-packages/gecko-php-unit) >= %{gecko_min}
Requires: php-composer(sebastian/diff) < 2
Requires: php-composer(sebastian/diff) >= 1.4
Requires: php-composer(symfony/console) < 4
@@ -209,9 +217,20 @@ phpab --template fedora --output src/autoload.php src/tests src/diff
cat << 'EOF' | tee -a src/autoload.php
\Fedora\Autoloader\Autoload::addPsr4('PhpCsFixer\\', __DIR__);
+if (class_exists('PHPUnit\\Runner\\Version') && version_compare(PHPUnit\Runner\Version::id(), '6', '>')) {
+ $gecko = [
+ '%{php_home}/GeckoPackages/PHPUnit3/autoload.php',
+ '%{php_home}/GeckoPackages/PHPUnit/autoload.php',
+ ];
+} else {
+ $gecko = [
+ '%{php_home}/GeckoPackages/PHPUnit/autoload.php',
+ '%{php_home}/GeckoPackages/PHPUnit3/autoload.php',
+ ];
+}
\Fedora\Autoloader\Dependencies::required([
'%{php_home}//Composer/Semver/autoload.php',
- '%{php_home}/GeckoPackages/PHPUnit/autoload.php',
+ $gecko,
'%{php_home}/Doctrine/Common/Annotations/autoload.php',
'%{php_home}/Symfony3/Component/Console/autoload.php',
'%{php_home}/Symfony3/Component/EventDispatcher/autoload.php',
@@ -243,6 +262,7 @@ install -Dpm755 %{name} %{buildroot}%{_bindir}/%{name}
mkdir vendor
cat << 'EOF' | tee vendor/autoload.php
<?php
+// Force version for local, when both versions are available
\Fedora\Autoloader\Dependencies::required([
'%{php_home}/Symfony3/Bridge/PhpUnit/autoload.php',
'%{php_home}/JsonSchema5/autoload.php',
@@ -264,9 +284,10 @@ sed -e 's/listeners/nolistener/' phpunit.xml.dist >phpunit.xml
sed -e 's:%{php_home}:%{buildroot}%{php_home}:' -i %{name}
ret=0
-for cmd in php php70 php71 php72; do
- if which $cmd; then
- $cmd -d memory_limit=1G %{_bindir}/phpunit || ret=1
+for cmdarg in "php %{phpunit}" "php56 %{_bindir}/phpunit" php70 php71 php72; do
+ if which $cmdarg; then
+ set $cmdarg
+ $1 -d memory_limit=1G ${2:-%{_bindir}/phpunit6} || ret=1
fi
done
exit $ret
@@ -285,6 +306,9 @@ exit $ret
%changelog
+* Fri Nov 3 2017 Remi Collet <remi@remirepo.net> - 2.8.0-2
+- use phpunit6 and php-gecko-packages-gecko-php-unit3 on F26+
+
* Fri Nov 3 2017 Remi Collet <remi@remirepo.net> - 2.8.0-1
- Update to 2.8.0