From 60e76f54e49b8482ee71515600ae252ab38d643a Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Fri, 16 Oct 2015 09:14:43 +0200 Subject: php-deepend-Mockery: 0.9.4 --- mockery-autoload.php | 18 +++++++++++ mockery-tests.patch | 37 +++++++++++++++++++++ php-deepend-Mockery.spec | 84 ++++++++++++++++++++++++++++++++++++++++-------- 3 files changed, 126 insertions(+), 13 deletions(-) create mode 100644 mockery-autoload.php create mode 100644 mockery-tests.patch diff --git a/mockery-autoload.php b/mockery-autoload.php new file mode 100644 index 0000000..5142be5 --- /dev/null +++ b/mockery-autoload.php @@ -0,0 +1,18 @@ +register(); +} + +$fedoraClassLoader->addPrefix('Mockery', dirname(__DIR__)); + +// dependencies +require_once $vendorDir . '/Hamcrest/autoload.php'; diff --git a/mockery-tests.patch b/mockery-tests.patch new file mode 100644 index 0000000..8dc59f7 --- /dev/null +++ b/mockery-tests.patch @@ -0,0 +1,37 @@ +diff -up tests/Bootstrap.php.rpm tests/Bootstrap.php +--- tests/Bootstrap.php.rpm 2015-10-16 08:42:02.861800156 +0200 ++++ tests/Bootstrap.php 2015-10-16 08:49:18.755612204 +0200 +@@ -29,13 +29,13 @@ error_reporting(E_ALL); + * distribution. + */ + $root = realpath(dirname(dirname(__FILE__))); +-$library = "$root/library"; ++$library = "@BUILD@"; + $tests = "$root/tests"; + + /** + * Check that --dev composer installation was done + */ +-if (!file_exists($root . '/vendor/autoload.php')) { ++if (!file_exists($library . '/Mockery/autoload.php')) { + throw new Exception( + 'Please run "php composer.phar install --dev" in root directory ' + . 'to setup unit test dependencies before running the tests' +@@ -54,7 +54,7 @@ $path = array( + ); + set_include_path(implode(PATH_SEPARATOR, $path)); + +-require_once "$root/vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest.php"; ++require_once '/usr/share/php/Hamcrest/Hamcrest.php'; + + if (defined('TESTS_GENERATE_REPORT') && TESTS_GENERATE_REPORT === true && + version_compare(PHPUnit_Runner_Version::id(), '3.1.6', '>=')) { +@@ -77,7 +77,7 @@ if (defined('TESTS_GENERATE_REPORT') && + PHPUnit_Util_Filter::addDirectoryToFilter(PHP_LIBDIR); + } + +-require __DIR__.'/../vendor/autoload.php'; ++require $library . '/Mockery/autoload.php'; + + /* + * Unset global variables that are no longer needed. diff --git a/php-deepend-Mockery.spec b/php-deepend-Mockery.spec index f5b8e60..bbd6c5d 100644 --- a/php-deepend-Mockery.spec +++ b/php-deepend-Mockery.spec @@ -1,23 +1,60 @@ +# remirepo spec file for php-deepend-Mockery, from +# +# Fedora spec file for php-deepend-Mockery +# +# License: MIT +# http://opensource.org/licenses/MIT +# +# Please preserve changelog entries +# +%global gh_commit 70bba85e4aabc9449626651f48b9018ede04f86b +%global gh_short %(c=%{gh_commit}; echo ${c:0:7}) +%global gh_owner padraic +%global gh_project mockery +%global with_tests 0%{!?_without_tests:1} + Name: php-deepend-Mockery -Version: 0.9.1 -Release: 2%{?dist} +Version: 0.9.4 +Release: 1%{?dist} Summary: Mockery is a simple but flexible PHP mock object framework Group: Development/Libraries License: BSD -URL: http://github.com/padraic/mockery -Source0: https://github.com/padraic/mockery/archive/%{version}/mockery-%{version}.tar.gz +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 + +# Autoloader +Source1: %{gh_project}-autoload.php + +# Use our autoloader +Patch0: %{gh_project}-tests.patch BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildArch: noarch -# TODO: enable tests -# TODO: make hamcrest as dependency for additional features +%if %{with_tests} +# From composer.json, "require-dev": { +# "phpunit/phpunit": "~4.0" +BuildRequires: php-composer(phpunit/phpunit) >= 4.0 +BuildRequires: php(language) >= 5.3.2 +BuildRequires: php-composer(hamcrest/hamcrest-php) >= 1.1 +# Autoloader +BuildRequires: php-composer(symfony/class-loader) +%endif + +# From composer.json, "require": { +# "php": ">=5.3.2", +# "lib-pcre": ">=7.0", +# "hamcrest/hamcrest-php": "~1.1" Requires: php(language) >= 5.3.2 -#Requires: pcre >= 7.0 +Requires: php-composer(hamcrest/hamcrest-php) >= 1.1 +Requires: php-composer(hamcrest/hamcrest-php) < 2 +# From phpcompatinfo report for version 0.9.4 Requires: php-pcre Requires: php-spl Requires: php-reflection +# Autoloader +Requires: php-composer(symfony/class-loader) Provides: php-composer(mockery/mockery) = %{version} Provides: php-pear(pear.survivethedeepend.com/Mockery) = %{version} @@ -29,8 +66,15 @@ Mockery is a simple but flexible PHP mock object framework for use in unit testing. It is inspired by Ruby's flexmock and Java's Mockito, borrowing elements from both of their APIs. +To use this library, you just have to add, in your project: + require_once '%{_datadir}/php/Mockery/autoload.php'; + + %prep -%setup -q -n mockery-%{version} +%setup -q -n %{gh_project}-%{gh_commit} + +cp %{SOURCE1} library/Mockery/autoload.php +%patch0 -p0 -b .rpm %build @@ -39,6 +83,7 @@ elements from both of their APIs. %install rm -rf %{buildroot} + mkdir -p %{buildroot}/%{_datadir}/php cp -rp library/* %{buildroot}/%{_datadir}/php/ @@ -48,10 +93,13 @@ rm -rf %{buildroot} %check -# We need this packages to pass tests -# hamcrest/hamcrest-php: ~1.1 -# satooshi/php-coveralls: ~0.7@dev -# phpunit --include-path ./library:./tests -d date.timezone="UTC" +%if %{with_tests} +: Use installed tree and our autoloader +sed -e 's:@BUILD@:%{buildroot}/%{_datadir}/php:' -i tests/Bootstrap.php + +: Run upstream test suite +%{_bindir}/phpunit --verbose +%endif %post @@ -63,12 +111,22 @@ fi %files %defattr(-,root,root,-) -%doc LICENSE README.md docs/* +%{!?_licensedir:%global license %%doc} +%license LICENSE +%doc README.md docs +%doc composer.json %{_datadir}/php/Mockery/ %{_datadir}/php/Mockery.php %changelog +* Fri Oct 16 2015 Remi Collet - 0.9.4-1 +- Update to 0.9.4 +- add autoloader using symfony/class-loader +- add dependency on hamcrest/hamcrest-php +- run test suite +- use github archive from commit reference + * Wed Jul 16 2014 Igor Gnatenko - 0.9.1-2 - fixed requires (Remi) - add script which will delete older pear package if installed (Remi) -- cgit