summaryrefslogtreecommitdiffstats
path: root/php-yoast-phpunit-polyfills.spec
blob: 01f5852582120a2fe715fc750fc66e664be32d2b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
# remirepo/fedora spec file for php-yoast-phpunit-polyfills
#
# Copyright (c) 2020 Remi Collet
# License: CC-BY-SA
# http://creativecommons.org/licenses/by-sa/4.0/
#
# Please preserve changelog entries
#
# Github
%global gh_commit    5ea3536428944955f969bc764bbe09738e151ada
%global gh_short     %(c=%{gh_commit}; echo ${c:0:7})
%global gh_owner     Yoast
%global gh_project   PHPUnit-Polyfills
# Packagist
%global pk_vendor    yoast
%global pk_project   phpunit-polyfills
# Namespace
%global ns_vendor    Yoast
%global ns_project   PHPUnitPolyfills
# don't change major version used in package name
%global major        %nil
%bcond_without       tests
%global php_home     %{_datadir}/php

Name:           php-%{pk_vendor}-%{pk_project}%{major}
Version:        1.0.3
Release:        1%{?dist}
Summary:        Set of polyfills for changed PHPUnit functionality

License:        BSD
URL:            https://github.com/%{gh_owner}/%{gh_project}
# git snapshot to get upstream test suite
Source0:        %{name}-%{version}-%{gh_short}.tgz
Source1:        makesrc.sh

BuildArch:      noarch
%if %{with tests}
BuildRequires:  php(language) >= 5.4
BuildRequires:  php-reflection
# From composer.json, "require-dev": {
#        "yoast/yoastcs": "^2.2.0"
%if 0%{?fedora} >= 32 || 0%{?rhel} >= 9
BuildRequires:  phpunit9
%endif
BuildRequires:  phpunit8
%if 0%{?fedora} < 35 && 0%{?rhel} < 9
BuildRequires:  phpunit7
BuildRequires:  phpunit
%endif
BuildRequires:  php-fedora-autoloader-devel
%endif

# From composer.json, "require": {
#        "php": ">=5.4",
#        "phpunit/phpunit": "^4.8.36 || ^5.7.21 || ^6.0 || ^7.0 || ^8.0 || ^9.0"
Requires:       php(language) >= 5.4
# from phpcompatinfo report on version 0.2.0
Requires:       php-reflection

Provides:       php-composer(%{pk_vendor}/%{pk_project}) = %{version}


%description
Set of polyfills for changed PHPUnit functionality to allow for creating
PHPUnit cross-version compatible tests.

Autoloader: %{php_home}/%{ns_vendor}/%{ns_project}%{major}/autoload.php



%prep
%setup -q -n %{gh_project}-%{gh_commit}

# Fix for RPM layout
sed -e 's:src/::' phpunitpolyfills-autoload.php > src/autoload.php


%build
# Empty build section, most likely nothing required.


%install
mkdir -p        %{buildroot}/%{php_home}/%{ns_vendor}
cp -pr src      %{buildroot}/%{php_home}/%{ns_vendor}/%{ns_project}%{major}


%check
%if %{with tests}
: Use installed tree and autoloader
mkdir vendor
cat << 'EOF' | tee -a vendor/autoload.php
<?php
require_once '%{php_home}/Fedora/Autoloader/autoload.php';
\Fedora\Autoloader\Autoload::addPsr4('Yoast\\PHPUnitPolyfills\\Tests\\', dirname(__DIR__) . '/tests');
require_once '%{buildroot}/%{php_home}/%{ns_vendor}/%{ns_project}%{major}/autoload.php';
EOF

: Run upstream test suite
ret=0
if [ -x %{_bindir}/phpunit ]; then
  for cmd in php php71 php72 php73 php74; do
    if which $cmd; then
      $cmd %{_bindir}/phpunit --no-coverage --verbose || ret=1
    fi
  done
fi
if [ -x %{_bindir}/phpunit6 ]; then
  for cmd in php php71 php72 php73 php74; do
    if which $cmd; then
      $cmd %{_bindir}/phpunit6 --no-coverage --verbose || ret=1
    fi
  done
fi
if [ -x %{_bindir}/phpunit7 ]; then
  for cmd in php php71 php72 php73 php74; do
    if which $cmd; then
      $cmd %{_bindir}/phpunit7 --no-coverage --verbose || ret=1
    fi
  done
fi
if [ -x %{_bindir}/phpunit8 ]; then
  for cmd in php php72 php73 php74 php80 php81; do
    if which $cmd; then
      $cmd %{_bindir}/phpunit8 --no-coverage --verbose || ret=1
    fi
  done
fi
if [ -x %{_bindir}/phpunit9 ]; then
  for cmd in php php73 php74 php80 php81; do
    if which $cmd; then
      $cmd %{_bindir}/phpunit9 --no-coverage --verbose || ret=1
    fi
  done
fi

exit $ret
%endif


%files
# remirepo:1
%{!?_licensedir:%global license %%doc}
%license LICENSE
%doc *.md
%doc composer.json
%{php_home}/%{ns_vendor}


%changelog
* Tue Nov 23 2021 Remi Collet <remi@remirepo.net> - 1.0.3-1
- update to 1.0.3

* Mon Oct  4 2021 Remi Collet <remi@remirepo.net> - 1.0.2-1
- update to 1.0.2

* Tue Aug 10 2021 Remi Collet <remi@remirepo.net> - 1.0.1-1
- update to 1.0.1

* Mon Jun 21 2021 Remi Collet <remi@remirepo.net> - 1.0.0-1
- update to 1.0.0

* Wed Mar 10 2021 Remi Collet <remi@remirepo.net> - 0.2.0-2
- reduce build matrix

* Thu Nov 26 2020 Remi Collet <remi@remirepo.net> - 0.2.0-1
- initial rpm