Skip to content

Commit 067bdd5

Browse files
committed
Fix tests to use relationship to create record
1 parent 1e477a1 commit 067bdd5

File tree

4 files changed

+12
-16
lines changed

4 files changed

+12
-16
lines changed

src/CacheKey.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public function make(
3939
$key .= $this->getOffsetClause();
4040
$key .= $this->getLimitClause();
4141
$key .= $keyDifferentiator;
42-
dump("key", $key);
42+
4343
return $key;
4444
}
4545

src/Traits/ModelCaching.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,10 @@ public static function bootCachable()
3737
$instance->checkCooldownAndFlushAfterPersiting($instance);
3838
});
3939

40-
static::restored(function ($instance) {
41-
$instance->checkCooldownAndFlushAfterPersiting($instance);
42-
});
40+
// TODO: figure out how to add this listener
41+
// static::restored(function ($instance) {
42+
// $instance->checkCooldownAndFlushAfterPersiting($instance);
43+
// });
4344

4445
static::pivotAttached(function ($instance) {
4546
$instance->checkCooldownAndFlushAfterPersiting($instance);

tests/Integration/CachedBuilder/WithCountTest.php

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,16 @@ public function testWithCountUpdatesAfterRecordIsAdded()
4242
$this->assertEquals($author1->books_count + 1, $author2->books_count);
4343
}
4444

45-
/** @group test */
4645
public function testWithCountOnMorphManyRelationshipUpdatesAfterRecordIsAdded()
4746
{
4847
$book1 = (new Book)
4948
->withCount("comments")
5049
->first();
51-
dump("start");
52-
factory(Comment::class, 1)
53-
->make()
54-
->each(function ($comment) use ($book1) {
55-
$comment->commentable_id = $book1->id;
56-
$comment->commentable_type = $book1->getTable();
57-
$comment->save();
58-
});
59-
dump("end");
50+
$comment = factory(Comment::class, 1)
51+
->create()
52+
->first();
53+
54+
$book1->comments()->save($comment);
6055

6156
$book2 = (new Book)
6257
->withCount("comments")

tests/database/migrations/2018_06_03_202000_create_comments.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ public function up()
1111
$table->increments('id');
1212
$table->timestamps();
1313

14-
$table->unsignedInteger("commentable_id");
15-
$table->string("commentable_type");
14+
$table->unsignedInteger("commentable_id")->nullable();
15+
$table->string("commentable_type")->nullable();
1616
$table->text("description");
1717
$table->string("subject");
1818
});

0 commit comments

Comments
 (0)