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

Commit

Permalink
commit
Browse files Browse the repository at this point in the history
  • Loading branch information
freekmurze committed Mar 21, 2017
1 parent fcc7aaf commit 73f8521
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 49 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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`
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion src/CleanUpModelsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
42 changes: 0 additions & 42 deletions tests/DatabaseCleanupTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
6 changes: 5 additions & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down

0 comments on commit 73f8521

Please sign in to comment.