set(DataList::class, 'use_placeholders_for_integer_ids', $config); $member1 = $this->objFromFixture(TestMember::class, 'parentgroupuser'); $member2 = $this->objFromFixture(TestMember::class, 'allgroupuser'); $groups1 = $member1->Groups(); $groups2 = $member2->Groups(); $ids = $useInt ? [$member1->ID, $member2->ID] : ['Lorem', 'Ipsum']; $newGroupList = $groups1->forForeignID($ids); $sql = $newGroupList->dataQuery()->sql(); preg_match('#ID" IN \(([^\)]+)\)\)#', $sql, $matches); $usesPlaceholders = ($matches[1] ?? '') === '?, ?, ?, ?, ?' || str_contains($sql, '"Group"."ID" = ?'); $this->assertSame($expected, $usesPlaceholders); $expectedIDs = $useInt ? array_unique(array_merge($groups1->column('ID'), $groups2->column('ID'))) : []; $this->assertEqualsCanonicalizing($expectedIDs, $newGroupList->column('ID')); } public function provideForForeignIDPlaceholders(): array { return [ 'config false' => [ 'config' => false, 'useInt' => true, 'expected' => false, ], 'config false non-int' => [ 'config' => false, 'useInt' => false, 'expected' => true, ], 'config true' => [ 'config' => true, 'useInt' => true, 'expected' => true, ], 'config true non-int' => [ 'config' => true, 'useInt' => false, 'expected' => true, ], ]; } }