summaryrefslogtreecommitdiffstats
path: root/php-behat-mink.spec
blob: 5e6bc7fb177806ff114692c3242e7f71293fed35 (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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
# remirepo spec for php-guzzlehttp-ringphp, from Fedora:
#
# Fedora spec file for php-behat-mink
#
# Copyright (c) 2015-2017 Shawn Iwinski <shawn@iwin.ski>
#
# License: MIT
# http://opensource.org/licenses/MIT
#
# Please preserve changelog entries
#

%global github_owner     minkphp
%global github_name      Mink
%global github_version   1.7.1
%global github_commit    e6930b9c74693dff7f4e58577e1b1743399f3ff9

%global composer_vendor  behat
%global composer_project mink

# "php": ">=5.3.1"
%global php_min_ver 5.3.1
# "symfony/css-selector": "~2.1|~3.0"
#     NOTE: Min version not 2.1 because autoloader required
%global symfony_min_ver %{?el6:2.3.31}%{!?el6:2.7.1}
%global symfony_max_ver 4.0

# Build using "--without tests" to disable tests
%global with_tests 0%{!?_without_tests:1}

%global phpdir   %{_datadir}/php
%global testsdir %{_datadir}/tests

Name:          php-%{composer_vendor}-%{composer_project}
Version:       %{github_version}
Release:       5%{?dist}
Summary:       Browser controller/emulator abstraction for PHP

Group:         Development/Libraries
License:       MIT
URL:           http://mink.behat.org/

# GitHub export does not include tests.
# Run php-behat-mink-get-source.sh to create full source.
Source0:       %{name}-%{github_version}-%{github_commit}.tar.gz
Source1:       %{name}-get-source.sh

# Modify driver testsuite bootstrap
Patch0:        %{name}-driver-testsuite-bootstrap.patch
# [Selector/NamedSelector] Fix PHP 7.2 count() errors
# https://github.com/minkphp/Mink/pull/736
# https://github.com/minkphp/Mink/pull/736.patch
Patch1:        %{name}-pull-736.patch

BuildArch:     noarch
# Tests
%if %{with_tests}
## composer.json
BuildRequires: php(language) >= %{php_min_ver}
BuildRequires: php-composer(phpunit/phpunit)
BuildRequires: php-composer(symfony/css-selector) <  %{symfony_max_ver}
BuildRequires: php-composer(symfony/css-selector) >= %{symfony_min_ver}
## phpcompatinfo (computed from version 1.7.1)
BuildRequires: php-dom
BuildRequires: php-gd
BuildRequires: php-json
BuildRequires: php-mbstring
BuildRequires: php-pcre
BuildRequires: php-reflection
BuildRequires: php-session
BuildRequires: php-spl
## Autoloader
BuildRequires: php-composer(fedora/autoloader)
%endif

# composer.json
Requires:      php(language) >= %{php_min_ver}
Requires:      php-composer(symfony/css-selector) >= %{symfony_min_ver}
Requires:      php-composer(symfony/css-selector) <  %{symfony_max_ver}
# phpcompatinfo (computed from version 1.7.1)
Requires:      php-mbstring
Requires:      php-pcre
Requires:      php-spl
# Autoloader
Requires:      php-composer(fedora/autoloader)

# Composer
Provides:      php-composer(%{composer_vendor}/%{composer_project}) = %{version}

%description
One of the most important parts in the web is a browser. Browser is the window
through which web users interact with web applications and other users. Users
are always talking with web applications through browsers.

So, in order to test that our web application behaves correctly, we need a way
to simulate this interaction between the browser and the web application in our
tests. We need a Mink.

Mink is an open source browser controller/emulator for web applications,
written in PHP.

Read Mink at a Glance [1] to learn more about Mink and why you need it.

Autoloader: %{phpdir}/Behat/Mink/autoload.php

[1] http://mink.behat.org/en/latest/at-a-glance.html

# ------------------------------------------------------------------------------

%package driver-testsuite

Summary:   Mink driver testsuite
Group:     Development/Libraries

Requires:  %{name} = %{version}-%{release}
# phpcompatinfo (computed from version 1.7.0)
Requires:  php-gd
Requires:  php-json
Requires:  php-pcre
Requires:  php-reflection
Requires:  php-session
Requires:  php-spl

# Bundled
## driver-testsuite/web-fixtures/js/jquery-1.6.2-min.js
Provides:  bundled(js-jquery1) = 1.6.2
## driver-testsuite/web-fixtures/js/jquery-ui-1.8.14.custom.min.js
Provides:  bundled(js-jquery-ui) = 1.8.14

%description driver-testsuite
%{summary}.

Autoloader: %{testsdir}/%{name}-driver-testsuite/autoload.php
Bootstrap: %{testsdir}/%{name}-driver-testsuite/boostrap.php

# ------------------------------------------------------------------------------

%prep
%setup -qn %{github_name}-%{github_commit}

: Patch driver testsuite bootstrap
%patch0 -p1

: [Selector/NamedSelector] Fix PHP 7.2 count function errors
%patch1 -p1


%build
: Create library autoloader
cat <<'AUTOLOAD' | tee src/autoload.php
<?php
/**
 * Autoloader for %{name} and its' dependencies
 * (created by %{name}-%{version}-%{release}).
 */
require_once '%{phpdir}/Fedora/Autoloader/autoload.php';

\Fedora\Autoloader\Autoload::addPsr4('Behat\\Mink\\', __DIR__);

\Fedora\Autoloader\Dependencies::required(array(
    array(
        '%{phpdir}/Symfony3/Component/CssSelector/autoload.php',
        '%{phpdir}/Symfony/Component/CssSelector/autoload.php',
    ),
));
AUTOLOAD

: Create driver testsuite autoloader
cat <<'AUTOLOAD' | tee driver-testsuite/autoload.php
<?php
/**
 * Autoloader for %{name} and its' dependencies
 * (created by %{name}-%{version}-%{release}).
 */
require_once '%{phpdir}/Fedora/Autoloader/autoload.php';

\Fedora\Autoloader\Autoload::addPsr4('Behat\\Mink\\Tests\\Driver\\', __DIR__.'/tests');

\Fedora\Autoloader\Dependencies::required(array(
    '%{phpdir}/Behat/Mink/autoload.php',
));
AUTOLOAD


%install
: Library
mkdir -p  %{buildroot}%{phpdir}/Behat/Mink
cp -pr src/* %{buildroot}%{phpdir}/Behat/Mink/

: Driver testsuite
mkdir -p %{buildroot}%{testsdir}
cp -pr driver-testsuite %{buildroot}%{testsdir}/%{name}-driver-testsuite


%check
%if %{with_tests}
: Create tests autoloader
cat <<'AUTOLOAD' | tee bootstrap.php
<?php
require_once '%{buildroot}%{phpdir}/Behat/Mink/autoload.php';
\Fedora\Autoloader\Autoload::addPsr4('Behat\\Mink\\Tests\\', __DIR__.'/tests');
AUTOLOAD

%if 0%{?el6}
: Skip tests requiring PHPUnit with the "willReturn" function
sed 's/function testCreateNodeElements/function SKIP_testCreateNodeElements/' \
    -i tests/Driver/CoreDriverTest.php
sed 's/function testGetResponseHeader/function SKIP_testGetResponseHeader/' \
    -i tests/SessionTest.php
sed 's/function testAddressEqualsEmptyPath/function SKIP_testAddressEqualsEmptyPath/' \
    -i tests/WebAssertTest.php
%endif

: Upstream tests
RETURN_CODE=0
PHPUNIT=$(which phpunit)
for PHP_EXEC in "" %{?rhel:php54 php55} php56 php70 php71 php72; do
    if [ -z "$PHP_EXEC" ] || which $PHP_EXEC; then
        $PHP_EXEC $PHPUNIT --verbose --bootstrap bootstrap.php || RETURN_CODE=1
    fi
done
exit $RETURN_CODE
%else
: Tests skipped
%endif


%files
%{!?_licensedir:%global license %%doc}
%license LICENSE
%doc *.md
%doc composer.json
%dir %{phpdir}/Behat
     %{phpdir}/Behat/Mink

%files driver-testsuite
%dir %{testsdir}
     %{testsdir}/%{name}-driver-testsuite


%changelog
* Fri Sep 22 2017 Shawn Iwinski <shawn@iwin.ski> - 1.7.1-5
- Fix autoloader for Symfony 3

* Fri May 12 2017 Shawn Iwinski <shawn@iwin.ski> - 1.7.1-3
- Switch autoloader to php-composer(fedora/autoloader)
- Add max versions to build dependencies
- Test with SCLs if available

* Sat Feb 11 2017 Fedora Release Engineering <releng@fedoraproject.org> - 1.7.1-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild

* Tue Aug 09 2016 Shawn Iwinski <shawn@iwin.ski> - 1.7.1-1
- Updated to 1.7.1 (RHBZ #1314987)

* Tue Dec  1 2015 Remi Collet <remi@fedoraproject.org> - 1.7.0-1
- backport for remi repository

* Wed Nov 25 2015 Shawn Iwinski <shawn@iwin.ski> - 1.7.0-1
- Initial package