diff --git a/CHANGELOG.md b/CHANGELOG.md index 12c293c..1299c95 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,20 +4,28 @@ All Notable changes to `collage` will be documented in this file. Updates should follow the [Keep a CHANGELOG](http://keepachangelog.com/) principles. -## NEXT - Very Soon... +## NEXT - Very Soon ### Added + - AutoDiscovery Support for Laravel 5.5 and above +- PHP Unit tests +- Travis CI Support ### Deprecated + - Nothing ### Fixed + - Maximum Allowed Images Count - Code Styling +- Major Bugs ### Removed + - Nothing ### Security + - Nothing diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 84063d8..f8a4291 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -4,11 +4,12 @@ Contributions are **welcome** and will be fully **credited**. We accept contributions via Pull Requests on [Github](https://github.com/tzsk/collage). - ## Pull Requests - **[PSR-2 Coding Standard](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md)** - Check the code style with ``$ composer check-style`` and fix it with ``$ composer fix-style``. +- **Include Tests** - Make sure sure to include tests. Any feature without test won't be accepted. Any fixes which breaks existing test results will not be excepted unless it is a major Bug. + - **Document any change in behaviour** - Make sure the `README.md` and any other relevant documentation are kept up-to-date. - **Consider our release cycle** - We try to follow [SemVer v2.0.0](http://semver.org/). Randomly breaking public APIs is not an option. diff --git a/README.md b/README.md index 5de62a1..08f1228 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,7 @@ [![Latest Version on Packagist][ico-version]][link-packagist] [![Software License][ico-license]](LICENSE.md) [![StyleCI](https://styleci.io/repos/103735431/shield?branch=master)](https://styleci.io/repos/103735431) +[![Build Status](https://travis-ci.org/tzsk/collage.svg?branch=master)](https://travis-ci.org/tzsk/collage) [![Quality Score][ico-code-quality]][link-code-quality] [![Build Status](https://scrutinizer-ci.com/g/tzsk/collage/badges/build.png?b=master)](https://scrutinizer-ci.com/g/tzsk/collage/build-status/master) [![Total Downloads][ico-downloads]][link-downloads] @@ -22,6 +23,8 @@ $ composer require tzsk/collage ## Configure +> NOTE: Ignore this step if you are using this package outside laravel. You can directly jump into using it. + Then add the Service Provider and Alias in your `config/app.php` file: ```php @@ -79,7 +82,21 @@ $images = [ Now, there are several configurations available most of them are optional. Below is the full syntax. ```php -$collage = Collage::make(400, 400) +$image = Collage::make(400, 400) + ->padding(10) + ->background('#f00') + ->from($images, function ($layout) { + ... + }); +``` + +### Outside Laravel + +```php +use Tzsk\Collage\MakeCollage; + +$collage = new MakeCollage(); +$image = $collage->make(400, 400) ->padding(10) ->background('#f00') ->from($images, function ($layout) { @@ -153,6 +170,16 @@ It returns the Intervention Image Object you can `save()`, `response()` or do wh Visit: [Intervention Image Documentation](http://image.intervention.io) to know more. +## Testing + +After Cloning the repository, install all composer dependecies by running: `composer install`. + +Then Run Tests: + +```bash +$ composer test +``` + ## Change log Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently. diff --git a/tests/Contracts/CollageGeneratorTest.php b/tests/Contracts/CollageGeneratorTest.php index e83540e..89bd898 100644 --- a/tests/Contracts/CollageGeneratorTest.php +++ b/tests/Contracts/CollageGeneratorTest.php @@ -2,17 +2,37 @@ namespace Tzsk\Collage\Tests\Contracts; +use Intervention\Image\Image; use Tzsk\Collage\Helpers\File; use Tzsk\Collage\Helpers\Config; use Tzsk\Collage\Tests\PhpTestCase; +use Intervention\Image\ImageManagerStatic; use Tzsk\Collage\Contracts\CollageGenerator; +use Tzsk\Collage\Exceptions\ImageCountException; class CollageGeneratorTest extends PhpTestCase { - public function test_it_can_create_something() + protected $generator; + + public function setUp() + { + $this->generator = $generator = new FakeCollageGenerator(new File, new Config); + } + + public function test_it_can_create_image() + { + $this->assertInstanceOf(Image::class, $this->generator->create()); + } + + public function test_it_has_image_collection() + { + $this->assertCount(0, $this->generator->getImages()); + } + + public function test_it_can_check_for_errors() { - $generator = new FakeCollageGenerator(new File, new Config); - $this->assertEquals($generator->create(), 'foo'); + $this->expectException(ImageCountException::class); + $this->generator->fakeCheck(1); } } @@ -20,6 +40,16 @@ class FakeCollageGenerator extends CollageGenerator { public function create($closure = null) { - return 'foo'; + return ImageManagerStatic::make('tests/images/image.jpg'); + } + + public function getImages() + { + return $this->images; + } + + public function fakeCheck($count) + { + $this->check($count); } } diff --git a/tests/LaravelMakeCollageTest.php b/tests/LaravelMakeCollageTest.php new file mode 100644 index 0000000..4f45ea7 --- /dev/null +++ b/tests/LaravelMakeCollageTest.php @@ -0,0 +1,27 @@ +assertInstanceOf(MakeCollage::class, Collage::make(100)); + } + + public function test_it_does_all_the_usual_things() + { + $images = [ + ImageManagerStatic::make('tests/images/image.jpg'), + file_get_contents('tests/images/image.jpg'), + 'tests/images/image.jpg' + ]; + + $this->assertInstanceOf(Image::class, Collage::make(100)->from($images)); + } +} diff --git a/tests/LaravelTestCase.php b/tests/LaravelTestCase.php index 53a6481..a12e5dc 100644 --- a/tests/LaravelTestCase.php +++ b/tests/LaravelTestCase.php @@ -6,4 +6,15 @@ class LaravelTestCase extends OrchestraTestCase { + protected function getPackageProviders($app) + { + return ['Tzsk\Collage\Provider\CollageServiceProvider']; + } + + protected function getPackageAliases($app) + { + return [ + 'Collage' => 'Tzsk\Collage\Facade\Collage' + ]; + } }