Skip to content

Commit 09013c6

Browse files
committed
test: enhance subquery tests with additional conditions and parameters
1 parent 727ca0e commit 09013c6

1 file changed

Lines changed: 30 additions & 2 deletions

File tree

tests/Database/Functional/Driver/Common/Query/SelectQueryTest.php

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2651,10 +2651,23 @@ public function testSelectFromSubQuery(): void
26512651

26522652
$outerSelect = $this->database
26532653
->select()
2654-
->from($injection);
2654+
->from($injection)
2655+
->where('u.id', '>', 10);
26552656

26562657
$this->assertSameQuery(
2657-
'SELECT * FROM (SELECT * FROM {users} WHERE {name} = ?) AS {u}',
2658+
<<<SQL
2659+
SELECT *
2660+
FROM (SELECT * FROM {users} WHERE {name} = ?) AS {u}
2661+
WHERE {u}.{id} > ?
2662+
SQL,
2663+
$outerSelect,
2664+
);
2665+
2666+
$this->assertSameParameters(
2667+
[
2668+
'John Doe',
2669+
10,
2670+
],
26582671
$outerSelect,
26592672
);
26602673
}
@@ -2687,6 +2700,14 @@ public function testSelectFromTwoSubQuery(): void
26872700
SQL,
26882701
$outerSelect,
26892702
);
2703+
2704+
$this->assertSameParameters(
2705+
[
2706+
'John Doe',
2707+
12,
2708+
],
2709+
$outerSelect,
2710+
);
26902711
}
26912712

26922713
public function testSelectSelectSubQuery(): void
@@ -2705,5 +2726,12 @@ public function testSelectSelectSubQuery(): void
27052726
'SELECT *, (SELECT * FROM {users} WHERE {name} = ?) AS {u} FROM {apartments}',
27062727
$outerSelect,
27072728
);
2729+
2730+
$this->assertSameParameters(
2731+
[
2732+
'John Doe',
2733+
],
2734+
$outerSelect,
2735+
);
27082736
}
27092737
}

0 commit comments

Comments
 (0)