Skip to content

Commit

Permalink
Add Laravel 5.6 support (#9)
Browse files Browse the repository at this point in the history
Add Laravel 5.6 support
  • Loading branch information
Anton Komarev authored Feb 9, 2018
1 parent 260ef95 commit ce816e3
Show file tree
Hide file tree
Showing 3 changed files with 81 additions and 146 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

All notable changes to `laravel-love` will be documented in this file.

## [5.1.0] - 2018-02-08

### Added

- Laravel 5.6 support ([#9](https://github.com/cybercog/laravel-love/pull/9))

## [5.0.0] - 2018-01-16

### Added
Expand Down Expand Up @@ -166,6 +172,7 @@ All notable changes to `laravel-love` will be documented in this file.

- Initial release

[5.1.0]: https://github.com/cybercog/laravel-love/compare/5.0.0...5.1.0
[5.0.0]: https://github.com/cybercog/laravel-love/compare/4.0.0...5.0.0
[4.0.0]: https://github.com/cybercog/laravel-love/compare/3.1.0...4.0.0
[3.1.0]: https://github.com/cybercog/laravel-love/compare/3.0.0...3.1.0
Expand Down
14 changes: 7 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@
},
"require": {
"php": "^7.0",
"illuminate/database": "~5.5",
"illuminate/support": "~5.5"
"illuminate/database": "~5.5.0|~5.6.0",
"illuminate/support": "~5.5.0|~5.6.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^1.11",
"mockery/mockery": "^0.9.8",
"orchestra/database": "~3.5.0",
"orchestra/testbench": "~3.5.0",
"phpunit/phpunit": "^6.0"
"friendsofphp/php-cs-fixer": "^2.10",
"mockery/mockery": "^1.0",
"orchestra/database": "~3.5.0|~3.6.0",
"orchestra/testbench": "~3.5.0|~3.6.0",
"phpunit/phpunit": "^6.0|^7.0"
},
"autoload": {
"psr-4": {
Expand Down
206 changes: 67 additions & 139 deletions tests/Unit/Console/Commands/Recount.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,13 @@

namespace Cog\Tests\Laravel\Love\Unit\Console\Commands;

use Cog\Contracts\Love\Likeable\Exceptions\InvalidLikeable;
use Cog\Laravel\Love\LikeCounter\Models\LikeCounter;
use Cog\Tests\Laravel\Love\Stubs\Models\Article;
use Cog\Tests\Laravel\Love\Stubs\Models\Entity;
use Cog\Tests\Laravel\Love\Stubs\Models\EntityWithMorphMap;
use Cog\Tests\Laravel\Love\Stubs\Models\User;
use Cog\Tests\Laravel\Love\TestCase;
use Illuminate\Contracts\Console\Kernel;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Output\BufferedOutput;

/**
* Class Recount.
Expand All @@ -30,15 +28,6 @@
*/
class Recount extends TestCase
{
protected $kernel;

protected function setUp()
{
parent::setUp();

$this->kernel = $this->app->make(Kernel::class);
}

/* Likes */

/** @test */
Expand All @@ -60,15 +49,11 @@ public function it_can_recount_all_models_likes()

LikeCounter::truncate();

$status = $this->kernel->handle(
$input = new ArrayInput([
'command' => 'love:recount',
'type' => 'LIKE',
]),
$output = new BufferedOutput
);
$status = $this->artisan('love:recount', [
'type' => 'LIKE',
]);

$this->assertEquals(0, $status);
$this->assertSame(0, $status);

$likeCounter = LikeCounter::all();
$this->assertCount(3, $likeCounter);
Expand All @@ -95,16 +80,12 @@ public function it_can_recount_model_likes()

LikeCounter::truncate();

$status = $this->kernel->handle(
$input = new ArrayInput([
'command' => 'love:recount',
'model' => Entity::class,
'type' => 'LIKE',
]),
$output = new BufferedOutput
);
$status = $this->artisan('love:recount', [
'model' => Entity::class,
'type' => 'LIKE',
]);

$this->assertEquals(0, $status);
$this->assertSame(0, $status);

$likeCounter = LikeCounter::all();
$this->assertCount(2, $likeCounter);
Expand All @@ -130,16 +111,12 @@ public function it_can_recount_model_likes_using_morph_map()

LikeCounter::truncate();

$status = $this->kernel->handle(
$input = new ArrayInput([
'command' => 'love:recount',
'model' => 'entity-with-morph-map',
'type' => 'LIKE',
]),
$output = new BufferedOutput
);
$status = $this->artisan('love:recount', [
'model' => 'entity-with-morph-map',
'type' => 'LIKE',
]);

$this->assertEquals(0, $status);
$this->assertSame(0, $status);

$likeCounter = LikeCounter::all();
$this->assertCount(2, $likeCounter);
Expand All @@ -165,16 +142,12 @@ public function it_can_recount_model_likes_with_morph_map_using_full_class_name(

LikeCounter::truncate();

$status = $this->kernel->handle(
$input = new ArrayInput([
'command' => 'love:recount',
'model' => EntityWithMorphMap::class,
'type' => 'LIKE',
]),
$output = new BufferedOutput
);
$status = $this->artisan('love:recount', [
'model' => EntityWithMorphMap::class,
'type' => 'LIKE',
]);

$this->assertEquals(0, $status);
$this->assertSame(0, $status);

$likeCounter = LikeCounter::all();
$this->assertCount(2, $likeCounter);
Expand Down Expand Up @@ -204,15 +177,11 @@ public function it_can_recount_all_models_dislikes()

LikeCounter::truncate();

$status = $this->kernel->handle(
$input = new ArrayInput([
'command' => 'love:recount',
'type' => 'DISLIKE',
]),
$output = new BufferedOutput
);
$status = $this->artisan('love:recount', [
'type' => 'DISLIKE',
]);

$this->assertEquals(0, $status);
$this->assertSame(0, $status);

$likeCounter = LikeCounter::all();
$this->assertCount(3, $likeCounter);
Expand All @@ -239,16 +208,12 @@ public function it_can_recount_model_dislikes()

LikeCounter::truncate();

$status = $this->kernel->handle(
$input = new ArrayInput([
'command' => 'love:recount',
'model' => Entity::class,
'type' => 'DISLIKE',
]),
$output = new BufferedOutput
);
$status = $this->artisan('love:recount', [
'model' => Entity::class,
'type' => 'DISLIKE',
]);

$this->assertEquals(0, $status);
$this->assertSame(0, $status);

$likeCounter = LikeCounter::all();
$this->assertCount(2, $likeCounter);
Expand All @@ -274,16 +239,12 @@ public function it_can_recount_model_dislikes_using_morph_map()

LikeCounter::truncate();

$status = $this->kernel->handle(
$input = new ArrayInput([
'command' => 'love:recount',
'model' => 'entity-with-morph-map',
'type' => 'DISLIKE',
]),
$output = new BufferedOutput
);
$status = $this->artisan('love:recount', [
'model' => 'entity-with-morph-map',
'type' => 'DISLIKE',
]);

$this->assertEquals(0, $status);
$this->assertSame(0, $status);

$likeCounter = LikeCounter::all();
$this->assertCount(2, $likeCounter);
Expand All @@ -309,16 +270,12 @@ public function it_can_recount_model_dislikes_with_morph_map_using_full_class_na

LikeCounter::truncate();

$status = $this->kernel->handle(
$input = new ArrayInput([
'command' => 'love:recount',
'model' => EntityWithMorphMap::class,
'type' => 'DISLIKE',
]),
$output = new BufferedOutput
);
$status = $this->artisan('love:recount', [
'model' => EntityWithMorphMap::class,
'type' => 'DISLIKE',
]);

$this->assertEquals(0, $status);
$this->assertSame(0, $status);

$likeCounter = LikeCounter::all();
$this->assertCount(2, $likeCounter);
Expand Down Expand Up @@ -347,14 +304,9 @@ public function it_can_recount_all_models_all_like_types()

LikeCounter::truncate();

$status = $this->kernel->handle(
$input = new ArrayInput([
'command' => 'love:recount',
]),
$output = new BufferedOutput
);
$status = $this->artisan('love:recount');

$this->assertEquals(0, $status);
$this->assertSame(0, $status);

$likeCounter = LikeCounter::all();
$this->assertCount(5, $likeCounter);
Expand All @@ -381,15 +333,11 @@ public function it_can_recount_model_all_like_types()

LikeCounter::truncate();

$status = $this->kernel->handle(
$input = new ArrayInput([
'command' => 'love:recount',
'model' => Entity::class,
]),
$output = new BufferedOutput
);
$status = $this->artisan('love:recount', [
'model' => Entity::class,
]);

$this->assertEquals(0, $status);
$this->assertSame(0, $status);

$likeCounter = LikeCounter::all();
$this->assertCount(4, $likeCounter);
Expand All @@ -415,15 +363,11 @@ public function it_can_recount_model_all_like_types_using_morph_map()

LikeCounter::truncate();

$status = $this->kernel->handle(
$input = new ArrayInput([
'command' => 'love:recount',
'model' => 'entity-with-morph-map',
]),
$output = new BufferedOutput
);
$status = $this->artisan('love:recount', [
'model' => 'entity-with-morph-map',
]);

$this->assertEquals(0, $status);
$this->assertSame(0, $status);

$likeCounter = LikeCounter::all();
$this->assertCount(4, $likeCounter);
Expand All @@ -449,15 +393,11 @@ public function it_can_recount_model_all_like_types_with_morph_map_using_full_cl

LikeCounter::truncate();

$status = $this->kernel->handle(
$input = new ArrayInput([
'command' => 'love:recount',
'model' => EntityWithMorphMap::class,
]),
$output = new BufferedOutput
);
$status = $this->artisan('love:recount', [
'model' => EntityWithMorphMap::class,
]);

$this->assertEquals(0, $status);
$this->assertSame(0, $status);

$likeCounter = LikeCounter::all();
$this->assertCount(4, $likeCounter);
Expand All @@ -472,37 +412,25 @@ public function it_can_recount_model_all_like_types_with_morph_map_using_full_cl
/** @test */
public function it_can_throw_model_invalid_exception_on_not_exist_morph_map()
{
// TODO: Check if works on older Laravel versions. Otherwise uncomment assertContains on the end.
$this->expectException(\Cog\Contracts\Love\Likeable\Exceptions\InvalidLikeable::class);

$status = $this->kernel->handle(
$input = new ArrayInput([
'command' => 'love:recount',
'model' => 'not-exist-model',
]),
$output = new BufferedOutput
);

$this->assertEquals(1, $status);
//$this->assertContains('Cog\Contracts\Love\Likeable\Exceptions\InvalidLikeable', $output->fetch());
$this->expectException(InvalidLikeable::class);

$status = $this->artisan('love:recount', [
'model' => 'not-exist-model',
]);

$this->assertSame(1, $status);
}

/** @test */
public function it_can_throw_model_invalid_exception_if_class_not_implemented_has_likes_interface()
{
// TODO: Check if works on older Laravel versions. Otherwise uncomment assertContains on the end.
$this->expectException(\Cog\Contracts\Love\Likeable\Exceptions\InvalidLikeable::class);

$status = $this->kernel->handle(
$input = new ArrayInput([
'command' => 'love:recount',
'model' => User::class,
]),
$output = new BufferedOutput
);

$this->assertEquals(1, $status);
//$this->assertContains('Cog\Contracts\Love\Likeable\Exceptions\InvalidLikeable', $output->fetch());
$this->expectException(InvalidLikeable::class);

$status = $this->artisan('love:recount', [
'model' => User::class,
]);

$this->assertSame(1, $status);
}

public function it_deletes_records_before_recount()
Expand Down

0 comments on commit ce816e3

Please sign in to comment.