summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--php-jakub-onderka-php-console-highlighter-pr11-phpunit-createMock.patch32
-rw-r--r--php-jakub-onderka-php-console-highlighter.spec137
2 files changed, 169 insertions, 0 deletions
diff --git a/php-jakub-onderka-php-console-highlighter-pr11-phpunit-createMock.patch b/php-jakub-onderka-php-console-highlighter-pr11-phpunit-createMock.patch
new file mode 100644
index 0000000..c5b4b73
--- /dev/null
+++ b/php-jakub-onderka-php-console-highlighter-pr11-phpunit-createMock.patch
@@ -0,0 +1,32 @@
+From 82a388a4b657989985f58855b5f1737ac2fbe5b1 Mon Sep 17 00:00:00 2001
+From: Shawn Iwinski <shawn@iwin.ski>
+Date: Fri, 15 Jul 2016 05:46:05 -0400
+Subject: [PATCH] Update tests to use createMock() instead of getMock() for
+ PHPUnit 5.4+
+
+---
+ tests/JakubOnderka/PhpConsoleHighligter/HigligterTest.php | 6 ++++--
+ 1 file changed, 4 insertions(+), 2 deletions(-)
+
+diff --git a/tests/JakubOnderka/PhpConsoleHighligter/HigligterTest.php b/tests/JakubOnderka/PhpConsoleHighligter/HigligterTest.php
+index 269d03d..8e8b4bf 100644
+--- a/tests/JakubOnderka/PhpConsoleHighligter/HigligterTest.php
++++ b/tests/JakubOnderka/PhpConsoleHighligter/HigligterTest.php
+@@ -8,7 +8,9 @@ class HighlighterTest extends \PHPUnit_Framework_TestCase
+
+ protected function getConsoleColorMock()
+ {
+- $mock = $this->getMock('\JakubOnderka\PhpConsoleColor\ConsoleColor');
++ $mock = method_exists($this, 'createMock')
++ ? $this->createMock('\JakubOnderka\PhpConsoleColor\ConsoleColor')
++ : $this->getMock('\JakubOnderka\PhpConsoleColor\ConsoleColor');
+
+ $mock->expects($this->any())
+ ->method('apply')
+@@ -260,4 +262,4 @@ public function testEmpty()
+ ''
+ );
+ }
+-}
+\ No newline at end of file
++}
diff --git a/php-jakub-onderka-php-console-highlighter.spec b/php-jakub-onderka-php-console-highlighter.spec
new file mode 100644
index 0000000..90e7762
--- /dev/null
+++ b/php-jakub-onderka-php-console-highlighter.spec
@@ -0,0 +1,137 @@
+#
+# Fedora spec file for php-jakub-onderka-php-console-highlighter
+#
+# Copyright (c) 2016 Shawn Iwinski <shawn@iwin.ski>
+#
+# License: MIT
+# http://opensource.org/licenses/MIT
+#
+# Please preserve changelog entries
+#
+
+%global github_owner JakubOnderka
+%global github_name PHP-Console-Highlighter
+%global github_version 0.3.2
+%global github_commit 7daa75df45242c8d5b75a22c00a201e7954e4fb5
+
+%global composer_vendor jakub-onderka
+%global composer_project php-console-highlighter
+
+# "php": ">=5.3.0"
+%global php_min_ver 5.3.0
+# "jakub-onderka/php-console-color": "~0.1"
+%global jakub_onderka_php_console_color_min_ver 0.1
+%global jakub_onderka_php_console_color_max_ver 1.0
+
+# Build using "--without tests" to disable tests
+%global with_tests 0%{!?_without_tests:1}
+
+%{!?phpdir: %global phpdir %{_datadir}/php}
+
+Name: php-%{composer_vendor}-%{composer_project}
+Version: %{github_version}
+Release: 1%{?github_release}%{?dist}
+Summary: Highlight PHP code in console (terminal)
+
+Group: Development/Libraries
+License: MIT
+URL: https://github.com/%{github_owner}/%{github_name}
+Source0: %{url}/archive/%{github_commit}/%{name}-%{github_version}-%{github_commit}.tar.gz
+
+# Update tests to use createMock() instead of getMock() for PHPUnit 5.4+
+# https://github.com/JakubOnderka/PHP-Console-Highlighter/pull/11
+# https://patch-diff.githubusercontent.com/raw/JakubOnderka/PHP-Console-Highlighter/pull/11.patch
+Patch0: %{name}-pr11-phpunit-createMock.patch
+
+BuildArch: noarch
+# Tests
+%if %{with_tests}
+## composer.json
+BuildRequires: php(language) >= %{php_min_ver}
+BuildRequires: php-composer(phpunit/phpunit)
+BuildRequires: php-composer(jakub-onderka/php-console-color) >= %{jakub_onderka_php_console_color_min_ver}
+## phpcompatinfo (computed from version 0.3.2)
+BuildRequires: php-tokenizer
+## Autoloader
+BuildRequires: php-composer(symfony/class-loader)
+%endif
+
+# composer.json
+Requires: php(language) >= %{php_min_ver}
+Requires: php-composer(jakub-onderka/php-console-color) >= %{jakub_onderka_php_console_color_min_ver}
+Requires: php-composer(jakub-onderka/php-console-color) < %{jakub_onderka_php_console_color_max_ver}
+# phpcompatinfo (computed from version 0.3.2)
+Requires: php-tokenizer
+# Autoloader
+Requires: php-composer(symfony/class-loader)
+
+# Composer
+Provides: php-composer(%{composer_vendor}/%{composer_project}) = %{version}
+
+%description
+%{summary}.
+
+Autoloader: %{phpdir}/JakubOnderka/PhpConsoleHighlighter/autoload.php
+
+
+%prep
+%setup -qn %{github_name}-%{github_commit}
+
+: Update tests to use createMock instead of getMock for PHPUnit 5.4+
+%patch0 -p1
+
+
+%build
+: Create autoloader
+cat <<'AUTOLOAD' | tee src/JakubOnderka/PhpConsoleHighlighter/autoload.php
+<?php
+/**
+ * Autoloader for %{name} and its' dependencies
+ * (created by %{name}-%{version}-%{release}).
+ *
+ * @return \Symfony\Component\ClassLoader\ClassLoader
+ */
+
+if (!isset($fedoraClassLoader) || !($fedoraClassLoader instanceof \Symfony\Component\ClassLoader\ClassLoader)) {
+ if (!class_exists('Symfony\\Component\\ClassLoader\\ClassLoader', false)) {
+ require_once '%{phpdir}/Symfony/Component/ClassLoader/ClassLoader.php';
+ }
+
+ $fedoraClassLoader = new \Symfony\Component\ClassLoader\ClassLoader();
+ $fedoraClassLoader->register();
+}
+
+$fedoraClassLoader->addPrefix('JakubOnderka\\PhpConsoleHighlighter\\', dirname(dirname(__DIR__)));
+
+// Required dependency
+require_once '%{phpdir}/JakubOnderka/PhpConsoleColor/autoload.php';
+
+return $fedoraClassLoader;
+AUTOLOAD
+
+
+%install
+mkdir -p %{buildroot}%{phpdir}
+cp -rp src/* %{buildroot}%{phpdir}/
+
+
+%check
+%if %{with_tests}
+%{_bindir}/phpunit --verbose \
+ --bootstrap %{buildroot}%{phpdir}/JakubOnderka/PhpConsoleHighlighter/autoload.php
+%else
+: Tests skipped
+%endif
+
+
+%files
+%{!?_licensedir:%global license %%doc}
+%license LICENSE
+%doc *.md
+%doc composer.json
+%{phpdir}/JakubOnderka/PhpConsoleHighlighter
+
+
+%changelog
+* Fri Jul 15 2016 Shawn Iwinski <shawn@iwin.ski> - 0.3.2-1
+- Initial package