Fix: Scope should have its own where clause
continuous-integration/drone/push Build is failing
Details
continuous-integration/drone/push Build is failing
Details
This commit is contained in:
parent
e37219b1ca
commit
9b2364bc34
|
@ -48,36 +48,36 @@ class FilterScope extends Filter
|
|||
*/
|
||||
public function apply(Builder $query): Builder
|
||||
{
|
||||
$query->orWhere(function ($query) {
|
||||
if ($this->ausstand) {
|
||||
$query->whereAusstand();
|
||||
}
|
||||
return $query->where(function ($query) {
|
||||
$query->orWhere(function ($query) {
|
||||
if ($this->ausstand) {
|
||||
$query->whereAusstand();
|
||||
}
|
||||
|
||||
if ($this->billKind) {
|
||||
$query->where('bill_kind', BillKind::fromValue($this->billKind));
|
||||
}
|
||||
if ($this->billKind) {
|
||||
$query->where('bill_kind', BillKind::fromValue($this->billKind));
|
||||
}
|
||||
|
||||
if (count($this->groupIds)) {
|
||||
$query->whereIn('group_id', $this->groupIds);
|
||||
}
|
||||
if (count($this->groupIds)) {
|
||||
$query->whereIn('group_id', $this->groupIds);
|
||||
}
|
||||
|
||||
if (count($this->subactivityIds) + count($this->activityIds) > 0) {
|
||||
$query->whereHas('memberships', function ($q) {
|
||||
$q->active();
|
||||
if (count($this->subactivityIds)) {
|
||||
$q->whereIn('subactivity_id', $this->subactivityIds);
|
||||
}
|
||||
if (count($this->activityIds)) {
|
||||
$q->whereIn('activity_id', $this->activityIds);
|
||||
}
|
||||
});
|
||||
}
|
||||
})->orWhere(function ($query) {
|
||||
if (count($this->additional)) {
|
||||
$query->whereIn('id', $this->additional);
|
||||
}
|
||||
if (count($this->subactivityIds) + count($this->activityIds) > 0) {
|
||||
$query->whereHas('memberships', function ($q) {
|
||||
$q->active();
|
||||
if (count($this->subactivityIds)) {
|
||||
$q->whereIn('subactivity_id', $this->subactivityIds);
|
||||
}
|
||||
if (count($this->activityIds)) {
|
||||
$q->whereIn('activity_id', $this->activityIds);
|
||||
}
|
||||
});
|
||||
}
|
||||
})->orWhere(function ($query) {
|
||||
if (count($this->additional)) {
|
||||
$query->whereIn('id', $this->additional);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return $query;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,9 @@
|
|||
<testsuite name="NamiUnit">
|
||||
<directory suffix="Test.php">./packages/laravel-nami/tests/Unit</directory>
|
||||
</testsuite>
|
||||
<testsuite name="EndToEnd">
|
||||
<directory suffix="Test.php">./tests/EndToEnd</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<filter>
|
||||
<whitelist processUncoveredFilesFromWhitelist="true">
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
namespace Tests\EndToEnd;
|
||||
|
||||
use App\Group;
|
||||
use App\Member\Member;
|
||||
use App\Payment\Payment;
|
||||
use Illuminate\Foundation\Testing\DatabaseMigrations;
|
||||
use Tests\RequestFactories\Child;
|
||||
use Tests\TestCase;
|
||||
|
||||
class MemberIndexTest extends TestCase
|
||||
{
|
||||
use DatabaseMigrations;
|
||||
|
||||
public function testItHandlesFullTextSearch(): void
|
||||
{
|
||||
$this->withoutExceptionHandling()->login()->loginNami();
|
||||
$group = Group::factory()->create();
|
||||
Member::factory()->defaults()->for($group)->create(['firstname' => '::firstname::']);
|
||||
Member::factory()->defaults()->for($group)->create(['firstname' => '::gggname::']);
|
||||
|
||||
$response = $this->callFilter('member.index', ['search' => '::firstname::']);
|
||||
|
||||
$this->assertCount(1, $this->inertia($response, 'data.data'));
|
||||
}
|
||||
|
||||
public function testItFiltersForSearchButNotForPayments(): void
|
||||
{
|
||||
$this->withoutExceptionHandling()->login()->loginNami();
|
||||
$group = Group::factory()->create();
|
||||
Member::factory()->defaults()->for($group)
|
||||
->has(Payment::factory()->notPaid()->subscription('tollerbeitrag', [
|
||||
new Child('a', 5400),
|
||||
]))
|
||||
->create(['firstname' => '::firstname::']);
|
||||
Member::factory()->defaults()->for($group)->create(['firstname' => '::firstname::']);
|
||||
|
||||
$response = $this->callFilter('member.index', ['search' => '::firstname::', 'ausstand' => true]);
|
||||
|
||||
$this->assertCount(1, $this->inertia($response, 'data.data'));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue