# remirepo/fedora spec file for php-mock2 # # Copyright (c) 2016-2023 Remi Collet # License: CC-BY-SA-4.0 # http://creativecommons.org/licenses/by-sa/4.0/ # # Please, preserve the changelog entries # %global gh_commit 6240b6f0a76d7b9d1ee4d70e686a7cc711619a9d %global gh_short %(c=%{gh_commit}; echo ${c:0:7}) %global gh_owner php-mock %global gh_project php-mock %global with_tests 0%{!?_without_tests:1} %global major 2 Name: php-mock%{major} Version: 2.4.1 Release: 1%{?dist} Summary: PHP-Mock can mock built-in PHP functions License: WTFPL URL: https://github.com/%{gh_owner}/%{gh_project} Source0: https://github.com/%{gh_owner}/%{gh_project}/archive/%{gh_commit}/%{gh_project}-%{version}-%{gh_short}.tar.gz BuildArch: noarch # 7.4 because of phpunit9 BuildRequires: php(language) >= 7.4 %if %{with_tests} # from composer.json, "require-dev": { # "phpunit/phpunit": "^5.7 || ^6.5 || ^7.5 || ^8.0 || ^9.0 || ^10.0", # "squizlabs/php_codesniffer": "^3.5" BuildRequires: phpunit8 BuildRequires: phpunit9 # TODO phpunit10 but requires php 8.1 %endif # For autoloader BuildRequires: php-composer(fedora/autoloader) # from composer.json, "require": { # "php": "^5.6 || ^7.0 || ^8.0", # "phpunit/php-text-template": "^1 || ^2 || ^3") Requires: php(language) >= 5.6 # remirepo:1 %if 0%{?fedora} >= 27 || 0%{?rhel} >= 8 Requires: (php-composer(phpunit/php-text-template) >= 1 with php-composer(phpunit/php-text-template) < 4) # remirepo:3 %else Requires: php-phpunit-Text-Template %endif # From phpcompatinfo report from version 2.0.0 Requires: php-date Requires: php-reflection Requires: php-spl # For autoloader Requires: php-composer(fedora/autoloader) # remirepo:1 %if 0%{?fedora} > 21 || 0%{?rhel} >= 8 # from composer.json, "suggest": { # "php-mock/php-mock-phpunit": "Allows integration into PHPUnit testcase with the trait PHPMock." Suggests: php-composer(php-mock/php-mock-phpunit) # remirepo:1 %endif Provides: php-composer(%{gh_owner}/%{gh_project}) = %{version} %description PHP-Mock can mock built-in PHP functions (e.g. time()). PHP-Mock relies on PHP's namespace fallback policy. No further extension is needed. Autoloader: %{_datadir}/php/phpmock%{major}/autoload.php %prep %setup -q -n %{gh_project}-%{gh_commit} : Prepare the layout mv tests/autoload.php testload.php mkdir -p rpm/tests rpm/php mv classes rpm/php/phpmock%{major} mv tests rpm/tests/phpmock%{major} : Create autoloader cat << 'AUTOLOAD' | tee rpm/php/phpmock%{major}/autoload.php >rpm/php/phpmock%{major}/autoload.php grep -v '>rpm/php/phpmock%{major}/autoload.php ln -s ../../php/phpmock%{major}/autoload.php rpm/tests/phpmock%{major}/autoload.php : Fix autoloader path sed -e 's:../autoload.php:autoload.php:' \ -i rpm/tests/phpmock2/AbstractMockTest.php& %build # Nothing %install # Library mkdir -p %{buildroot}%{_datadir} cp -pr rpm/php %{buildroot}%{_datadir}/php cp -pr rpm/tests %{buildroot}%{_datadir}/tests %check %if %{with_tests} ret=0 # testDefiningAfterCallingUnqualified and testEnable may fail locally (ok in mock) if [ -x %{_bindir}/phpunit8 ]; then for cmd in php php80 php81 php82;do if which $cmd; then $cmd %{_bindir}/phpunit8 \ --filter '^((?!(testDefiningAfterCallingUnqualified|testEnable)).)*$' \ --bootstrap %{buildroot}%{_datadir}/tests/phpmock2/autoload.php --verbose rpm/tests || ret=1 fi done fi if [ -x %{_bindir}/phpunit9 ]; then for cmd in php php80 php81 php82 php83;do if which $cmd; then $cmd %{_bindir}/phpunit9 \ --filter '^((?!(testDefiningAfterCallingUnqualified|testEnable)).)*$' \ --bootstrap %{buildroot}%{_datadir}/tests/phpmock2/autoload.php --verbose rpm/tests || ret=1 fi done fi if [ -x %{_bindir}/phpunit10 ]; then for cmd in php php81 php82 php83;do if which $cmd; then $cmd %{_bindir}/phpunit10 \ --filter '^((?!(testDefiningAfterCallingUnqualified|testEnable)).)*$' \ --bootstrap %{buildroot}%{_datadir}/tests/phpmock2/autoload.php rpm/tests || ret=1 fi done fi exit $ret %else : bootstrap build with test suite disabled %endif %files # remirepo:1 %{!?_licensedir:%global license %%doc} %license LICENSE %doc composer.json %doc *.md %{_datadir}/php/phpmock%{major} %{_datadir}/tests/phpmock%{major} %changelog * Tue Jun 13 2023 Remi Collet - 2.4.1-1 - update to 2.4.1 (no change) * Mon Feb 13 2023 Remi Collet - 2.4.0-1 - update to 2.4.0 - allow phpunit10 * Tue Feb 8 2022 Remi Collet - 2.3.1-1 - update to 2.3.1 * Mon Dec 14 2020 Remi Collet - 2.3.0-1 - update to 2.3.0 - switch to phpunit9 * Mon Apr 20 2020 Remi Collet - 2.2.2-1 - update to 2.2.2 * Mon Feb 10 2020 Remi Collet - 2.2.1-1 - update to 2.2.1 - allow phpunit9 and phpunit/php-text-template v2 * Thu Jun 6 2019 Remi Collet - 2.1.2-1 - update to 2.1.2 * Mon Apr 8 2019 Remi Collet - 2.1.1-1 - update to 2.1.1 * Thu Mar 7 2019 Remi Collet - 2.1.0-2 - single autoloader * Wed Mar 6 2019 Remi Collet - 2.1.0-1 - update to 2.1.0 * Fri Mar 23 2018 Remi Collet - 2.0.0-2 - use range dependencies on F27+ * Tue Dec 5 2017 Remi Collet - 2.0.0-1 - rename to php-mock2 - Update to 2.0.0 - raise dependency on PHP 5.6 * Thu May 11 2017 Remi Collet - 1.0.1-4 - switch to fedora/autoloader * Mon Feb 22 2016 Remi Collet - 1.0.1-2 - Fix: license is WTFPL, from review #1306968 * Fri Feb 12 2016 Remi Collet - 1.0.1-1 - initial package