final commit on this pr: added trick in CategoryObserver to make it unit testable (unit tests not included)

This commit is contained in:
MonaHartdegen 2019-12-09 15:57:46 +01:00
parent ebcae41f3c
commit 8f010045e7
1 changed files with 6 additions and 1 deletions

View File

@ -4,6 +4,7 @@ namespace Webkul\Category\Observers;
use Illuminate\Support\Facades\Storage; use Illuminate\Support\Facades\Storage;
use Webkul\Category\Models\Category; use Webkul\Category\Models\Category;
use Carbon\Carbon;
class CategoryObserver class CategoryObserver
{ {
@ -26,7 +27,11 @@ class CategoryObserver
public function saved($category) public function saved($category)
{ {
foreach($category->children as $child) { foreach($category->children as $child) {
$child->touch(); // Hacky trick to make this method unit-testable (instead of $child->touch()
// as the unit test is too fast)
$child->setUpdatedAt(Carbon::now()->addSecond());
$child->save();
} }
} }
} }