summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Makefile4
-rw-r--r--bootstrap-autoload.patch29
-rw-r--r--composer.json18
-rw-r--r--php-hamcrest-upstream.patch69
-rw-r--r--php-hamcrest2.spec72
5 files changed, 68 insertions, 124 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..91b0fd5
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,4 @@
+SRCDIR := $(shell pwd)
+NAME := $(shell basename $(SRCDIR))
+include ../../common/Makefile
+
diff --git a/bootstrap-autoload.patch b/bootstrap-autoload.patch
index 49cad37..df475dd 100644
--- a/bootstrap-autoload.patch
+++ b/bootstrap-autoload.patch
@@ -1,18 +1,25 @@
-diff -up tests/bootstrap.php.rpm tests/bootstrap.php
---- tests/bootstrap.php.rpm 2015-01-05 13:27:31.069437796 +0100
-+++ tests/bootstrap.php 2015-01-05 13:27:40.291470405 +0100
-@@ -1,6 +1,7 @@
- <?php
+diff -up ./hamcrest/Hamcrest/Util.php.rpm ./hamcrest/Hamcrest/Util.php
+--- ./hamcrest/Hamcrest/Util.php.rpm 2018-01-22 09:48:17.689161741 +0100
++++ ./hamcrest/Hamcrest/Util.php 2018-01-22 09:48:24.644197714 +0100
+@@ -14,7 +14,7 @@ class Util
+ {
+ public static function registerGlobalFunctions()
+ {
+- require_once __DIR__.'/../Hamcrest.php';
++ require_once __DIR__.'/Hamcrest.php';
+ }
+
+ /**
+diff -up ./tests/bootstrap.php.rpm ./tests/bootstrap.php
+--- ./tests/bootstrap.php.rpm 2016-01-20 09:20:44.000000000 +0100
++++ ./tests/bootstrap.php 2018-01-22 09:46:19.525550567 +0100
+@@ -2,7 +2,8 @@
+
error_reporting(E_ALL | E_STRICT);
+
-require __DIR__ . '/../vendor/autoload.php';
+require __DIR__ . '/../hamcrest/Hamcrest/autoload.php';
+require __DIR__ . '/autoload.php';
if (defined('E_DEPRECATED')) {
error_reporting(error_reporting() | E_DEPRECATED);
-@@ -14,5 +15,3 @@ set_include_path(implode(PATH_SEPARATOR,
- HAMCREST_BASE . '/hamcrest',
- get_include_path()
- )));
--
--require_once 'Hamcrest.php';
diff --git a/composer.json b/composer.json
index a1b48c1..5349f5f 100644
--- a/composer.json
+++ b/composer.json
@@ -8,25 +8,31 @@
],
"autoload": {
- "classmap": ["hamcrest"],
- "files": ["hamcrest/Hamcrest.php"]
+ "classmap": ["hamcrest"]
},
"autoload-dev": {
"classmap": ["tests", "generator"]
},
"require": {
- "php": ">=5.3.2"
+ "php": "^5.3|^7.0"
},
"require-dev": {
- "satooshi/php-coveralls": "dev-master",
- "phpunit/php-file-iterator": "1.3.3"
+ "satooshi/php-coveralls": "^1.0",
+ "phpunit/php-file-iterator": "1.3.3",
+ "phpunit/phpunit": "~4.0"
},
"replace": {
"kodova/hamcrest-php": "*",
"davedevelopment/hamcrest-php": "*",
"cordoval/hamcrest-php": "*"
- }
+ },
+
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.0-dev"
+ }
+ }
}
diff --git a/php-hamcrest-upstream.patch b/php-hamcrest-upstream.patch
deleted file mode 100644
index 65c3ec6..0000000
--- a/php-hamcrest-upstream.patch
+++ /dev/null
@@ -1,69 +0,0 @@
-From c2aecc2127c92e5e6a77b9b23bf3f409ffd56e4a Mon Sep 17 00:00:00 2001
-From: mikeSimonson <mike.simonson@gmail.com>
-Date: Wed, 6 Jan 2016 22:26:02 +0100
-Subject: [PATCH] Removing php 7 from the allowed failure
-
-Fixing the backward incompatible change of PHP 7 and adding tests for it.
----
- .travis.yml | 1 -
- hamcrest/Hamcrest/Type/IsNumeric.php | 20 ++++++++++++++++++++
- tests/Hamcrest/Type/IsNumericTest.php | 4 ++++
- 3 files changed, 24 insertions(+), 1 deletion(-)
-
-diff --git a/hamcrest/Hamcrest/Type/IsNumeric.php b/hamcrest/Hamcrest/Type/IsNumeric.php
-index 9fe8a7a..bc74405 100644
---- a/hamcrest/Hamcrest/Type/IsNumeric.php
-+++ b/hamcrest/Hamcrest/Type/IsNumeric.php
-@@ -19,10 +19,30 @@ public function __construct()
-
- public function matches($item)
- {
-+ if ($this->isHexadecimal($item)) {
-+ return true;
-+ }
-+
- return is_numeric($item);
- }
-
- /**
-+ * Return if the string passed is a valid hexadecimal number.
-+ * This check is necessary because PHP 7 doesn't recognize hexadecimal string as numeric anymore.
-+ *
-+ * @param mixed $item
-+ * @return boolean
-+ */
-+ private function isHexadecimal($item)
-+ {
-+ if (is_string($item) && preg_match('/^0x(.*)$/', $item, $matches)) {
-+ return ctype_xdigit($matches[1]);
-+ }
-+
-+ return false;
-+ }
-+
-+ /**
- * Is the value a numeric?
- *
- * @factory
-diff --git a/tests/Hamcrest/Type/IsNumericTest.php b/tests/Hamcrest/Type/IsNumericTest.php
-index e718485..1fd83ef 100644
---- a/tests/Hamcrest/Type/IsNumericTest.php
-+++ b/tests/Hamcrest/Type/IsNumericTest.php
-@@ -25,6 +25,7 @@ public function testEvaluatesToTrueIfArgumentMatchesType()
- assertThat('0.053e-2', numericValue());
- assertThat('-53.253e+25', numericValue());
- assertThat('+53.253e+25', numericValue());
-+ assertThat(0x4F2a04, numericValue());
- assertThat('0x4F2a04', numericValue());
- }
-
-@@ -34,6 +35,9 @@ public function testEvaluatesToFalseIfArgumentDoesntMatchType()
- assertThat('foo', not(numericValue()));
- assertThat('foo5', not(numericValue()));
- assertThat('5foo', not(numericValue()));
-+ assertThat('0x42A04G', not(numericValue())); // G is not in the hexadecimal range.
-+ assertThat('1x42A04', not(numericValue())); // 1x is not a valid hexadecimal sequence.
-+ assertThat('0x', not(numericValue()));
- }
-
- public function testHasAReadableDescription()
diff --git a/php-hamcrest2.spec b/php-hamcrest2.spec
index 3742c53..8e261b8 100644
--- a/php-hamcrest2.spec
+++ b/php-hamcrest2.spec
@@ -1,48 +1,54 @@
# remirepo/fedora spec file for php-hamcrest
#
-# Copyright (c) 2015-2017 Remi Collet
+# Copyright (c) 2015-2018 Remi Collet
# License: CC-BY-SA
# http://creativecommons.org/licenses/by-sa/4.0/
#
# Please, preserve the changelog entries
#
-%global gh_commit b37020aa976fa52d3de9aa904aa2522dc518f79c
+%global gh_commit 776503d3a8e85d4f9a1148614f95b7a608b046ad
%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
%global with_tests 0%{!?_without_tests:1}
-Name: php-hamcrest
-Version: 1.2.2
-Release: 4%{?dist}
+Name: php-hamcrest2
+Version: 2.0.0
+Release: 1%{?dist}
Summary: PHP port of Hamcrest Matchers
Group: Development/Libraries
License: BSD
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
+Source0: https://github.com/%{gh_owner}/%{gh_project}/archive/%{gh_commit}/%{name}-%{version}-%{gh_short}.tar.gz
# Use generated autoloader instead of composer one
Patch0: bootstrap-autoload.patch
-# Upstream patch for PHP 7+
-Patch1: %{name}-upstream.patch
-BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildArch: noarch
BuildRequires: php-fedora-autoloader-devel
%if %{with_tests}
+# From composer.json, require-dev:
+# "satooshi/php-coveralls": "^1.0",
+# "phpunit/php-file-iterator": "1.3.3",
+# "phpunit/phpunit": "~4.0"
BuildRequires: php-composer(phpunit/phpunit)
-# composer.json
-# "php": ">=5.3.2"
-BuildRequires: php(language) >= 5.3.2
-# From phpcompatinfo report for 1.2.2
+# composer.json, require:
+# "php": "^5.3|^7.0"
+BuildRequires: php(language) >= 5.3
+# From phpcompatinfo report for 2.0.0
+BuildRequires: php-reflection
+BuildRequires: php-ctype
BuildRequires: php-dom
BuildRequires: php-pcre
BuildRequires: php-spl
%endif
-Requires: php(language) >= 5.3.2
-# From phpcompatinfo report for 1.2.2
+Requires: php(language) >= 5.3
+# From phpcompatinfo report for 2.0.0
+Requires: php-ctype
Requires: php-dom
Requires: php-pcre
Requires: php-spl
@@ -60,45 +66,36 @@ but subsequently ported to many other languages.
a literal translation of the original Java API for Hamcrest,
with a few Exceptions, mostly down to PHP language barriers.
-To use this library, you just have to add, in your project:
- require_once '%{_datadir}/php/Hamcrest/autoload.php';
+Autoloader: %{_datadir}/php/%{ns_project}%{major}/autoload.php
%prep
%setup -q -n %{gh_project}-%{gh_commit}
%patch0 -p0 -b .rpm
-%patch1 -p1 -b .upstream
-find . -name \*.upstream -exec rm {} \;
+find . -name \*.rpm -exec rm {} \;
# Move to Library tree
-mv hamcrest/Hamcrest.php hamcrest/Hamcrest/Hamcrest.php
+mv hamcrest/%{ns_project}.php hamcrest/%{ns_project}/%{ns_project}.php
%build
# Library autoloader
%{_bindir}/phpab \
--template fedora \
- --output hamcrest/Hamcrest/autoload.php \
- hamcrest/Hamcrest
-
-cat << 'EOF' | tee -a hamcrest/Hamcrest/autoload.php
-
-// Functions
-require __DIR__ . '/Hamcrest.php';
-EOF
+ --output hamcrest/%{ns_project}/autoload.php \
+ hamcrest/%{ns_project}
# Test suite autoloader
%{_bindir}/phpab \
--output tests/autoload.php \
--exclude '*Test.php' \
- tests
+ tests generator
%install
-rm -rf %{buildroot}
-mkdir -p %{buildroot}%{_datadir}/php
-cp -pr hamcrest/* %{buildroot}%{_datadir}/php
+mkdir -p %{buildroot}%{_datadir}/php
+cp -pr hamcrest/%{ns_project} %{buildroot}%{_datadir}/php/%{ns_project}%{major}
%check
@@ -116,20 +113,19 @@ exit $ret
%endif
-%clean
-rm -rf %{buildroot}
-
-
%files
-%defattr(-,root,root,-)
%{!?_licensedir:%global license %%doc}
%license LICENSE.txt
%doc CHANGES.txt README.md TODO.txt
%doc composer.json
-%{_datadir}/php/Hamcrest
+%{_datadir}/php/%{ns_project}%{major}
%changelog
+* 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