Skip to content
This repository has been archived by the owner on Mar 21, 2021. It is now read-only.

Commit

Permalink
Add Laravel 5.4 support (#13)
Browse files Browse the repository at this point in the history
* Add laravel 5.4 support
  • Loading branch information
Pe Ell authored Feb 20, 2017
1 parent 9226341 commit 73d45a3
Show file tree
Hide file tree
Showing 14 changed files with 71 additions and 21 deletions.
13 changes: 13 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-likeable` will be documented in this file.

## 2.1.0 - 2017-02-20

### Added

- Laravel 5.4 support.

## 2.0.1 - 2017-01-11

- Removed unused properties in `LikeObserver` #12
Expand Down Expand Up @@ -32,3 +38,10 @@ All notable changes to `laravel-likeable` will be documented in this file.
## 1.0.0 - 2016-09-06

- Initial release

[2.1.0]: https://github.com/cybercog/laravel-likeable/compare/2.0.1...2.1.0
[2.0.1]: https://github.com/cybercog/laravel-likeable/compare/2.0.0...2.0.1
[2.0.0]: https://github.com/cybercog/laravel-likeable/compare/1.1.2...2.0.0
[1.1.2]: https://github.com/cybercog/laravel-likeable/compare/1.1.1...1.1.2
[1.1.1]: https://github.com/cybercog/laravel-likeable/compare/1.1.0...1.1.1
[1.1.0]: https://github.com/cybercog/laravel-likeable/compare/1.0.0...1.1.0
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed re
- [rtconner/laravel-likeable](https://github.com/rtconner/laravel-likeable)
- [faustbrian/laravel-likeable](https://github.com/faustbrian/Laravel-Likeable)
- [sukohi/evaluation](https://github.com/SUKOHI/Evaluation)
- [zvermafia/lavoter](https://github.com/zvermafia/lavoter)

*Feel free to add more alternatives as Pull Request.*

Expand Down
34 changes: 24 additions & 10 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{
"name": "cybercog/laravel-likeable",
"description": "Trait for Laravel Eloquent models to allow easy implementation of a `like` & `dislike` features.",
"type": "library",
"license": "MIT",
"keywords": [
"trait",
"laravel",
Expand All @@ -22,18 +24,25 @@
"role": "Developer"
}
],
"license": "BSD-3-Clause",
"type": "library",
"homepage": "https://github.com/cybercog/laravel-likeable",
"support": {
"email": "[email protected]",
"issues": "https://github.com/cybercog/laravel-likeable/issues",
"wiki": "https://github.com/cybercog/laravel-likeable/wiki",
"source": "https://github.com/cybercog/laravel-likeable",
"docs": "https://github.com/cybercog/laravel-likeable/wiki"
},
"require": {
"php": "^5.6|^7.0",
"illuminate/database": "~5.1.20|~5.2.0|~5.3.0",
"illuminate/support": "~5.1.20|~5.2.0|~5.3.0"
"illuminate/database": "~5.1.20|~5.2.0|~5.3.0|~5.4.0",
"illuminate/support": "~5.1.20|~5.2.0|~5.3.0|~5.4.0",
"php": "^5.6|^7.0"
},
"require-dev": {
"phpunit/phpunit": "^5.2",
"orchestra/testbench": "~3.0",
"mockery/mockery": "~0.9",
"friendsofphp/php-cs-fixer": "^1.11"
"friendsofphp/php-cs-fixer": "^1.11",
"mockery/mockery": "^0.9.5",
"orchestra/database": "~3.4.0",
"orchestra/testbench": "~3.4.0",
"phpunit/phpunit": "^5.7"
},
"autoload": {
"psr-4": {
Expand All @@ -44,5 +53,10 @@
"psr-4": {
"Cog\\Likeable\\Tests\\": "tests/"
}
}
},
"config": {
"sort-packages": true
},
"minimum-stability": "dev",
"prefer-stable" : true
}
4 changes: 2 additions & 2 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
>
<testsuites>
<testsuite name="Package Test Suite">
<directory suffix=".php">./tests/</directory>
<exclude>./tests/factories/</exclude>
<directory suffix=".php">tests/</directory>
<exclude>tests/database/factories/</exclude>
</testsuite>
</testsuites>
<php>
Expand Down
30 changes: 23 additions & 7 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
namespace Cog\Likeable\Tests;

use Cog\Likeable\Tests\Stubs\Models\EntityWithMorphMap;
use File;
use Illuminate\Database\Eloquent\Relations\Relation;
use Illuminate\Support\Facades\File;
use Mockery;
use Orchestra\Testbench\TestCase as Orchestra;

Expand All @@ -24,17 +24,30 @@
*/
abstract class TestCase extends Orchestra
{
/**
* Register a callback to be run before the application is destroyed.
* TODO: Remove it when will be pushed to Orchestra Testbench package.
*
* @param callable $callback
*
* @return void
*/
protected function beforeApplicationDestroyed(callable $callback)
{
array_unshift($this->beforeApplicationDestroyedCallbacks, $callback);
}

/**
* Actions to be performed on PHPUnit start.
*/
public function setUp()
protected function setUp()
{
parent::setUp();

$this->destroyPackageMigrations();
$this->publishPackageMigrations();
$this->migrateUnitTestTables();
$this->migratePackageTables();
$this->migrateUnitTestTables();
$this->registerPackageFactories();
$this->registerTestMorphMaps();
}
Expand All @@ -56,6 +69,7 @@ protected function getPackageProviders($app)
{
return [
\Cog\Likeable\Providers\LikeableServiceProvider::class,
\Orchestra\Database\ConsoleServiceProvider::class,
];
}

Expand All @@ -80,8 +94,9 @@ protected function destroyPackageMigrations()
*/
protected function migrateUnitTestTables()
{
$this->artisan('migrate', [
'--realpath' => realpath(__DIR__ . '/migrations'),
$this->loadMigrationsFrom([
//'--database' => 'sqlite',
'--realpath' => realpath(__DIR__ . '/database/migrations'),
]);
}

Expand All @@ -90,7 +105,8 @@ protected function migrateUnitTestTables()
*/
protected function migratePackageTables()
{
$this->artisan('migrate', [
$this->loadMigrationsFrom([
//'--database' => 'sqlite',
'--realpath' => database_path('migrations'),
]);
}
Expand All @@ -100,7 +116,7 @@ protected function migratePackageTables()
*/
protected function registerPackageFactories()
{
$pathToFactories = realpath(__DIR__ . '/factories');
$pathToFactories = realpath(__DIR__ . '/database/factories');
$this->withFactories($pathToFactories);
}

Expand Down
File renamed without changes.
10 changes: 8 additions & 2 deletions tests/unit/Console/LikeableRecountCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,9 @@ 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\Likeable\Exceptions\ModelInvalidException::class);

$status = $this->kernel->handle(
$input = new ArrayInput([
'command' => 'likeable:recount',
Expand All @@ -479,12 +482,15 @@ public function it_can_throw_model_invalid_exception_on_not_exist_morph_map()
);

$this->assertEquals(1, $status);
$this->assertContains('Cog\Likeable\Exceptions\ModelInvalidException', $output->fetch());
//$this->assertContains('Cog\Likeable\Exceptions\ModelInvalidException', $output->fetch());
}

/** @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\Likeable\Exceptions\ModelInvalidException::class);

$status = $this->kernel->handle(
$input = new ArrayInput([
'command' => 'likeable:recount',
Expand All @@ -494,7 +500,7 @@ public function it_can_throw_model_invalid_exception_if_class_not_implemented_ha
);

$this->assertEquals(1, $status);
$this->assertContains('Cog\Likeable\Exceptions\ModelInvalidException', $output->fetch());
//$this->assertContains('Cog\Likeable\Exceptions\ModelInvalidException', $output->fetch());
}

public function it_deletes_records_before_recount()
Expand Down

0 comments on commit 73d45a3

Please sign in to comment.