Skip to content

Commit 87aff5b

Browse files
aarondfrancisclaude
andcommitted
Skip $total assertions on Laravel 10
The $total parameter was added in Laravel 11, so on Laravel 10 we can't skip the COUNT query. The test now only asserts the query count and custom total on Laravel 11+. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 10bd315 commit 87aff5b

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

tests/Integration/BuilderTest.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,12 +98,16 @@ public function total_can_be_passed_to_skip_count_query()
9898
/** @var \Illuminate\Pagination\LengthAwarePaginator $results */
9999
$this->assertEquals(5, $results->count());
100100

101-
// Should only be 2 queries (inner select + outer select), no COUNT query
102-
$this->assertCount(2, $queries);
103-
104-
// The total should be the custom value we passed
105-
$this->assertEquals(100, $results->total());
106-
$this->assertTrue($results->hasMorePages());
101+
// The $total parameter was added in Laravel 11. On Laravel 10,
102+
// we can't pass it through, so the COUNT query still runs.
103+
if (version_compare(app()->version(), '11.0.0', '>=')) {
104+
// Should only be 2 queries (inner select + outer select), no COUNT query
105+
$this->assertCount(2, $queries);
106+
107+
// The total should be the custom value we passed
108+
$this->assertEquals(100, $results->total());
109+
$this->assertTrue($results->hasMorePages());
110+
}
107111
}
108112

109113
#[Test]

0 commit comments

Comments
 (0)