From 5d9e112393d2a18878a96e7cd0153f38aae458bf Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Thu, 21 Jul 2016 18:01:36 +0200 Subject: php-jakub-onderka-php-console-highlighter: import from Fedora --- ...nsole-highlighter-pr11-phpunit-createMock.patch | 32 +++++ php-jakub-onderka-php-console-highlighter.spec | 137 +++++++++++++++++++++ 2 files changed, 169 insertions(+) create mode 100644 php-jakub-onderka-php-console-highlighter-pr11-phpunit-createMock.patch create mode 100644 php-jakub-onderka-php-console-highlighter.spec 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 +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 +# +# 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 +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 - 0.3.2-1 +- Initial package -- cgit