Skip to content

Commit 01b0148

Browse files
authored
Add data consistency test (#49)
1 parent f35d519 commit 01b0148

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

tests/SearchTest.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,4 +627,31 @@ public function it_supports_full_text_search()
627627
$this->assertTrue($results->contains($blogA));
628628
$this->assertTrue($results->contains($pageA));
629629
}
630+
631+
/** @test */
632+
public function it_returns_data_consistently() {
633+
Carbon::setTestNow(now());
634+
$postA = Post::create(['title' => 'Laravel Framework']);
635+
636+
Carbon::setTestNow(now()->addSecond());
637+
$postB = Post::create(['title' => 'Tailwind Framework']);
638+
639+
$this->assertEquals(2, Post::all()->count());
640+
$this->assertEquals(0, Blog::all()->count());
641+
642+
$resultA = Search::addMany([
643+
[Post::query(), 'title'],
644+
])->get('');
645+
646+
$resultB = Search::addMany([
647+
[Post::query(), 'title'],
648+
[Blog::query(), 'title'],
649+
])->get('');
650+
651+
$this->assertCount(2, $resultA);
652+
$this->assertCount(2, $resultB);
653+
654+
$this->assertTrue($resultA->first()->is($postA));
655+
$this->assertTrue($resultB->first()->is($postA));
656+
}
630657
}

0 commit comments

Comments
 (0)