diff --git a/.travis.yml b/.travis.yml index 4d656806..94e7749d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,12 +1,14 @@ language: php +matrix: + include: + - php: 7.0 + dist: precise + php: - - 5.3 - - 5.4 - - 5.5 - - 5.6 - 7.0 - - hhvm + - 7.1 + - 7.2 before_script: - curl -s https://getcomposer.org/installer | php diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..9ac980d4 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +FROM php:7.1.11 + +RUN php -r "readfile('https://getcomposer.org/installer');" > composer-setup.php && \ + php composer-setup.php && \ + php -r "unlink('composer-setup.php');" && \ + mv composer.phar /usr/local/bin/composer + +RUN apt-get update && \ + apt-get install -yqq git && \ + git config --global user.email "test@gitelephant.org" && \ + git config --global user.name "GitElephant tests" && \ + rm -rf /var/lib/apt/lists/* + +RUN apt-get update && \ + apt-get install -yqq zlib1g-dev && \ + docker-php-ext-install zip && \ + rm -rf /var/lib/apt/lists/* diff --git a/README.md b/README.md index 23ddb2a8..a7e8d024 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ The api is completely transparent to the end user. You don't have to worry about Requirements ------------ -- php >= 5.3.0 +- php >= 7.0.0 - *nix system with git installed I work on linux, but the lib should work well with every unix system, as far as a git binary is available. diff --git a/composer.json b/composer.json index 8a7f0580..b7d1ebec 100644 --- a/composer.json +++ b/composer.json @@ -11,14 +11,14 @@ } ], "require": { - "php": ">=5.3.3", - "symfony/process": "~2.0|~3.0", - "symfony/filesystem": "~2.0|~3.0", - "symfony/finder": "~2.0|~3.0", + "php": ">=7.0.0", + "symfony/process": "~2.0|~3.0|~4.0", + "symfony/filesystem": "~2.0|~3.0|~4.0", + "symfony/finder": "~2.0|~3.0|~4.0", "phpcollection/phpcollection": "~0.4" }, "require-dev": { - "phpunit/phpunit": "~4.8", + "phpunit/phpunit": "~6.0", "mockery/mockery": "~0.9" }, "minimum-stability": "stable", @@ -26,10 +26,5 @@ "psr-0": { "GitElephant": "src/" } - }, - "config": { - "platform": { - "php": "5.3.3" - } } } diff --git a/composer.lock b/composer.lock deleted file mode 100644 index 297e62de..00000000 --- a/composer.lock +++ /dev/null @@ -1,1337 +0,0 @@ -{ - "_readme": [ - "This file locks the dependencies of your project to a known state", - "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", - "This file is @generated automatically" - ], - "hash": "dd1c970222d2f3f0621764a098881d98", - "content-hash": "9a13e83dd7398b4e3ec23b95857c0e5d", - "packages": [ - { - "name": "phpcollection/phpcollection", - "version": "0.4.0", - "source": { - "type": "git", - "url": "https://github.com/schmittjoh/php-collection.git", - "reference": "b8bf55a0a929ca43b01232b36719f176f86c7e83" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/schmittjoh/php-collection/zipball/b8bf55a0a929ca43b01232b36719f176f86c7e83", - "reference": "b8bf55a0a929ca43b01232b36719f176f86c7e83", - "shasum": "" - }, - "require": { - "phpoption/phpoption": "1.*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "0.3-dev" - } - }, - "autoload": { - "psr-0": { - "PhpCollection": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "Apache2" - ], - "authors": [ - { - "name": "Johannes M. Schmitt", - "email": "schmittjoh@gmail.com", - "homepage": "https://github.com/schmittjoh", - "role": "Developer of wrapped JMSSerializerBundle" - } - ], - "description": "General-Purpose Collection Library for PHP", - "keywords": [ - "collection", - "list", - "map", - "sequence", - "set" - ], - "time": "2014-03-11 13:46:42" - }, - { - "name": "phpoption/phpoption", - "version": "1.5.0", - "source": { - "type": "git", - "url": "https://github.com/schmittjoh/php-option.git", - "reference": "94e644f7d2051a5f0fcf77d81605f152eecff0ed" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/schmittjoh/php-option/zipball/94e644f7d2051a5f0fcf77d81605f152eecff0ed", - "reference": "94e644f7d2051a5f0fcf77d81605f152eecff0ed", - "shasum": "" - }, - "require": { - "php": ">=5.3.0" - }, - "require-dev": { - "phpunit/phpunit": "4.7.*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.3-dev" - } - }, - "autoload": { - "psr-0": { - "PhpOption\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "Apache2" - ], - "authors": [ - { - "name": "Johannes M. Schmitt", - "email": "schmittjoh@gmail.com" - } - ], - "description": "Option Type for PHP", - "keywords": [ - "language", - "option", - "php", - "type" - ], - "time": "2015-07-25 16:39:46" - }, - { - "name": "symfony/filesystem", - "version": "v2.6.13", - "target-dir": "Symfony/Component/Filesystem", - "source": { - "type": "git", - "url": "https://github.com/symfony/filesystem.git", - "reference": "823c035b1a5c13a4924e324d016eb07e70f94735" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/filesystem/zipball/823c035b1a5c13a4924e324d016eb07e70f94735", - "reference": "823c035b1a5c13a4924e324d016eb07e70f94735", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "symfony/phpunit-bridge": "~2.7" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.6-dev" - } - }, - "autoload": { - "psr-0": { - "Symfony\\Component\\Filesystem\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Filesystem Component", - "homepage": "https://symfony.com", - "time": "2015-07-08 05:59:48" - }, - { - "name": "symfony/finder", - "version": "v2.6.13", - "target-dir": "Symfony/Component/Finder", - "source": { - "type": "git", - "url": "https://github.com/symfony/finder.git", - "reference": "203a10f928ae30176deeba33512999233181dd28" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/finder/zipball/203a10f928ae30176deeba33512999233181dd28", - "reference": "203a10f928ae30176deeba33512999233181dd28", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "symfony/phpunit-bridge": "~2.7" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.6-dev" - } - }, - "autoload": { - "psr-0": { - "Symfony\\Component\\Finder\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Finder Component", - "homepage": "https://symfony.com", - "time": "2015-07-09 16:02:48" - }, - { - "name": "symfony/process", - "version": "v2.6.13", - "target-dir": "Symfony/Component/Process", - "source": { - "type": "git", - "url": "https://github.com/symfony/process.git", - "reference": "57f1e88bb5dafa449b83f9f265b11d52d517b3e9" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/process/zipball/57f1e88bb5dafa449b83f9f265b11d52d517b3e9", - "reference": "57f1e88bb5dafa449b83f9f265b11d52d517b3e9", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "symfony/phpunit-bridge": "~2.7" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.6-dev" - } - }, - "autoload": { - "psr-0": { - "Symfony\\Component\\Process\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Process Component", - "homepage": "https://symfony.com", - "time": "2015-06-30 16:10:16" - } - ], - "packages-dev": [ - { - "name": "doctrine/instantiator", - "version": "1.0.5", - "source": { - "type": "git", - "url": "https://github.com/doctrine/instantiator.git", - "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/doctrine/instantiator/zipball/8e884e78f9f0eb1329e445619e04456e64d8051d", - "reference": "8e884e78f9f0eb1329e445619e04456e64d8051d", - "shasum": "" - }, - "require": { - "php": ">=5.3,<8.0-DEV" - }, - "require-dev": { - "athletic/athletic": "~0.1.8", - "ext-pdo": "*", - "ext-phar": "*", - "phpunit/phpunit": "~4.0", - "squizlabs/php_codesniffer": "~2.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "psr-4": { - "Doctrine\\Instantiator\\": "src/Doctrine/Instantiator/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Marco Pivetta", - "email": "ocramius@gmail.com", - "homepage": "http://ocramius.github.com/" - } - ], - "description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors", - "homepage": "https://github.com/doctrine/instantiator", - "keywords": [ - "constructor", - "instantiate" - ], - "time": "2015-06-14 21:17:01" - }, - { - "name": "hamcrest/hamcrest-php", - "version": "v1.2.2", - "source": { - "type": "git", - "url": "https://github.com/hamcrest/hamcrest-php.git", - "reference": "b37020aa976fa52d3de9aa904aa2522dc518f79c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/hamcrest/hamcrest-php/zipball/b37020aa976fa52d3de9aa904aa2522dc518f79c", - "reference": "b37020aa976fa52d3de9aa904aa2522dc518f79c", - "shasum": "" - }, - "require": { - "php": ">=5.3.2" - }, - "replace": { - "cordoval/hamcrest-php": "*", - "davedevelopment/hamcrest-php": "*", - "kodova/hamcrest-php": "*" - }, - "require-dev": { - "phpunit/php-file-iterator": "1.3.3", - "satooshi/php-coveralls": "dev-master" - }, - "type": "library", - "autoload": { - "classmap": [ - "hamcrest" - ], - "files": [ - "hamcrest/Hamcrest.php" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD" - ], - "description": "This is the PHP port of Hamcrest Matchers", - "keywords": [ - "test" - ], - "time": "2015-05-11 14:41:42" - }, - { - "name": "mockery/mockery", - "version": "0.9.4", - "source": { - "type": "git", - "url": "https://github.com/padraic/mockery.git", - "reference": "70bba85e4aabc9449626651f48b9018ede04f86b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/padraic/mockery/zipball/70bba85e4aabc9449626651f48b9018ede04f86b", - "reference": "70bba85e4aabc9449626651f48b9018ede04f86b", - "shasum": "" - }, - "require": { - "hamcrest/hamcrest-php": "~1.1", - "lib-pcre": ">=7.0", - "php": ">=5.3.2" - }, - "require-dev": { - "phpunit/phpunit": "~4.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "0.9.x-dev" - } - }, - "autoload": { - "psr-0": { - "Mockery": "library/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Pádraic Brady", - "email": "padraic.brady@gmail.com", - "homepage": "http://blog.astrumfutura.com" - }, - { - "name": "Dave Marshall", - "email": "dave.marshall@atstsolutions.co.uk", - "homepage": "http://davedevelopment.co.uk" - } - ], - "description": "Mockery is a simple yet flexible PHP mock object framework for use in unit testing with PHPUnit, PHPSpec or any other testing framework. Its core goal is to offer a test double framework with a succinct API capable of clearly defining all possible object operations and interactions using a human readable Domain Specific Language (DSL). Designed as a drop in alternative to PHPUnit's phpunit-mock-objects library, Mockery is easy to integrate with PHPUnit and can operate alongside phpunit-mock-objects without the World ending.", - "homepage": "http://github.com/padraic/mockery", - "keywords": [ - "BDD", - "TDD", - "library", - "mock", - "mock objects", - "mockery", - "stub", - "test", - "test double", - "testing" - ], - "time": "2015-04-02 19:54:00" - }, - { - "name": "phpdocumentor/reflection-docblock", - "version": "2.0.4", - "source": { - "type": "git", - "url": "https://github.com/phpDocumentor/ReflectionDocBlock.git", - "reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpDocumentor/ReflectionDocBlock/zipball/d68dbdc53dc358a816f00b300704702b2eaff7b8", - "reference": "d68dbdc53dc358a816f00b300704702b2eaff7b8", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.0" - }, - "suggest": { - "dflydev/markdown": "~1.0", - "erusev/parsedown": "~1.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.0.x-dev" - } - }, - "autoload": { - "psr-0": { - "phpDocumentor": [ - "src/" - ] - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Mike van Riel", - "email": "mike.vanriel@naenius.com" - } - ], - "time": "2015-02-03 12:10:50" - }, - { - "name": "phpspec/prophecy", - "version": "v1.5.0", - "source": { - "type": "git", - "url": "https://github.com/phpspec/prophecy.git", - "reference": "4745ded9307786b730d7a60df5cb5a6c43cf95f7" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/phpspec/prophecy/zipball/4745ded9307786b730d7a60df5cb5a6c43cf95f7", - "reference": "4745ded9307786b730d7a60df5cb5a6c43cf95f7", - "shasum": "" - }, - "require": { - "doctrine/instantiator": "^1.0.2", - "phpdocumentor/reflection-docblock": "~2.0", - "sebastian/comparator": "~1.1" - }, - "require-dev": { - "phpspec/phpspec": "~2.0" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.4.x-dev" - } - }, - "autoload": { - "psr-0": { - "Prophecy\\": "src/" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Konstantin Kudryashov", - "email": "ever.zet@gmail.com", - "homepage": "http://everzet.com" - }, - { - "name": "Marcello Duarte", - "email": "marcello.duarte@gmail.com" - } - ], - "description": "Highly opinionated mocking framework for PHP 5.3+", - "homepage": "https://github.com/phpspec/prophecy", - "keywords": [ - "Double", - "Dummy", - "fake", - "mock", - "spy", - "stub" - ], - "time": "2015-08-13 10:07:40" - }, - { - "name": "phpunit/php-code-coverage", - "version": "2.2.4", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "eabf68b476ac7d0f73793aada060f1c1a9bf8979" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/eabf68b476ac7d0f73793aada060f1c1a9bf8979", - "reference": "eabf68b476ac7d0f73793aada060f1c1a9bf8979", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "phpunit/php-file-iterator": "~1.3", - "phpunit/php-text-template": "~1.2", - "phpunit/php-token-stream": "~1.3", - "sebastian/environment": "^1.3.2", - "sebastian/version": "~1.0" - }, - "require-dev": { - "ext-xdebug": ">=2.1.4", - "phpunit/phpunit": "~4" - }, - "suggest": { - "ext-dom": "*", - "ext-xdebug": ">=2.2.1", - "ext-xmlwriter": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.2.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.", - "homepage": "https://github.com/sebastianbergmann/php-code-coverage", - "keywords": [ - "coverage", - "testing", - "xunit" - ], - "time": "2015-10-06 15:47:00" - }, - { - "name": "phpunit/php-file-iterator", - "version": "1.4.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-file-iterator.git", - "reference": "6150bf2c35d3fc379e50c7602b75caceaa39dbf0" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/6150bf2c35d3fc379e50c7602b75caceaa39dbf0", - "reference": "6150bf2c35d3fc379e50c7602b75caceaa39dbf0", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.4.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "FilterIterator implementation that filters files based on a list of suffixes.", - "homepage": "https://github.com/sebastianbergmann/php-file-iterator/", - "keywords": [ - "filesystem", - "iterator" - ], - "time": "2015-06-21 13:08:43" - }, - { - "name": "phpunit/php-text-template", - "version": "1.2.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-text-template.git", - "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/31f8b717e51d9a2afca6c9f046f5d69fc27c8686", - "reference": "31f8b717e51d9a2afca6c9f046f5d69fc27c8686", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Simple template engine.", - "homepage": "https://github.com/sebastianbergmann/php-text-template/", - "keywords": [ - "template" - ], - "time": "2015-06-21 13:50:34" - }, - { - "name": "phpunit/php-timer", - "version": "1.0.7", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-timer.git", - "reference": "3e82f4e9fc92665fafd9157568e4dcb01d014e5b" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/3e82f4e9fc92665fafd9157568e4dcb01d014e5b", - "reference": "3e82f4e9fc92665fafd9157568e4dcb01d014e5b", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "Utility class for timing", - "homepage": "https://github.com/sebastianbergmann/php-timer/", - "keywords": [ - "timer" - ], - "time": "2015-06-21 08:01:12" - }, - { - "name": "phpunit/php-token-stream", - "version": "1.4.8", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/php-token-stream.git", - "reference": "3144ae21711fb6cac0b1ab4cbe63b75ce3d4e8da" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/3144ae21711fb6cac0b1ab4cbe63b75ce3d4e8da", - "reference": "3144ae21711fb6cac0b1ab4cbe63b75ce3d4e8da", - "shasum": "" - }, - "require": { - "ext-tokenizer": "*", - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.2" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.4-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Wrapper around PHP's tokenizer extension.", - "homepage": "https://github.com/sebastianbergmann/php-token-stream/", - "keywords": [ - "tokenizer" - ], - "time": "2015-09-15 10:49:45" - }, - { - "name": "phpunit/phpunit", - "version": "4.8.21", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "ea76b17bced0500a28098626b84eda12dbcf119c" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/ea76b17bced0500a28098626b84eda12dbcf119c", - "reference": "ea76b17bced0500a28098626b84eda12dbcf119c", - "shasum": "" - }, - "require": { - "ext-dom": "*", - "ext-json": "*", - "ext-pcre": "*", - "ext-reflection": "*", - "ext-spl": "*", - "php": ">=5.3.3", - "phpspec/prophecy": "^1.3.1", - "phpunit/php-code-coverage": "~2.1", - "phpunit/php-file-iterator": "~1.4", - "phpunit/php-text-template": "~1.2", - "phpunit/php-timer": ">=1.0.6", - "phpunit/phpunit-mock-objects": "~2.3", - "sebastian/comparator": "~1.1", - "sebastian/diff": "~1.2", - "sebastian/environment": "~1.3", - "sebastian/exporter": "~1.2", - "sebastian/global-state": "~1.0", - "sebastian/version": "~1.0", - "symfony/yaml": "~2.1|~3.0" - }, - "suggest": { - "phpunit/php-invoker": "~1.1" - }, - "bin": [ - "phpunit" - ], - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "4.8.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "The PHP Unit Testing framework.", - "homepage": "https://phpunit.de/", - "keywords": [ - "phpunit", - "testing", - "xunit" - ], - "time": "2015-12-12 07:45:58" - }, - { - "name": "phpunit/phpunit-mock-objects", - "version": "2.3.8", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git", - "reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/ac8e7a3db35738d56ee9a76e78a4e03d97628983", - "reference": "ac8e7a3db35738d56ee9a76e78a4e03d97628983", - "shasum": "" - }, - "require": { - "doctrine/instantiator": "^1.0.2", - "php": ">=5.3.3", - "phpunit/php-text-template": "~1.2", - "sebastian/exporter": "~1.2" - }, - "require-dev": { - "phpunit/phpunit": "~4.4" - }, - "suggest": { - "ext-soap": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.3.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sb@sebastian-bergmann.de", - "role": "lead" - } - ], - "description": "Mock Object library for PHPUnit", - "homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/", - "keywords": [ - "mock", - "xunit" - ], - "time": "2015-10-02 06:51:40" - }, - { - "name": "sebastian/comparator", - "version": "1.2.0", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/comparator.git", - "reference": "937efb279bd37a375bcadf584dec0726f84dbf22" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/comparator/zipball/937efb279bd37a375bcadf584dec0726f84dbf22", - "reference": "937efb279bd37a375bcadf584dec0726f84dbf22", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "sebastian/diff": "~1.2", - "sebastian/exporter": "~1.2" - }, - "require-dev": { - "phpunit/phpunit": "~4.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.2.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Volker Dusch", - "email": "github@wallbash.com" - }, - { - "name": "Bernhard Schussek", - "email": "bschussek@2bepublished.at" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Provides the functionality to compare PHP values for equality", - "homepage": "http://www.github.com/sebastianbergmann/comparator", - "keywords": [ - "comparator", - "compare", - "equality" - ], - "time": "2015-07-26 15:48:44" - }, - { - "name": "sebastian/diff", - "version": "1.4.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/diff.git", - "reference": "13edfd8706462032c2f52b4b862974dd46b71c9e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/diff/zipball/13edfd8706462032c2f52b4b862974dd46b71c9e", - "reference": "13edfd8706462032c2f52b4b862974dd46b71c9e", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.8" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.4-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Kore Nordmann", - "email": "mail@kore-nordmann.de" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Diff implementation", - "homepage": "https://github.com/sebastianbergmann/diff", - "keywords": [ - "diff" - ], - "time": "2015-12-08 07:14:41" - }, - { - "name": "sebastian/environment", - "version": "1.3.3", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/environment.git", - "reference": "6e7133793a8e5a5714a551a8324337374be209df" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/environment/zipball/6e7133793a8e5a5714a551a8324337374be209df", - "reference": "6e7133793a8e5a5714a551a8324337374be209df", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.3.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Provides functionality to handle HHVM/PHP environments", - "homepage": "http://www.github.com/sebastianbergmann/environment", - "keywords": [ - "Xdebug", - "environment", - "hhvm" - ], - "time": "2015-12-02 08:37:27" - }, - { - "name": "sebastian/exporter", - "version": "1.2.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/exporter.git", - "reference": "7ae5513327cb536431847bcc0c10edba2701064e" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/exporter/zipball/7ae5513327cb536431847bcc0c10edba2701064e", - "reference": "7ae5513327cb536431847bcc0c10edba2701064e", - "shasum": "" - }, - "require": { - "php": ">=5.3.3", - "sebastian/recursion-context": "~1.0" - }, - "require-dev": { - "phpunit/phpunit": "~4.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.2.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Volker Dusch", - "email": "github@wallbash.com" - }, - { - "name": "Bernhard Schussek", - "email": "bschussek@2bepublished.at" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, - { - "name": "Adam Harvey", - "email": "aharvey@php.net" - } - ], - "description": "Provides the functionality to export PHP variables for visualization", - "homepage": "http://www.github.com/sebastianbergmann/exporter", - "keywords": [ - "export", - "exporter" - ], - "time": "2015-06-21 07:55:53" - }, - { - "name": "sebastian/global-state", - "version": "1.1.1", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/global-state.git", - "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/global-state/zipball/bc37d50fea7d017d3d340f230811c9f1d7280af4", - "reference": "bc37d50fea7d017d3d340f230811c9f1d7280af4", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.2" - }, - "suggest": { - "ext-uopz": "*" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - } - ], - "description": "Snapshotting of global state", - "homepage": "http://www.github.com/sebastianbergmann/global-state", - "keywords": [ - "global state" - ], - "time": "2015-10-12 03:26:01" - }, - { - "name": "sebastian/recursion-context", - "version": "1.0.2", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/recursion-context.git", - "reference": "913401df809e99e4f47b27cdd781f4a258d58791" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/recursion-context/zipball/913401df809e99e4f47b27cdd781f4a258d58791", - "reference": "913401df809e99e4f47b27cdd781f4a258d58791", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "phpunit/phpunit": "~4.4" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "1.0.x-dev" - } - }, - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Jeff Welch", - "email": "whatthejeff@gmail.com" - }, - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de" - }, - { - "name": "Adam Harvey", - "email": "aharvey@php.net" - } - ], - "description": "Provides functionality to recursively process PHP variables", - "homepage": "http://www.github.com/sebastianbergmann/recursion-context", - "time": "2015-11-11 19:50:13" - }, - { - "name": "sebastian/version", - "version": "1.0.6", - "source": { - "type": "git", - "url": "https://github.com/sebastianbergmann/version.git", - "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/version/zipball/58b3a85e7999757d6ad81c787a1fbf5ff6c628c6", - "reference": "58b3a85e7999757d6ad81c787a1fbf5ff6c628c6", - "shasum": "" - }, - "type": "library", - "autoload": { - "classmap": [ - "src/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "BSD-3-Clause" - ], - "authors": [ - { - "name": "Sebastian Bergmann", - "email": "sebastian@phpunit.de", - "role": "lead" - } - ], - "description": "Library that helps with managing the version number of Git-hosted PHP projects", - "homepage": "https://github.com/sebastianbergmann/version", - "time": "2015-06-21 13:59:46" - }, - { - "name": "symfony/yaml", - "version": "v2.6.13", - "target-dir": "Symfony/Component/Yaml", - "source": { - "type": "git", - "url": "https://github.com/symfony/yaml.git", - "reference": "c044d1744b8e91aaaa0d9bac683ab87ec7cbf359" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/c044d1744b8e91aaaa0d9bac683ab87ec7cbf359", - "reference": "c044d1744b8e91aaaa0d9bac683ab87ec7cbf359", - "shasum": "" - }, - "require": { - "php": ">=5.3.3" - }, - "require-dev": { - "symfony/phpunit-bridge": "~2.7" - }, - "type": "library", - "extra": { - "branch-alias": { - "dev-master": "2.6-dev" - } - }, - "autoload": { - "psr-0": { - "Symfony\\Component\\Yaml\\": "" - } - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - }, - { - "name": "Symfony Community", - "homepage": "https://symfony.com/contributors" - } - ], - "description": "Symfony Yaml Component", - "homepage": "https://symfony.com", - "time": "2015-07-26 08:59:42" - } - ], - "aliases": [], - "minimum-stability": "stable", - "stability-flags": [], - "prefer-stable": false, - "prefer-lowest": false, - "platform": { - "php": ">=5.3.3" - }, - "platform-dev": [], - "platform-overrides": { - "php": "5.3.3" - } -} diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 00000000..377320f9 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,5 @@ +git: + build: . + volumes: + - .:/code + working_dir: /code diff --git a/src/GitElephant/Command/CatFileCommand.php b/src/GitElephant/Command/CatFileCommand.php index ad18dfa5..5cdc60ea 100644 --- a/src/GitElephant/Command/CatFileCommand.php +++ b/src/GitElephant/Command/CatFileCommand.php @@ -19,7 +19,7 @@ namespace GitElephant\Command; -use \GitElephant\Objects\Object; +use \GitElephant\Objects\NodeObject; use \GitElephant\Objects\TreeishInterface; use \GitElephant\Repository; @@ -46,13 +46,13 @@ public function __construct(Repository $repo = null) /** * command to show content of a Object at a given Treeish point * - * @param \GitElephant\Objects\Object $object a Object instance + * @param \GitElephant\Objects\NodeObject $object a Object instance * @param \GitElephant\Objects\TreeishInterface|string $treeish an object with TreeishInterface interface * * @throws \RuntimeException * @return string */ - public function content(Object $object, $treeish) + public function content(NodeObject $object, $treeish) { $this->clearAll(); if ($treeish instanceof TreeishInterface) { diff --git a/src/GitElephant/Command/LogCommand.php b/src/GitElephant/Command/LogCommand.php index 9f341307..6ba4c1aa 100644 --- a/src/GitElephant/Command/LogCommand.php +++ b/src/GitElephant/Command/LogCommand.php @@ -19,7 +19,7 @@ namespace GitElephant\Command; -use \GitElephant\Objects\Object; +use \GitElephant\Objects\NodeObject; use \GitElephant\Objects\Branch; use \GitElephant\Objects\TreeishInterface; use \GitElephant\Repository; @@ -48,7 +48,7 @@ public function __construct(Repository $repo = null) /** * Build an object log command * - * @param \GitElephant\Objects\Object $obj the Object to get the log for + * @param \GitElephant\Objects\NodeObject $obj the Object to get the log for * @param \GitElephant\Objects\Branch|string|null $branch the branch to consider * @param int|null $limit limit to n entries * @param int|null $offset skip n entries @@ -56,7 +56,7 @@ public function __construct(Repository $repo = null) * @throws \RuntimeException * @return string */ - public function showObjectLog(Object $obj, $branch = null, $limit = null, $offset = null) + public function showObjectLog(NodeObject $obj, $branch = null, $limit = null, $offset = null) { $subject = null; if (null !== $branch) { diff --git a/src/GitElephant/Command/LsTreeCommand.php b/src/GitElephant/Command/LsTreeCommand.php index 6f802f31..144bc7f3 100644 --- a/src/GitElephant/Command/LsTreeCommand.php +++ b/src/GitElephant/Command/LsTreeCommand.php @@ -21,7 +21,7 @@ use \GitElephant\Objects\Branch; use \GitElephant\Objects\TreeishInterface; -use \GitElephant\Objects\Object; +use \GitElephant\Objects\NodeObject; use \GitElephant\Repository; /** @@ -73,15 +73,15 @@ public function fullTree($ref = 'HEAD') /** * tree of a given path * - * @param string $ref reference - * @param string|Object $path path + * @param string $ref reference + * @param string|NodeObject $path path * * @throws \RuntimeException * @return string */ public function tree($ref = 'HEAD', $path = null) { - if ($path instanceof Object) { + if ($path instanceof NodeObject) { $subjectPath = $path->getFullPath() . ($path->isTree() ? '/' : ''); } else { $subjectPath = $path; diff --git a/src/GitElephant/Command/MvCommand.php b/src/GitElephant/Command/MvCommand.php index 5e11a7c4..15339ecd 100644 --- a/src/GitElephant/Command/MvCommand.php +++ b/src/GitElephant/Command/MvCommand.php @@ -19,7 +19,7 @@ namespace GitElephant\Command; -use \GitElephant\Objects\Object; +use \GitElephant\Objects\NodeObject; use \GitElephant\Repository; /** @@ -43,8 +43,8 @@ public function __construct(Repository $repo = null) } /** - * @param string|Object $source source name - * @param string $target dest name + * @param string|NodeObject $source source name + * @param string $target dest name * * @throws \RuntimeException * @throws \InvalidArgumentException @@ -52,7 +52,7 @@ public function __construct(Repository $repo = null) */ public function rename($source, $target) { - if ($source instanceof Object) { + if ($source instanceof NodeObject) { if (!$source->isBlob()) { throw new \InvalidArgumentException("The given object is not a blob, it couldn't be renamed"); } diff --git a/src/GitElephant/Command/PushCommand.php b/src/GitElephant/Command/PushCommand.php index d1b10553..62a02543 100644 --- a/src/GitElephant/Command/PushCommand.php +++ b/src/GitElephant/Command/PushCommand.php @@ -49,7 +49,7 @@ public function __construct(Repository $repo = null) * @throws \RuntimeException * @return string */ - public function push($remote = 'origin', $branch = 'master') + public function push($remote = 'origin', $branch = 'master', $args = null) { if ($remote instanceof Remote) { $remote = $remote->getName(); @@ -62,6 +62,10 @@ public function push($remote = 'origin', $branch = 'master') $this->addCommandSubject($remote); $this->addCommandSubject2($branch); + if(!is_null($args)) { + $this->addCommandArgument($args); + } + return $this->getCommand(); } } diff --git a/src/GitElephant/Command/ResetCommand.php b/src/GitElephant/Command/ResetCommand.php new file mode 100644 index 00000000..88138e75 --- /dev/null +++ b/src/GitElephant/Command/ResetCommand.php @@ -0,0 +1,70 @@ +clearAll(); + $this->addCommandName(self::GIT_RESET_COMMAND); + // if there are options add them. + if (! is_null($options)) { + foreach ($options as $option) { + $this->addCommandArgument($option); + } + } + if($arg!=null){ + $this->addCommandSubject2($arg); + } + + return $this->getCommand(); + } + + /** + * @param Repository $repository + * @return ResetCommand + */ + public static function getInstance(Repository $repository=null) + { + return new self($repository); + } + + + +} diff --git a/src/GitElephant/Objects/Branch.php b/src/GitElephant/Objects/Branch.php index 626a1421..54b727c5 100644 --- a/src/GitElephant/Objects/Branch.php +++ b/src/GitElephant/Objects/Branch.php @@ -28,7 +28,7 @@ * * @author Matteo Giachino */ -class Branch extends Object implements TreeishInterface +class Branch extends NodeObject implements TreeishInterface { /** * current checked out branch diff --git a/src/GitElephant/Objects/Commit.php b/src/GitElephant/Objects/Commit.php index 9b834d5b..8f50c7f4 100644 --- a/src/GitElephant/Objects/Commit.php +++ b/src/GitElephant/Objects/Commit.php @@ -221,7 +221,7 @@ public function getDiff() */ private function parseOutputLines($outputLines) { - $message = ''; + $message = array(); foreach ($outputLines as $line) { $matches = array(); if (preg_match('/^commit (\w+)$/', $line, $matches) > 0) { @@ -406,4 +406,42 @@ public function revParse(Array $options = array()) return array_map('trim', $caller->getOutputLines(true)); } + + /** + * Is the commit tagged? + * + * return true if some tag of repository point to this commit + * return false otherwise + * + * @return bool + */ + public function tagged() + { + $result = false; + foreach ($this->repository->getTags() as $tag) { + if ($tag->getSha() == $this->getSha()) { + $result = true; + break; + } + } + + return $result; + } + + /** + * Return Tags that point to this commit + * + * @return Tag[] + */ + public function getTags() + { + $currentCommitTags = array(); + foreach ($this->repository->getTags() as $tag) { + if ($tag->getSha() == $this->getSha()) { + $currentCommitTags[] = $tag; + } + } + + return $currentCommitTags; + } } diff --git a/src/GitElephant/Objects/Object.php b/src/GitElephant/Objects/NodeObject.php similarity index 96% rename from src/GitElephant/Objects/Object.php rename to src/GitElephant/Objects/NodeObject.php index 81b3c0e2..c466fb64 100644 --- a/src/GitElephant/Objects/Object.php +++ b/src/GitElephant/Objects/NodeObject.php @@ -28,7 +28,7 @@ * * @author Matteo Giachino */ -class Object implements TreeishInterface +class NodeObject implements TreeishInterface { const TYPE_BLOB = 'blob'; const TYPE_TREE = 'tree'; @@ -88,7 +88,7 @@ class Object implements TreeishInterface * @param string $outputLine output from ls-tree command * * @see LsTreeCommand::tree - * @return Object + * @return NodeObject */ public static function createFromOutputLine(Repository $repository, $outputLine) { @@ -127,14 +127,14 @@ public static function getLineSlices($line) $permissions = $matches[1]; $type = null; switch ($matches[2]) { - case Object::TYPE_TREE: - $type = Object::TYPE_TREE; + case NodeObject::TYPE_TREE: + $type = NodeObject::TYPE_TREE; break; - case Object::TYPE_BLOB: - $type = Object::TYPE_BLOB; + case NodeObject::TYPE_BLOB: + $type = NodeObject::TYPE_BLOB; break; - case Object::TYPE_LINK: - $type = Object::TYPE_LINK; + case NodeObject::TYPE_LINK: + $type = NodeObject::TYPE_LINK; break; } $sha = $matches[3]; diff --git a/src/GitElephant/Objects/Tag.php b/src/GitElephant/Objects/Tag.php index 87033ecc..849c7de1 100644 --- a/src/GitElephant/Objects/Tag.php +++ b/src/GitElephant/Objects/Tag.php @@ -28,7 +28,7 @@ * * @author Matteo Giachino */ -class Tag extends Object +class Tag extends NodeObject { /** * tag name diff --git a/src/GitElephant/Objects/Tree.php b/src/GitElephant/Objects/Tree.php index 8784d13e..7a209387 100644 --- a/src/GitElephant/Objects/Tree.php +++ b/src/GitElephant/Objects/Tree.php @@ -31,7 +31,7 @@ * * @author Matteo Giachino */ -class Tree extends Object implements \ArrayAccess, \Countable, \Iterator +class Tree extends NodeObject implements \ArrayAccess, \Countable, \Iterator { /** * @var string @@ -48,7 +48,7 @@ class Tree extends Object implements \ArrayAccess, \Countable, \Iterator /** * the tree subject * - * @var Object + * @var NodeObject */ private $subject; @@ -69,7 +69,7 @@ class Tree extends Object implements \ArrayAccess, \Countable, \Iterator /** * the blob of the actual tree * - * @var \GitElephant\Objects\Object + * @var \GitElephant\Objects\NodeObject */ private $blob; @@ -109,7 +109,7 @@ private function createFromCommand() * * @param \GitElephant\Repository $repository the repository * @param string $ref a treeish reference - * @param Object $subject the subject + * @param NodeObject $subject the subject * * @throws \RuntimeException * @throws \Symfony\Component\Process\Exception\RuntimeException @@ -187,7 +187,7 @@ public function isBlob() */ public function isBinary() { - return $this->isRoot() ? false : Object::TYPE_BLOB === $this->subject->getType(); + return $this->isRoot() ? false : NodeObject::TYPE_BLOB === $this->subject->getType(); } /** @@ -258,7 +258,7 @@ private function scanPathsForBlob($outputLines) return; } if (1 === count($outputLines)) { - $treeObject = Object::createFromOutputLine($this->repository, $outputLines[0]); + $treeObject = NodeObject::createFromOutputLine($this->repository, $outputLines[0]); if ($treeObject->getSha() === $this->subject->getSha()) { $this->blob = $treeObject; } @@ -269,12 +269,12 @@ private function scanPathsForBlob($outputLines) * Reorder children of the tree * Tree first (alphabetically) and then blobs (alphabetically) * - * @param \GitElephant\Objects\Object $a the first object - * @param \GitElephant\Objects\Object $b the second object + * @param \GitElephant\Objects\NodeObject $a the first object + * @param \GitElephant\Objects\NodeObject $b the second object * * @return int */ - private function sortChildren(Object $a, Object $b) + private function sortChildren(NodeObject $a, NodeObject $b) { if ($a->getType() == $b->getType()) { $names = array($a->getName(), $b->getName()); @@ -283,7 +283,7 @@ private function sortChildren(Object $a, Object $b) return ($a->getName() == $names[0]) ? -1 : 1; } - return $a->getType() == Object::TYPE_TREE || $b->getType() == Object::TYPE_BLOB ? -1 : 1; + return $a->getType() == NodeObject::TYPE_TREE || $b->getType() == NodeObject::TYPE_BLOB ? -1 : 1; } /** @@ -298,7 +298,7 @@ private function parseLine($line) if ($line == '') { return; } - $slices = Object::getLineSlices($line); + $slices = NodeObject::getLineSlices($line); if ($this->isBlob()) { $this->pathChildren[] = $this->blob->getName(); } else { @@ -384,7 +384,7 @@ public function getLastCommit($ref = 'master') /** * get the tree object for this tree * - * @return \GitElephant\Objects\Object + * @return \GitElephant\Objects\NodeObject */ public function getObject() { @@ -398,7 +398,7 @@ public function getObject() /** * Blob getter * - * @return \GitElephant\Objects\Object + * @return \GitElephant\Objects\NodeObject */ public function getBlob() { @@ -408,7 +408,7 @@ public function getBlob() /** * Get Subject * - * @return \GitElephant\Objects\Object + * @return \GitElephant\Objects\NodeObject */ public function getSubject() { diff --git a/src/GitElephant/Objects/TreeObject.php b/src/GitElephant/Objects/TreeObject.php index 7e5c314a..f2631faf 100644 --- a/src/GitElephant/Objects/TreeObject.php +++ b/src/GitElephant/Objects/TreeObject.php @@ -2,6 +2,6 @@ namespace GitElephant\Objects; -class TreeObject extends Object +class TreeObject extends NodeObject { } diff --git a/src/GitElephant/Repository.php b/src/GitElephant/Repository.php index 761462ba..2974c69b 100644 --- a/src/GitElephant/Repository.php +++ b/src/GitElephant/Repository.php @@ -23,14 +23,14 @@ use \GitElephant\Command\PullCommand; use \GitElephant\Command\PushCommand; use \GitElephant\Command\RemoteCommand; -use \GitElephant\Exception\InvalidRepositoryPathException; +use GitElephant\Command\ResetCommand; use \GitElephant\Command\Caller\Caller; use \GitElephant\Objects\Author; use \GitElephant\Objects\Remote; use \GitElephant\Objects\Tree; use \GitElephant\Objects\Branch; use \GitElephant\Objects\Tag; -use \GitElephant\Objects\Object; +use \GitElephant\Objects\NodeObject; use \GitElephant\Objects\Diff\Diff; use \GitElephant\Objects\Commit; use \GitElephant\Objects\Log; @@ -192,7 +192,7 @@ public function init($bare = false) /** * Stage the working tree content * - * @param string|Object $path the path to store + * @param string|NodeObject $path the path to store * * @throws \RuntimeException * @throws \Symfony\Component\Process\Exception\LogicException @@ -210,7 +210,7 @@ public function stage($path = '.') /** * Unstage a tree content * - * @param string|Object $path the path to unstage + * @param string|NodeObject $path the path to unstage * * @throws \RuntimeException * @throws \Symfony\Component\Process\Exception\LogicException @@ -228,8 +228,8 @@ public function unstage($path) /** * Move a file/directory * - * @param string|Object $from source path - * @param string|Object $to destination path + * @param string|NodeObject $from source path + * @param string|NodeObject $to destination path * * @throws \RuntimeException * @throws \Symfony\Component\Process\Exception\LogicException @@ -248,9 +248,9 @@ public function move($from, $to) /** * Remove a file/directory * - * @param string|Object $path the path to remove - * @param bool $recursive recurse - * @param bool $force force + * @param string|NodeObject $path the path to remove + * @param bool $recursive recurse + * @param bool $force force * * @throws \RuntimeException * @throws \Symfony\Component\Process\Exception\LogicException @@ -300,8 +300,8 @@ public function commit($message, $stageAll = false, $ref = null, $author = null, /** * rev-parse command - often used to return a commit tag. * - * @param array $options the options to apply to rev-parse - * @param string|Object|Commit $arg the argument (may be a branch head, etc) + * @param array $options the options to apply to rev-parse + * @param string|NodeObject|Commit $arg the argument (may be a branch head, etc) * * @throws \RuntimeException * @throws \InvalidArgumentException @@ -327,6 +327,15 @@ public function isBare() return trim($this->caller->getOutput()) === 'true'; } + /** + * @param TreeishInterface|Commit|string $arg + * @param array $options + */ + public function reset($arg,$options) + { + $this->caller->execute(ResetCommand::getInstance($this)->reset($arg,$options)); + } + /** * Get the repository status * @@ -794,7 +803,7 @@ public function countCommits($start = 'HEAD') * Get a log for a ref * * @param string|TreeishInterface|array $ref the treeish to check, as a string, as an object or as an array - * @param string|Object $path the physical path to the tree relative to the repository root + * @param string|NodeObject $path the physical path to the tree relative to the repository root * @param int|null $limit limit to n entries * @param int|null $offset skip n entries * @param boolean|false $firstParent skip commits brought in to branch by a merge @@ -809,12 +818,12 @@ public function getLog($ref = 'HEAD', $path = null, $limit = 10, $offset = null, /** * Get a log for a range ref * - * @param string $refStart - * @param string $refEnd - * @param string|Object $path the physical path to the tree relative to the repository root - * @param int|null $limit limit to n entries - * @param int|null $offset skip n entries - * @param boolean|false $firstParent skip commits brought in to branch by a merge + * @param string $refStart + * @param string $refEnd + * @param string|NodeObject $path the physical path to the tree relative to the repository root + * @param int|null $limit limit to n entries + * @param int|null $offset skip n entries + * @param boolean|false $firstParent skip commits brought in to branch by a merge * * @return \GitElephant\Objects\LogRange */ @@ -836,7 +845,7 @@ public function getLogRange($refStart, $refEnd, $path = null, $limit = 10, $offs /** * Get a log for an object * - * @param \GitElephant\Objects\Object $obj The Object instance + * @param \GitElephant\Objects\NodeObject $obj The Object instance * @param null|string|\GitElephant\Objects\Branch $branch The branch to read from * @param int $limit Limit to n entries * @param int|null $offset Skip n entries @@ -847,7 +856,7 @@ public function getLogRange($refStart, $refEnd, $path = null, $limit = 10, $offs * @throws \Symfony\Component\Process\Exception\RuntimeException * @return \GitElephant\Objects\Log */ - public function getObjectLog(Object $obj, $branch = null, $limit = 1, $offset = null) + public function getObjectLog(NodeObject $obj, $branch = null, $limit = 1, $offset = null) { $command = LogCommand::getInstance($this)->showObjectLog($obj, $branch, $limit, $offset); @@ -882,7 +891,7 @@ public function checkout($ref, $create = false) * Tree Object is Countable, Iterable and has ArrayAccess for easy manipulation * * @param string|TreeishInterface $ref the treeish to check - * @param string|Object $path Object or null for root + * @param string|NodeObject $path Object or null for root * * @throws \RuntimeException * @throws \Symfony\Component\Process\Exception\LogicException @@ -907,7 +916,7 @@ public function getTree($ref = 'HEAD', $path = null) * * @param \GitElephant\Objects\Commit|string $commit1 A TreeishInterface instance * @param \GitElephant\Objects\Commit|string|null $commit2 A TreeishInterface instance - * @param null|string|Object $path The path to get the diff for or a Object instance + * @param null|string|NodeObject $path The path to get the diff for or a Object instance * * @throws \RuntimeException * @throws \InvalidArgumentException @@ -1026,7 +1035,7 @@ public function pull($from = null, $ref = null, $rebase = true) } /** - * Fetch from and merge with another repository or a local branch + * Push changes to remote repository * * @param string $to * @param string $ref @@ -1057,7 +1066,7 @@ public function getHumanishName() /** * output a node content as an array of lines * - * @param \GitElephant\Objects\Object $obj The Object of type BLOB + * @param \GitElephant\Objects\NodeObject $obj The Object of type BLOB * @param \GitElephant\Objects\TreeishInterface|string $treeish A treeish object * * @throws \RuntimeException @@ -1066,7 +1075,7 @@ public function getHumanishName() * @throws \Symfony\Component\Process\Exception\RuntimeException * @return array */ - public function outputContent(Object $obj, $treeish) + public function outputContent(NodeObject $obj, $treeish) { $command = CatFileCommand::getInstance($this)->content($obj, $treeish); @@ -1076,7 +1085,7 @@ public function outputContent(Object $obj, $treeish) /** * output a node raw content * - * @param \GitElephant\Objects\Object $obj The Object of type BLOB + * @param \GitElephant\Objects\NodeObject $obj The Object of type BLOB * @param \GitElephant\Objects\TreeishInterface|string $treeish A treeish object * * @throws \RuntimeException @@ -1085,7 +1094,7 @@ public function outputContent(Object $obj, $treeish) * @throws \Symfony\Component\Process\Exception\RuntimeException * @return string */ - public function outputRawContent(Object $obj, $treeish) + public function outputRawContent(NodeObject $obj, $treeish) { $command = CatFileCommand::getInstance($this)->content($obj, $treeish); diff --git a/tests/GitElephant/Command/BaseCommandTest.php b/tests/GitElephant/Command/BaseCommandTest.php index 69816797..626b7078 100644 --- a/tests/GitElephant/Command/BaseCommandTest.php +++ b/tests/GitElephant/Command/BaseCommandTest.php @@ -6,10 +6,8 @@ * Just for fun... */ - namespace GitElephant\Command; -use \GitElephant\Command\BaseCommand; use \GitElephant\TestCase; use \ReflectionClass; @@ -41,7 +39,7 @@ public function testConstructor() foreach ($arguments as $argumentValue) { $repo->addGlobalCommandArgument($argumentValue); } $bc2 = new BaseCommand($repo); - $ref_bc = new ReflectionClass($bc2); + $ref_bc = new \ReflectionClass($bc2); $ref_bc_cfg_prop = $ref_bc->getProperty('globalConfigs'); $ref_bc_cfg_prop->setAccessible(true); @@ -70,7 +68,7 @@ public function testGetInstance() public function testAddGlobalConfigs() { $configs = array('one' => 1, 'two' => 2, 'three' => 3); $bc = BaseCommand::getInstance(); - $ref_bc = new ReflectionClass($bc); + $ref_bc = new \ReflectionClass($bc); $ref_bc_cfg_prop = $ref_bc->getProperty('globalConfigs'); $ref_bc_cfg_prop->setAccessible(true); @@ -85,7 +83,7 @@ public function testAddGlobalConfigs() { public function testAddGlobalOptions() { $options = array('one' => 1, 'two' => 2, 'three' => 3); $bc = BaseCommand::getInstance(); - $ref_bc = new ReflectionClass($bc); + $ref_bc = new \ReflectionClass($bc); $ref_bc_opt_prop = $ref_bc->getProperty('globalOptions'); $ref_bc_opt_prop->setAccessible(true); @@ -100,7 +98,7 @@ public function testAddGlobalOptions() { public function testAddGlobalCommandArguments() { $arguments = array('one', 'two', 'three'); $bc = BaseCommand::getInstance(); - $ref_bc = new ReflectionClass($bc); + $ref_bc = new \ReflectionClass($bc); $ref_bc_arg_prop = $ref_bc->getProperty('globalCommandArguments'); $ref_bc_arg_prop->setAccessible(true); @@ -117,7 +115,7 @@ public function testAddGlobalCommandArguments() { public function testGetCommand() { $name = 'command'; $bc = BaseCommand::getInstance(); - $ref_bc = new ReflectionClass($bc); + $ref_bc = new \ReflectionClass($bc); $ref_bc_arg_prop = $ref_bc->getProperty('commandName'); $ref_bc_arg_prop->setAccessible(true); @@ -137,14 +135,14 @@ public function testGetCommand() { public function testGetCommandException() { $bc = BaseCommand::getInstance(); - $this->setExpectedException('RuntimeException'); + $this->expectException('RuntimeException'); $this->fail($bc->getCommand()); } public function testGetCLICommandArguments() { $args = array('--first', '--second', '--third'); $bc = BaseCommand::getInstance(); - $ref_bc = new ReflectionClass($bc); + $ref_bc = new \ReflectionClass($bc); $ref_bc_arg_prop = $ref_bc->getProperty('globalCommandArguments'); $ref_bc_arg_prop->setAccessible(true); @@ -164,7 +162,7 @@ public function testGetCLICommandArguments() { public function testGetCLICommandName() { $name = 'command'; $bc = BaseCommand::getInstance(); - $ref_bc = new ReflectionClass($bc); + $ref_bc = new \ReflectionClass($bc); $ref_bc_arg_prop = $ref_bc->getProperty('commandName'); $ref_bc_arg_prop->setAccessible(true); @@ -184,7 +182,7 @@ public function testGetCLIConfigs() { $configs = array_merge($globals, $locals); $bc = BaseCommand::getInstance(); - $ref_bc = new ReflectionClass($bc); + $ref_bc = new \ReflectionClass($bc); $ref_bc_glob_cfg_prop = $ref_bc->getProperty('globalConfigs'); $ref_bc_glob_cfg_prop->setAccessible(true); @@ -208,7 +206,7 @@ public function testGetCLIConfigs() { public function testGetCLIGlobalOptions() { $options = array('first' => 'a', 'second' => 'b', 'third' => 'c'); $bc = BaseCommand::getInstance(); - $ref_bc = new ReflectionClass($bc); + $ref_bc = new \ReflectionClass($bc); $ref_bc_opt_prop = $ref_bc->getProperty('globalOptions'); $ref_bc_opt_prop->setAccessible(true); @@ -228,7 +226,7 @@ public function testGetCLIGlobalOptions() { public function testGetCLIPath() { $path = '/path/to/something'; $bc = BaseCommand::getInstance(); - $ref_bc = new ReflectionClass($bc); + $ref_bc = new \ReflectionClass($bc); $ref_bc_path_prop = $ref_bc->getProperty('path'); $ref_bc_path_prop->setAccessible(true); @@ -246,7 +244,7 @@ public function testGetCLISubjects() { $subject1 = 'first'; $subject2 = 'second'; $bc = BaseCommand::getInstance(); - $ref_bc = new ReflectionClass($bc); + $ref_bc = new \ReflectionClass($bc); $ref_bc_subj1_prop = $ref_bc->getProperty('commandSubject'); $ref_bc_subj1_prop->setAccessible(true); diff --git a/tests/GitElephant/Command/DiffTreeCommandTest.php b/tests/GitElephant/Command/DiffTreeCommandTest.php index 35dd1494..9d92c06a 100644 --- a/tests/GitElephant/Command/DiffTreeCommandTest.php +++ b/tests/GitElephant/Command/DiffTreeCommandTest.php @@ -50,7 +50,7 @@ public function testRootDiff() ); $this->addFile('test'); $this->getRepository()->commit('test commit', true); - $this->setExpectedException('InvalidArgumentException'); + $this->expectException('InvalidArgumentException'); $this->fail($dtc->rootDiff($this->getRepository()->getCommit())); } } diff --git a/tests/GitElephant/Command/ResetCommandTest.php b/tests/GitElephant/Command/ResetCommandTest.php new file mode 100644 index 00000000..6bdea6ba --- /dev/null +++ b/tests/GitElephant/Command/ResetCommandTest.php @@ -0,0 +1,33 @@ +initRepository(); + $this->getRepository()->init(); + $this->addFile('test'); + $this->getRepository()->commit('test', true); + $this->getRepository()->createBranch('test', 'master'); + } + + public function testResetHard() + { + $rstc = ResetCommand::getInstance(); + $this->assertEquals("reset '--hard' 'dbeac'",$rstc->reset('dbeac',array(ResetCommand::OPTION_HARD))); + } +} diff --git a/tests/GitElephant/Objects/BranchTest.php b/tests/GitElephant/Objects/BranchTest.php index f54b17ec..0a0c7213 100644 --- a/tests/GitElephant/Objects/BranchTest.php +++ b/tests/GitElephant/Objects/BranchTest.php @@ -74,7 +74,7 @@ public function testConstructor() $this->assertEquals('develop', $b->getName()); $this->assertEquals('test commit', $b->getComment()); $this->assertFalse($b->getCurrent()); - $this->setExpectedException('GitElephant\Exception\InvalidBranchNameException'); + $this->expectException('GitElephant\Exception\InvalidBranchNameException'); $this->fail(Branch::checkout($this->getRepository(), 'non-existent')); } diff --git a/tests/GitElephant/Objects/Commit/MessageTest.php b/tests/GitElephant/Objects/Commit/MessageTest.php index f0814469..467087f7 100644 --- a/tests/GitElephant/Objects/Commit/MessageTest.php +++ b/tests/GitElephant/Objects/Commit/MessageTest.php @@ -18,7 +18,7 @@ * * @author Mathias Geat */ -class MessageTest extends \PHPUnit_Framework_TestCase +class MessageTest extends \PHPUnit\Framework\TestCase { protected $shortMsg; protected $longMsg; diff --git a/tests/GitElephant/Objects/CommitTest.php b/tests/GitElephant/Objects/CommitTest.php index 1456da43..0091b106 100644 --- a/tests/GitElephant/Objects/CommitTest.php +++ b/tests/GitElephant/Objects/CommitTest.php @@ -223,4 +223,27 @@ public function testRevParse() $revParse = $commit->revParse(); $this->assertEquals($commit->getSha(), $revParse[0]); } + + public function testCommitWithoutTag() + { + $this->getRepository()->init(); + $this->addFile('test'); + $this->repository->stage(); + $commit = Commit::create($this->repository, 'first commit', true); + $this->assertFalse($commit->tagged()); + } + + public function testCommitWithTag() + { + $this->getRepository()->init(); + $this->addFile('test'); + $this->repository->stage(); + $commit = Commit::create($this->repository, 'first commit', true); + Tag::create($this->repository, '1.0.0'); + $this->assertTrue($commit->tagged()); + $this->assertCount(1, $commit->getTags()); + $commitTags = $commit->getTags(); + $this->assertEquals('1.0.0', $commitTags[0]->getName()); + } + } diff --git a/tests/GitElephant/Objects/ObjectTest.php b/tests/GitElephant/Objects/NodeObjectTest.php similarity index 89% rename from tests/GitElephant/Objects/ObjectTest.php rename to tests/GitElephant/Objects/NodeObjectTest.php index 7796e982..e67097b3 100644 --- a/tests/GitElephant/Objects/ObjectTest.php +++ b/tests/GitElephant/Objects/NodeObjectTest.php @@ -5,10 +5,10 @@ namespace GitElephant\Objects; -use \GitElephant\Objects\Object; +use \GitElephant\Objects\NodeObject; use \GitElephant\TestCase; -class ObjectTest extends TestCase +class NodeObjectTest extends TestCase { public function setUp() { @@ -63,8 +63,8 @@ public function testRevParse() /** * test repository getter and setter * - * @covers GitElephant\Objects\Object::getRepository - * @covers GitElephant\Objects\Object::setRepository + * @covers GitElephant\Objects\NodeObject::getRepository + * @covers GitElephant\Objects\NodeObject::setRepository */ public function testGetSetRepository() { @@ -74,7 +74,7 @@ public function testGetSetRepository() $this->initRepository('object2', 2); $repo2 = $this->getRepository(2); - $object = new Object($repo1, 'permissions', 'type', 'sha', 'size', 'name', 'path'); // dummy params + $object = new NodeObject($repo1, 'permissions', 'type', 'sha', 'size', 'name', 'path'); // dummy params $this->assertSame($repo1, $object->getRepository()); $object->setRepository($repo2); $this->assertSame($repo2, $object->getRepository()); diff --git a/tests/GitElephant/Objects/RemoteTest.php b/tests/GitElephant/Objects/RemoteTest.php index 3417220e..e55c98c4 100644 --- a/tests/GitElephant/Objects/RemoteTest.php +++ b/tests/GitElephant/Objects/RemoteTest.php @@ -17,9 +17,9 @@ /** * Class RemoteTest - * + * * Remote Object Test - * + * * @package GitElephant\Command * @author David Neimeyer */ @@ -27,12 +27,14 @@ class RemoteTest extends TestCase { /** * test double branch name + * * @var string */ protected $startBranchName = 'test_branch'; /** * test double tag name + * * @var string */ protected $startTagName = 'test_start_tag'; @@ -54,6 +56,7 @@ public function setUp() /** * return sample output of git-remote --verbose + * * @return string */ public function sampleRemoteVerbose() @@ -72,6 +75,7 @@ public function sampleRemoteVerbose() /** * test double fetch URL + * * @return string */ public function sampleRemoteShowFetchURL() @@ -81,6 +85,7 @@ public function sampleRemoteShowFetchURL() /** * test double push URL + * * @return string */ public function sampleRemoteShowPushURL() @@ -90,6 +95,7 @@ public function sampleRemoteShowPushURL() /** * test double remote name + * * @return string */ public function sampleRemoteShowRemoteName() @@ -99,6 +105,7 @@ public function sampleRemoteShowRemoteName() /** * test double remote HEAD branch + * * @return string */ public function sampleRemoteShowRemoteHEAD() @@ -107,7 +114,8 @@ public function sampleRemoteShowRemoteHEAD() } /** - * sample output of git-remote show + * sample output of git-remote show + * * @return string */ public function sampleRemoteShow() @@ -148,51 +156,52 @@ public function sampleRemoteShow() /** * expected branch structure produced when * parsing the sample output of git-remote show + * * @return array */ public function sampleRemoteShowAsArray() { - return array( - '11.30' => array( - 'pushes_to' => '11.30', - 'local_state' => '(local out of date)', - ), - '11.30.6' => array( - 'pushes_to' => '11.30.6', - 'local_state' => '(up to date)', - 'merges_with' => '11.30.6', - 'local_relationship' => 'tracked', - ), - '11.32.0' => array( - 'pushes_to' => '11.32.0', - 'local_state' => '(up to date)', - 'merges_with' => '11.32.0', - 'local_relationship' => 'tracked', - ), - '11.32' => array( - 'pushes_to' => '11.32', - 'local_state' => '(local out of date)', - 'local_relationship' => 'tracked', - ), - '11.40' => array( - 'pushes_to' => '11.40', - 'merges_with' => '11.40', - 'local_state' => '(local out of date)', - 'local_relationship' => 'tracked', - ), - 'master' => array( - 'pushes_to' => 'master', - 'local_state' => '(up to date)', - 'merges_with' => 'master', - 'local_relationship' => 'tracked', - ), - 'pbi_4371' => array( - 'local_relationship' => 'tracked', - ), - 'refs/remotes/upstream/58120-squashed' => array( - 'local_relationship' => 'stale', - ), - ); + return [ + '11.30' => [ + 'pushes_to' => '11.30', + 'local_state' => '(local out of date)', + ], + '11.30.6' => [ + 'pushes_to' => '11.30.6', + 'local_state' => '(up to date)', + 'merges_with' => '11.30.6', + 'local_relationship' => 'tracked', + ], + '11.32.0' => [ + 'pushes_to' => '11.32.0', + 'local_state' => '(up to date)', + 'merges_with' => '11.32.0', + 'local_relationship' => 'tracked', + ], + '11.32' => [ + 'pushes_to' => '11.32', + 'local_state' => '(local out of date)', + 'local_relationship' => 'tracked', + ], + '11.40' => [ + 'pushes_to' => '11.40', + 'merges_with' => '11.40', + 'local_state' => '(local out of date)', + 'local_relationship' => 'tracked', + ], + 'master' => [ + 'pushes_to' => 'master', + 'local_state' => '(up to date)', + 'merges_with' => 'master', + 'local_relationship' => 'tracked', + ], + 'pbi_4371' => [ + 'local_relationship' => 'tracked', + ], + 'refs/remotes/upstream/58120-squashed' => [ + 'local_relationship' => 'stale', + ], + ]; } /** @@ -327,13 +336,13 @@ public function testParseOutputLines() /** * helper for getting a mock Remote object - * + * * the returned test double will provide the sample output * defined in other methods of this test class - * + * * NOTE: this will do an assertion in the hope to ensure * sanity of the test double - * + * * @return \GitElephant\Objects\Remote */ public function getMockRemote() @@ -343,13 +352,10 @@ public function getMockRemote() $sample = $this->sampleRemoteVerbose(); $verboseOutput = explode("\n", $sample); - $mockRemote = $this->getMock( - '\\GitElephant\\Objects\\Remote', //class - array('getShowOutput', 'getVerboseOutput'), //methods to mock - array(), //original constructor args - '', //class for test double - false //call constructor - ); + $mockRemote = $this->getMockBuilder(Remote::class) + ->disableOriginalConstructor() + ->setMethods(['getShowOutput', 'getVerboseOutput']) + ->getMock(); $mockRemote->expects($this->any()) ->method('getShowOutput') @@ -371,7 +377,7 @@ public function getMockRemote() /** * verify object - * + * * NOTE: this is actually verifying the mock object and * could be useless if the helper that makes the double * is flawed. However, it should do the trick so other tests @@ -380,7 +386,7 @@ public function getMockRemote() public function testConstructor() { $obj = $this->getMockRemote(); - $this->assertInstanceOf('\\GitElephant\\Objects\\Remote', $obj); + $this->assertInstanceOf(Remote::class, $obj); } /** @@ -391,7 +397,7 @@ public function testToString() $obj = $this->getMockRemote(); $this->assertEquals( $this->sampleRemoteShowRemoteName(), - (string) $obj, + (string)$obj, 'magic to string method provides the remote name' ); } diff --git a/tests/GitElephant/Objects/TreeTest.php b/tests/GitElephant/Objects/TreeTest.php index e4a0edd4..e8660c7c 100644 --- a/tests/GitElephant/Objects/TreeTest.php +++ b/tests/GitElephant/Objects/TreeTest.php @@ -58,9 +58,9 @@ public function testConstructor() $tree = $this->repository->getTree('HEAD'); $this->assertCount(3, $tree); $treeObj1 = $tree[0]; - $this->assertEquals(Object::TYPE_TREE, $treeObj1->getType()); + $this->assertEquals(NodeObject::TYPE_TREE, $treeObj1->getType()); $treeObj2 = $tree[1]; - $this->assertEquals(Object::TYPE_BLOB, $treeObj2->getType()); + $this->assertEquals(NodeObject::TYPE_BLOB, $treeObj2->getType()); } /** @@ -75,7 +75,7 @@ public function testWithPath() $this->assertInstanceOf('Countable', $tree); $this->assertCount(3, $tree); $treeObjChild = $tree[0]; - $this->assertEquals(Object::TYPE_TREE, $treeObjChild->getType()); + $this->assertEquals(NodeObject::TYPE_TREE, $treeObjChild->getType()); $tree = $this->repository->getTree('HEAD', $treeObjChild); $this->assertCount(1, $tree); } @@ -86,7 +86,8 @@ public function testWithPath() public function testSubmodule() { $tempDir = realpath(sys_get_temp_dir()).'gitelephant_'.md5(uniqid(rand(), 1)); - $tempName = tempnam($tempDir, 'gitelephant'); + // horrible hack because php is beautiful. + $tempName = @tempnam($tempDir, 'gitelephant'); $path = $tempName; unlink($path); mkdir($path); @@ -98,7 +99,7 @@ public function testSubmodule() $this->assertContains('.gitmodules', $tree); $this->assertContains($this->repository->getHumanishName(), $tree); $submodule = $tree[0]; - $this->assertEquals(Object::TYPE_LINK, $submodule->getType()); + $this->assertEquals(NodeObject::TYPE_LINK, $submodule->getType()); } /** @@ -124,8 +125,8 @@ public function testGetObject() $this->assertNull($tree->getObject()); $tree = $this->getRepository()->getTree('HEAD', 'test'); $this->assertNotNull($tree->getObject()); - $this->assertEquals(Object::TYPE_TREE, $tree->getObject()->getType()); + $this->assertEquals(NodeObject::TYPE_TREE, $tree->getObject()->getType()); $tree = $this->getRepository()->getTree('HEAD', 'test/1'); - $this->assertEquals(Object::TYPE_BLOB, $tree->getObject()->getType()); + $this->assertEquals(NodeObject::TYPE_BLOB, $tree->getObject()->getType()); } } diff --git a/tests/GitElephant/RepositoryTest.php b/tests/GitElephant/RepositoryTest.php index 4c5751b0..35256ae8 100644 --- a/tests/GitElephant/RepositoryTest.php +++ b/tests/GitElephant/RepositoryTest.php @@ -13,8 +13,9 @@ namespace GitElephant; +use GitElephant\Command\ResetCommand; use \GitElephant\Objects\Branch; -use \GitElephant\Objects\Object; +use \GitElephant\Objects\NodeObject; use \GitElephant\Objects\Tag; /** @@ -43,7 +44,7 @@ public function testConstruct() { $this->assertEquals($this->getRepository()->getPath(), $this->path); - $this->setExpectedException('GitElephant\Exception\InvalidRepositoryPathException'); + $this->expectException('GitElephant\Exception\InvalidRepositoryPathException'); $repo = new Repository('non-existent-path'); $repo = Repository::open($this->path); @@ -432,7 +433,7 @@ public function testGetObjectLogFolders() $tree = $repo->getTree(); - /* @var $treeObj Object */ + /* @var $treeObj NodeObject */ foreach ($tree as $treeObj) { $name = $treeObj->getName(); $log = $repo->getObjectLog($treeObj, null, null, null); @@ -581,7 +582,7 @@ public function testGetTree() $this->assertCount(2, $tree, 'One file in the repository'); $firstNode = $tree[0]; $this->assertInstanceOf( - 'GitElephant\Objects\Object', + 'GitElephant\Objects\NodeObject', $firstNode, 'array access on tree should give always a node type' ); @@ -592,24 +593,24 @@ public function testGetTree() ); $secondNode = $tree[1]; $this->assertInstanceOf( - 'GitElephant\Objects\Object', + 'GitElephant\Objects\NodeObject', $secondNode, 'array access on tree should give always a node type' ); $this->assertEquals( - Object::TYPE_BLOB, + NodeObject::TYPE_BLOB, $secondNode->getType(), 'second node should be of type tree' ); $subtree = $this->getRepository()->getTree('master', 'test-folder'); $subnode = $subtree[0]; $this->assertInstanceOf( - 'GitElephant\Objects\Object', + 'GitElephant\Objects\NodeObject', $subnode, 'array access on tree should give always a node type' ); $this->assertEquals( - Object::TYPE_BLOB, + NodeObject::TYPE_BLOB, $subnode->getType(), 'subnode should be of type blob' ); @@ -904,6 +905,50 @@ public function testGlobalConfigs() $this->assertEmpty($repo->getGlobalConfigs()); } + /** + * test reset + */ + public function testResetHard() + { + $this->initRepository(); + $repo=$this->getRepository(); + $repo->init(); + $this->addFile('file1'); + $repo->stage(); + $repo->commit('message1'); + $headCommit=$repo->getCommit(); + $this->addFile('file2'); + $repo->stage(); + $repo->commit('message2'); + + $this->assertEquals(2,$repo->countCommits()); + $repo->reset($headCommit,array(ResetCommand::OPTION_HARD)); + $this->assertEquals(1,$repo->countCommits()); + $this->assertEmpty($repo->getIndexStatus()->added()); + } + + /** + * test reset + */ + public function testResetSoft() + { + $this->initRepository(); + $repo=$this->getRepository(); + $repo->init(); + $this->addFile('file1'); + $repo->stage(); + $repo->commit('message1'); + $headCommit=$repo->getCommit(); + $this->addFile('file2'); + $repo->stage(); + $repo->commit('message2'); + + $this->assertEquals(2,$repo->countCommits()); + $repo->reset($headCommit,array(ResetCommand::OPTION_SOFT)); + $this->assertEquals(1,$repo->countCommits()); + $this->assertNotEmpty($repo->getIndexStatus()->added()); + } + /** * test add, remove and get global options * diff --git a/tests/GitElephant/TestCase.php b/tests/GitElephant/TestCase.php index e44f31a3..583ad706 100644 --- a/tests/GitElephant/TestCase.php +++ b/tests/GitElephant/TestCase.php @@ -27,7 +27,7 @@ * * @package GitElephant */ -class TestCase extends \PHPUnit_Framework_TestCase +class TestCase extends \PHPUnit\Framework\TestCase { /** * @var \GitElephant\Command\Caller\CallerInterface @@ -201,13 +201,26 @@ protected function addSubmodule($url, $path) $this->getRepository()->addSubmodule($url, $path); } + /** + * @param $classname + * + * @return \PHPUnit\Framework\MockObject\MockObject + */ + protected function getMock($classname) + { + return $this + ->getMockBuilder($classname) + ->disableOriginalConstructor() + ->getMock(); + } + /** * mock the caller * * @param string $command command * @param string $output output * - * @return \PHPUnit_Framework_MockObject_MockObject + * @return \PHPUnit\Framework\MockObject\MockObject */ protected function getMockCaller($command, $output) { @@ -229,7 +242,7 @@ protected function getMockContainer() return $this->getMock('GitElephant\Command\CommandContainer'); } - protected function addCommandToMockContainer(\PHPUnit_Framework_MockObject_MockObject $container, $commandName) + protected function addCommandToMockContainer(\PHPUnit\Framework\MockObject\MockObject $container, $commandName) { $container ->expects($this->any()) @@ -238,7 +251,7 @@ protected function addCommandToMockContainer(\PHPUnit_Framework_MockObject_MockO ->will($this->returnValue($this->getMockCommand())); } - protected function addOutputToMockRepo(\PHPUnit_Framework_MockObject_MockObject $repo, $output) + protected function addOutputToMockRepo(\PHPUnit\Framework\MockObject\MockObject $repo, $output) { $repo ->expects($this->any())