summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemi Collet <remi@remirepo.net>2020-11-26 08:33:53 +0100
committerRemi Collet <remi@remirepo.net>2020-11-26 08:33:53 +0100
commitce7a71c1c059d90399c31c5fe22d8f328e33070e (patch)
treeae41c606322946bc7e1a213be7686eb0ad28662d
new package
-rw-r--r--.gitignore9
-rw-r--r--Makefile4
-rw-r--r--composer.json71
-rwxr-xr-xmakesrc.sh28
-rw-r--r--php-yoast-phpunit-polyfills-layout.patch11
-rw-r--r--php-yoast-phpunit-polyfills.spec155
6 files changed, 278 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..01f0400
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,9 @@
+clog
+package-*.xml
+*.tgz
+*.tar.bz2
+*.tar.gz
+*.tar.xz
+*.tar.xz.asc
+*.src.rpm
+*/*rpm
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/composer.json b/composer.json
new file mode 100644
index 0000000..ece8171
--- /dev/null
+++ b/composer.json
@@ -0,0 +1,71 @@
+{
+ "name": "yoast/phpunit-polyfills",
+ "description": "Set of polyfills for changed PHPUnit functionality to allow for creating PHPUnit cross-version compatible tests",
+ "type": "library",
+ "keywords": [ "phpunit", "polyfill", "testing" ],
+ "license": "BSD-3-Clause",
+ "homepage": "https://github.com/Yoast/PHPUnit-Polyfills",
+ "authors": [
+ {
+ "name" : "Team Yoast",
+ "email" : "support@yoast.com",
+ "homepage": "https://yoast.com"
+ },
+ {
+ "name" : "Contributors",
+ "homepage": "https://github.com/Yoast/PHPUnit-Polyfills/graphs/contributors"
+ }
+ ],
+ "support": {
+ "issues": "https://github.com/Yoast/PHPUnit-Polyfills/issues",
+ "source": "https://github.com/Yoast/PHPUnit-Polyfills"
+ },
+ "minimum-stability": "dev",
+ "prefer-stable": true,
+ "require": {
+ "php": ">=5.5",
+ "phpunit/phpunit": "^4.8.36 || ^5.7.21 || ^6.0 || ^7.0 || ^8.0 || ^9.0"
+ },
+ "require-dev": {
+ "php-parallel-lint/php-parallel-lint": "^1.2.0",
+ "php-parallel-lint/php-console-highlighter": "^0.5",
+ "yoast/yoastcs": "^2.1.0"
+ },
+ "autoload": {
+ "files": ["phpunitpolyfills-autoload.php"]
+ },
+ "autoload-dev" : {
+ "psr-4": {
+ "Yoast\\PHPUnitPolyfills\\Tests\\": "tests/"
+ }
+ },
+ "extra": {
+ "branch-alias": {
+ "dev-main": "1.x-dev",
+ "dev-develop": "1.x-dev"
+ }
+ },
+ "scripts": {
+ "lint": [
+ "@php ./vendor/php-parallel-lint/php-parallel-lint/parallel-lint . -e php --exclude vendor --exclude .git"
+ ],
+ "lint-lt71": [
+ "@php ./vendor/php-parallel-lint/php-parallel-lint/parallel-lint . -e php --exclude vendor --exclude .git --exclude src/TestCases/TestCasePHPUnitGte8.php --exclude src/TestListeners/TestListenerDefaultImplementationPHPUnitGte7.php"
+ ],
+ "check-cs": [
+ "@php ./vendor/squizlabs/php_codesniffer/bin/phpcs"
+ ],
+ "fix-cs": [
+ "@php ./vendor/squizlabs/php_codesniffer/bin/phpcbf"
+ ],
+ "test": [
+ "@php ./vendor/phpunit/phpunit/phpunit --no-coverage"
+ ],
+ "coverage": [
+ "@php ./vendor/phpunit/phpunit/phpunit"
+ ],
+ "coverage-local": [
+ "@php ./vendor/phpunit/phpunit/phpunit --coverage-html ./build/coverage-html"
+ ]
+ }
+}
diff --git a/makesrc.sh b/makesrc.sh
new file mode 100755
index 0000000..f578f06
--- /dev/null
+++ b/makesrc.sh
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+NAME=$(basename $PWD)
+OWNER=$(sed -n '/^%global gh_owner/{s/.* //;p}' $NAME.spec)
+PROJECT=$(sed -n '/^%global gh_project/{s/.* //;p}' $NAME.spec)
+VERSION=$(sed -n '/^Version:/{s/.* //;p}' $NAME.spec)
+COMMIT=$(sed -n '/^%global gh_commit/{s/.* //;p}' $NAME.spec)
+SHORT=${COMMIT:0:7}
+
+echo -e "\nCreate git snapshot\nName=$NAME, Owner=$OWNER, Project=$PROJECT, Version=$VERSION, Commit=$COMMIT\n"
+
+echo "Cloning..."
+git clone https://github.com/$OWNER/$PROJECT.git $PROJECT-$COMMIT
+
+echo "Getting commit..."
+pushd $PROJECT-$COMMIT
+git checkout $COMMIT || exit 1
+cp composer.json ../composer.json
+popd
+
+echo "Archiving..."
+tar czf $NAME-$VERSION-$SHORT.tgz --exclude .git $PROJECT-$COMMIT
+
+echo "Cleaning..."
+rm -rf $PROJECT-$COMMIT
+
+echo "Done."
+
diff --git a/php-yoast-phpunit-polyfills-layout.patch b/php-yoast-phpunit-polyfills-layout.patch
new file mode 100644
index 0000000..637d51b
--- /dev/null
+++ b/php-yoast-phpunit-polyfills-layout.patch
@@ -0,0 +1,11 @@
+diff -up ./phpunitpolyfills-autoload.php.rpm ./phpunitpolyfills-autoload.php
+--- ./phpunitpolyfills-autoload.php.rpm 2020-11-26 07:45:13.798777427 +0100
++++ ./phpunitpolyfills-autoload.php 2020-11-26 07:45:29.603748277 +0100
+@@ -88,7 +88,6 @@ if ( \class_exists( 'Yoast\PHPUnitPolyfi
+ default:
+ $file = \realpath(
+ __DIR__ . \DIRECTORY_SEPARATOR
+- . 'src' . \DIRECTORY_SEPARATOR
+ . \strtr( \substr( $class, 23 ), '\\', \DIRECTORY_SEPARATOR ) . '.php'
+ );
+
diff --git a/php-yoast-phpunit-polyfills.spec b/php-yoast-phpunit-polyfills.spec
new file mode 100644
index 0000000..c7812dc
--- /dev/null
+++ b/php-yoast-phpunit-polyfills.spec
@@ -0,0 +1,155 @@
+# 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 c48e4cf0c44b2d892540846aff19fb0468627bab
+%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: 0.2.0
+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
+
+Patch0: %{name}-layout.patch
+
+BuildArch: noarch
+%if %{with tests}
+BuildRequires: php(language) >= 5.5
+BuildRequires: php-reflection
+# From composer.json, "require-dev": {
+# "php-parallel-lint/php-parallel-lint": "^1.2.0",
+# "php-parallel-lint/php-console-highlighter": "^0.5",
+# "yoast/yoastcs": "^2.1.0"
+%if 0%{?fedora} >= 32 || 0%{?rhel} >= 9
+BuildRequires: phpunit9
+%endif
+BuildRequires: phpunit8
+BuildRequires: phpunit7
+BuildRequires: phpunit6
+BuildRequires: phpunit
+BuildRequires: php-fedora-autoloader-devel
+%endif
+
+# From composer.json, "require": {
+# "php": ">=5.5",
+# "phpunit/phpunit": "^4.8.36 || ^5.7.21 || ^6.0 || ^7.0 || ^8.0 || ^9.0"
+Requires: php(language) >= 5.5
+# 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
+%patch0 -p1 -b .rpm
+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; 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; 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
+* Thu Nov 26 2020 Remi Collet <remi@remirepo.net> - 0.2.0-1
+- initial rpm