Skip to content

Commit 8b9f717

Browse files
committed
MySQLi - max_prepared_stmt_count: Add failing test case
1 parent 12eaeca commit 8b9f717

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

tests/TDBMDaoGeneratorTest.php

+37
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
namespace TheCodingMachine\TDBM;
2323

2424
use Doctrine\Common\Cache\ArrayCache;
25+
use Doctrine\DBAL\Driver\Mysqli\MysqliConnection;
2526
use Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException;
2627
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
2728
use Doctrine\DBAL\Platforms\MySQL57Platform;
@@ -2208,4 +2209,40 @@ public function testFindFromRawSQLOnInheritance(): void
22082209
$this->assertNotNull($objects->first());
22092210
$this->assertEquals(6, $objects->count());
22102211
}
2212+
2213+
public function testMysqlStatementCount(): void
2214+
{
2215+
if (! $this->tdbmService->getConnection() instanceof MysqliConnection) {
2216+
$this->markTestSkipped('This test only applies for MySQLi driver.');
2217+
}
2218+
try {
2219+
$this->tdbmService->getConnection()->exec('set global max_prepared_stmt_count = 2;');
2220+
2221+
$objectBaseDao = new BaseObjectDao($this->tdbmService);
2222+
$objectInheritedDao = new InheritedObjectDao($this->tdbmService);
2223+
2224+
$objectBase = new BaseObjectBean('label-1');
2225+
$objectBaseDao->save($objectBase);
2226+
$objectInherited = new InheritedObjectBean($objectBase);
2227+
$objectInheritedDao->save($objectInherited);
2228+
2229+
$objectBase = new BaseObjectBean('label-2');
2230+
$objectBaseDao->save($objectBase);
2231+
$objectInherited = new InheritedObjectBean($objectBase);
2232+
$objectInheritedDao->save($objectInherited);
2233+
2234+
$objectBase = new BaseObjectBean('label-3');
2235+
$objectBaseDao->save($objectBase);
2236+
$objectInherited = new InheritedObjectBean($objectBase);
2237+
$objectInheritedDao->save($objectInherited);
2238+
2239+
$objects = $objectBaseDao->findAll();
2240+
$this->assertGreaterThanOrEqual(3, $objects->count());
2241+
foreach ($objects->take(0, 1) as $objectBean) { $objectBean->getInheritedObject()->getId(); }
2242+
foreach ($objects->take(1, 2) as $objectBean) { $objectBean->getInheritedObject()->getId(); }
2243+
foreach ($objects->take(2, 3) as $objectBean) { $objectBean->getInheritedObject()->getId(); }
2244+
} finally {
2245+
$this->tdbmService->getConnection()->exec('set global max_prepared_stmt_count = 16382;');
2246+
}
2247+
}
22112248
}

0 commit comments

Comments
 (0)