diff --git a/CHANGELOG.md b/CHANGELOG.md index d601079..e635a46 100755 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,9 @@ # Changelog -All Notable changes to `laravel-model-cleanup` will be documented in this file +All notable changes to `laravel-model-cleanup` will be documented in this file + +### 1.2.0 - 2016-08-10 +- allow v3 of php parser. ### 1.1.0 - 2016-08-10 - Added `ModelWasCleanedUpEvent` diff --git a/README.md b/README.md index e339261..2a97ab6 100644 --- a/README.md +++ b/README.md @@ -34,11 +34,11 @@ Spatie is a webdesign agency based in Antwerp, Belgium. You'll find an overview ## Postcardware -You're free to use this package (it's [MIT-licensed](LICENSE.md)), but if it makes it to your production environment you are required to send us a postcard from your hometown, mentioning which of our package(s) you are using. +You're free to use this package (it's [MIT-licensed](LICENSE.md)), but if it makes it to your production environment we highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. Our address is: Spatie, Samberstraat 69D, 2060 Antwerp, Belgium. -The best postcards will get published on the open source page on our website. +The best postcards are published [on our website](https://spatie.be/en/opensource/postcards). ## Installation diff --git a/composer.json b/composer.json index 0518841..d32a702 100644 --- a/composer.json +++ b/composer.json @@ -23,9 +23,9 @@ ], "require": { "php" : "^7.0", - "illuminate/support": "^5.2", + "illuminate/support": "~5.2.0|~5.3.0|~5.4.0", "nesbot/carbon": "^1.0", - "nikic/php-parser":"^2.0" + "nikic/php-parser":"^2.0|^3.0" }, "require-dev": { "phpunit/phpunit": "^5.0", diff --git a/src/CleanUpModelsCommand.php b/src/CleanUpModelsCommand.php index e43e865..7940ec8 100644 --- a/src/CleanUpModelsCommand.php +++ b/src/CleanUpModelsCommand.php @@ -6,8 +6,8 @@ use Illuminate\Support\Collection; use Illuminate\Filesystem\Filesystem; use PhpParser\Node\Stmt\Class_; +use PhpParser\NodeTraverser; use PhpParser\ParserFactory; -use ClassPreloader\Parser\NodeTraverser; use PhpParser\NodeVisitor\NameResolver; class CleanUpModelsCommand extends Command diff --git a/tests/DatabaseCleanupTest.php b/tests/DatabaseCleanupTest.php index e77d710..0f5432a 100644 --- a/tests/DatabaseCleanupTest.php +++ b/tests/DatabaseCleanupTest.php @@ -59,48 +59,6 @@ public function it_leaves_models_without_the_GetCleanUp_trait_untouched() $this->assertCount(10, UncleanableItem::all()); } - /** @test */ - public function it_will_fire_off_an_event_when_a_model_has_been_cleaned() - { - $this->assertCount(20, CleanableItem::all()); - - $this->app['config']->set('laravel-model-cleanup', - [ - 'models' => [CleanableItem::class], - 'directories' => [], - - ]); - - $this->app->make(Kernel::class)->call('clean:models'); - - $firedEvent = $this->getFiredEvent(ModelWasCleanedUp::class); - - $this->assertInstanceOf(ModelWasCleanedUp::class, $firedEvent); - - $this->assertSame(10, $firedEvent->numberOfDeletedRecords); - } - - /** @test */ - public function it_will_fire_off_an_event_when_a_model_has_been_cleaned_even_if_no_records_were_deleted() - { - CleanableItem::truncate(); - - $this->app['config']->set('laravel-model-cleanup', - [ - 'models' => [CleanableItem::class], - 'directories' => [], - - ]); - - $this->app->make(Kernel::class)->call('clean:models'); - - $firedEvent = $this->getFiredEvent(ModelWasCleanedUp::class); - - $this->assertInstanceOf(ModelWasCleanedUp::class, $firedEvent); - - $this->assertSame(0, $firedEvent->numberOfDeletedRecords); - } - protected function setConfigThatCleansUpDirectory() { $this->app['config']->set('laravel-model-cleanup', diff --git a/tests/TestCase.php b/tests/TestCase.php index 5b639ea..63f2741 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -84,7 +84,11 @@ public function getFiredEvent($eventClassName) { return collect($this->firedEvents) ->filter(function ($event) use ($eventClassName) { - return $event instanceof $eventClassName; + if ($event instanceof $eventClassName) { + return true; + }; + + return $event == $eventClassName; }) ->first(); }