Skip to content

Commit

Permalink
Added Outside Laravel Use
Browse files Browse the repository at this point in the history
  • Loading branch information
tzsk committed Jul 28, 2018
1 parent 867b4a8 commit 2cd31aa
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 7 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
3 changes: 2 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
29 changes: 28 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand All @@ -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
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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.
Expand Down
38 changes: 34 additions & 4 deletions tests/Contracts/CollageGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,54 @@

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);
}
}

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);
}
}
27 changes: 27 additions & 0 deletions tests/LaravelMakeCollageTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?php

namespace Tzsk\Collage\Tests;

use Intervention\Image\Image;
use Tzsk\Collage\MakeCollage;
use Tzsk\Collage\Facade\Collage;
use Intervention\Image\ImageManagerStatic;

class LaravelMakeCollageTest extends LaravelTestCase
{
public function test_it_uses_make_collage_class()
{
$this->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));
}
}
11 changes: 11 additions & 0 deletions tests/LaravelTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'
];
}
}

0 comments on commit 2cd31aa

Please sign in to comment.