Skip to content

Commit

Permalink
Add Laravel 5.7 support (#21)
Browse files Browse the repository at this point in the history
Add Laravel 5.7 support
  • Loading branch information
antonkomarev authored Sep 9, 2018
1 parent c7de1bf commit 258857c
Show file tree
Hide file tree
Showing 4 changed files with 84 additions and 10 deletions.
16 changes: 15 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,23 @@

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

## [5.2.0] - 2018-09-09

### Added

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

## [5.1.1] - 2018-02-16

### Fixed

- ([#11](https://github.com/cybercog/laravel-love/pull/11)) Added missing migrations auto-loading

## [5.1.0] - 2018-02-08

### Added

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

## [5.0.0] - 2018-01-16

Expand Down Expand Up @@ -172,6 +184,8 @@ All notable changes to `laravel-love` will be documented in this file.

- Initial release

[5.2.0]: https://github.com/cybercog/laravel-love/compare/5.1.1...5.2.0
[5.1.1]: https://github.com/cybercog/laravel-love/compare/5.1.0...5.1.1
[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
Expand Down
8 changes: 4 additions & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,14 @@
},
"require": {
"php": "^7.0",
"illuminate/database": "~5.5.0|~5.6.0",
"illuminate/support": "~5.5.0|~5.6.0"
"illuminate/database": "~5.5.0|~5.6.0|~5.7.0",
"illuminate/support": "~5.5.0|~5.6.0|~5.7.0"
},
"require-dev": {
"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",
"orchestra/database": "~3.5.0|~3.6.0|~3.7.0",
"orchestra/testbench": "~3.5.0|~3.6.0|~3.7.0",
"phpunit/phpunit": "^6.0|^7.0"
},
"autoload": {
Expand Down
1 change: 0 additions & 1 deletion phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
convertWarningsToExceptions="true"
processIsolation="false"
stopOnFailure="false"
syntaxCheck="false"
verbose="true"
>
<testsuites>
Expand Down
69 changes: 65 additions & 4 deletions tests/Unit/Console/Commands/Recount.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ class Recount extends TestCase
/** @test */
public function it_can_recount_all_models_likes()
{
if ($this->isLaravelVersion('5.7')) {
$this->withoutMockingConsoleOutput();
}

$entity1 = factory(Entity::class)->create();
$entity2 = factory(EntityWithMorphMap::class)->create();
$article = factory(Article::class)->create();
Expand Down Expand Up @@ -66,6 +70,10 @@ public function it_can_recount_all_models_likes()
/** @test */
public function it_can_recount_model_likes()
{
if ($this->isLaravelVersion('5.7')) {
$this->withoutMockingConsoleOutput();
}

$entity1 = factory(Entity::class)->create();
$entity2 = factory(Entity::class)->create();

Expand Down Expand Up @@ -97,6 +105,10 @@ public function it_can_recount_model_likes()
/** @test */
public function it_can_recount_model_likes_using_morph_map()
{
if ($this->isLaravelVersion('5.7')) {
$this->withoutMockingConsoleOutput();
}

$entity1 = factory(EntityWithMorphMap::class)->create();
$entity2 = factory(EntityWithMorphMap::class)->create();

Expand Down Expand Up @@ -128,6 +140,10 @@ public function it_can_recount_model_likes_using_morph_map()
/** @test */
public function it_can_recount_model_likes_with_morph_map_using_full_class_name()
{
if ($this->isLaravelVersion('5.7')) {
$this->withoutMockingConsoleOutput();
}

$entity1 = factory(EntityWithMorphMap::class)->create();
$entity2 = factory(EntityWithMorphMap::class)->create();

Expand Down Expand Up @@ -161,6 +177,10 @@ public function it_can_recount_model_likes_with_morph_map_using_full_class_name(
/** @test */
public function it_can_recount_all_models_dislikes()
{
if ($this->isLaravelVersion('5.7')) {
$this->withoutMockingConsoleOutput();
}

$entity1 = factory(Entity::class)->create();
$entity2 = factory(EntityWithMorphMap::class)->create();
$article = factory(Article::class)->create();
Expand Down Expand Up @@ -194,6 +214,10 @@ public function it_can_recount_all_models_dislikes()
/** @test */
public function it_can_recount_model_dislikes()
{
if ($this->isLaravelVersion('5.7')) {
$this->withoutMockingConsoleOutput();
}

$entity1 = factory(Entity::class)->create();
$entity2 = factory(Entity::class)->create();

Expand Down Expand Up @@ -225,6 +249,10 @@ public function it_can_recount_model_dislikes()
/** @test */
public function it_can_recount_model_dislikes_using_morph_map()
{
if ($this->isLaravelVersion('5.7')) {
$this->withoutMockingConsoleOutput();
}

$entity1 = factory(EntityWithMorphMap::class)->create();
$entity2 = factory(EntityWithMorphMap::class)->create();

Expand Down Expand Up @@ -256,6 +284,10 @@ public function it_can_recount_model_dislikes_using_morph_map()
/** @test */
public function it_can_recount_model_dislikes_with_morph_map_using_full_class_name()
{
if ($this->isLaravelVersion('5.7')) {
$this->withoutMockingConsoleOutput();
}

$entity1 = factory(EntityWithMorphMap::class)->create();
$entity2 = factory(EntityWithMorphMap::class)->create();

Expand Down Expand Up @@ -289,6 +321,10 @@ public function it_can_recount_model_dislikes_with_morph_map_using_full_class_na
/** @test */
public function it_can_recount_all_models_all_like_types()
{
if ($this->isLaravelVersion('5.7')) {
$this->withoutMockingConsoleOutput();
}

$entity1 = factory(Entity::class)->create();
$entity2 = factory(EntityWithMorphMap::class)->create();
$article = factory(Article::class)->create();
Expand Down Expand Up @@ -320,6 +356,10 @@ public function it_can_recount_all_models_all_like_types()
/** @test */
public function it_can_recount_model_all_like_types()
{
if ($this->isLaravelVersion('5.7')) {
$this->withoutMockingConsoleOutput();
}

$entity1 = factory(Entity::class)->create();
$entity2 = factory(Entity::class)->create();

Expand Down Expand Up @@ -350,6 +390,10 @@ public function it_can_recount_model_all_like_types()
/** @test */
public function it_can_recount_model_all_like_types_using_morph_map()
{
if ($this->isLaravelVersion('5.7')) {
$this->withoutMockingConsoleOutput();
}

$entity1 = factory(EntityWithMorphMap::class)->create();
$entity2 = factory(EntityWithMorphMap::class)->create();

Expand Down Expand Up @@ -380,6 +424,10 @@ public function it_can_recount_model_all_like_types_using_morph_map()
/** @test */
public function it_can_recount_model_all_like_types_with_morph_map_using_full_class_name()
{
if ($this->isLaravelVersion('5.7')) {
$this->withoutMockingConsoleOutput();
}

$entity1 = factory(EntityWithMorphMap::class)->create();
$entity2 = factory(EntityWithMorphMap::class)->create();

Expand Down Expand Up @@ -412,29 +460,42 @@ 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()
{
if ($this->isLaravelVersion('5.7')) {
$this->withoutMockingConsoleOutput();
}

$this->expectException(InvalidLikeable::class);

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

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

/** @test */
public function it_can_throw_model_invalid_exception_if_class_not_implemented_has_likes_interface()
{
if ($this->isLaravelVersion('5.7')) {
$this->withoutMockingConsoleOutput();
}

$this->expectException(InvalidLikeable::class);

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

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

public function it_deletes_records_before_recount()
{
// :TODO: Mock `removeLikeCountersOfType` method call
}

private function isLaravelVersion(string $version): bool
{
return starts_with($this->app->version(), $version);
}
}

0 comments on commit 258857c

Please sign in to comment.