summaryrefslogtreecommitdiffstats
path: root/php-hamcrest2.spec
blob: 88c915ba910150e056683c78c8fba3c37d17762b (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
# remirepo/fedora spec file for php-hamcrest2
#
# SPDX-FileCopyrightText:  Copyright 2015-2025 Remi Collet
# SPDX-License-Identifier: CECILL-2.1
# http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
#
# Please, preserve the changelog entries
#
%global gh_date      2025-04-30
%global gh_commit    f8b1c0173b22fa6ec77a81fe63e5b01eba7e6487
%global gh_short     %(c=%{gh_commit}; echo ${c:0:7})
%global gh_owner     hamcrest
%global gh_project   hamcrest-php
%global ns_project   Hamcrest
%global major        2
%bcond_without       tests

Name:           php-hamcrest2
Version:        2.1.1
Release:        1%{?dist}
Summary:        PHP port of Hamcrest Matchers

License:        BSD-3-Clause
URL:            https://github.com/%{gh_owner}/%{gh_project}
# git snapshot with tests
Source0:        %{name}-%{version}-%{gh_short}.tgz
Source1:        makesrc.sh

# Use generated autoloader instead of composer one
Patch0:         bootstrap-autoload.patch

BuildArch:      noarch
BuildRequires:  php-fedora-autoloader-devel
%if %{with tests}
# From composer.json, require-dev:
#               "phpunit/php-file-iterator": "^1.4 || ^2.0 || ^3.0",
#               "phpunit/phpunit": "^4.8.36 || ^5.7 || ^6.5 || ^7.0 || ^8.0 || ^9.0"
BuildRequires:  phpunit9
BuildRequires:  php(language) >= 7.4
# From phpcompatinfo report for 2.1.1
BuildRequires:  php-ctype
BuildRequires:  php-dom
%endif

# composer.json, require:
#      "php": "^7.4|^8.0"
Requires:       php(language) >= 7.4
# From phpcompatinfo report for 2.1.1
Requires:       php-ctype
Requires:       php-dom
# Autoloader
Requires:       php-composer(fedora/autoloader)

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


%description
Hamcrest is a matching library originally written for Java,
but subsequently ported to many other languages.

%{name} is the official PHP port of Hamcrest and essentially follows
a literal translation of the original Java API for Hamcrest,
with a few Exceptions, mostly down to PHP language barriers.

Autoloader: %{_datadir}/php/%{ns_project}%{major}/autoload.php


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

%patch -P0 -p0 -b .rpm
find . -name \*.rpm -exec rm {} \; -print

# Move to Library tree
mv hamcrest/%{ns_project}.php hamcrest/%{ns_project}/%{ns_project}.php


%build
# Library autoloader
%{_bindir}/phpab \
    --template fedora \
    --output hamcrest/%{ns_project}/autoload.php \
    hamcrest/%{ns_project}

# Test suite autoloader
%{_bindir}/phpab \
    --output tests/autoload.php \
    --exclude '*Test.php' \
    tests generator


%install
mkdir -p %{buildroot}%{_datadir}/php
cp -pr hamcrest/%{ns_project} %{buildroot}%{_datadir}/php/%{ns_project}%{major}


%check
%if %{with tests}
cd tests
ret=0
for cmd in php php81 php82 php83 php84; do
  if which $cmd; then
    $cmd %{_bindir}/phpunit9 || ret=1
  fi
done
exit $ret
%else
: Test suite disabled
%endif


%files
%license LICENSE.txt
%doc CHANGES.txt README.md
%doc composer.json
%{_datadir}/php/%{ns_project}%{major}


%changelog
* Tue May  6 2025 Remi Collet <remi@remirepo.net> - 2.1.1-1
- update to 2.1.1
- raise dependency on PHP 7.4

* Wed Jan 22 2025 Remi Collet <remi@remirepo.net> - 2.0.1-12
- switch to phpunit9
- re-license spec file to CECILL-2.1

* Thu Jul  9 2020 Remi Collet <remi@remirepo.net> - 2.0.1-1
- update to 2.0.1
- switch to phpunit7

* Mon Jan 22 2018 Remi Collet <remi@remirepo.net> - 2.0.0-1
- Update to 2.0.0
- rename to php-hamcrest2

* Fri Feb 17 2017 Remi Collet <remi@fedoraproject.org> - 1.2.2-4
- add upstream patch for PHP 7, fix FTBFS
- switch to fedora/autoloader

* Thu Oct 15 2015 Remi Collet <remi@fedoraproject.org> - 1.2.2-1
- update to 1.2.2

* Mon Jan  5 2015 Remi Collet <remi@fedoraproject.org> - 1.2.0-1
- initial package