Skip to content

Commit

Permalink
MySQLi - max_prepared_stmt_count: Add failing test case
Browse files Browse the repository at this point in the history
  • Loading branch information
homersimpsons committed Sep 14, 2020
1 parent 12eaeca commit 8b9f717
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions tests/TDBMDaoGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
namespace TheCodingMachine\TDBM;

use Doctrine\Common\Cache\ArrayCache;
use Doctrine\DBAL\Driver\Mysqli\MysqliConnection;
use Doctrine\DBAL\Exception\ForeignKeyConstraintViolationException;
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
use Doctrine\DBAL\Platforms\MySQL57Platform;
Expand Down Expand Up @@ -2208,4 +2209,40 @@ public function testFindFromRawSQLOnInheritance(): void
$this->assertNotNull($objects->first());
$this->assertEquals(6, $objects->count());
}

public function testMysqlStatementCount(): void
{
if (! $this->tdbmService->getConnection() instanceof MysqliConnection) {
$this->markTestSkipped('This test only applies for MySQLi driver.');
}
try {
$this->tdbmService->getConnection()->exec('set global max_prepared_stmt_count = 2;');

$objectBaseDao = new BaseObjectDao($this->tdbmService);
$objectInheritedDao = new InheritedObjectDao($this->tdbmService);

$objectBase = new BaseObjectBean('label-1');
$objectBaseDao->save($objectBase);
$objectInherited = new InheritedObjectBean($objectBase);
$objectInheritedDao->save($objectInherited);

$objectBase = new BaseObjectBean('label-2');
$objectBaseDao->save($objectBase);
$objectInherited = new InheritedObjectBean($objectBase);
$objectInheritedDao->save($objectInherited);

$objectBase = new BaseObjectBean('label-3');
$objectBaseDao->save($objectBase);
$objectInherited = new InheritedObjectBean($objectBase);
$objectInheritedDao->save($objectInherited);

$objects = $objectBaseDao->findAll();
$this->assertGreaterThanOrEqual(3, $objects->count());
foreach ($objects->take(0, 1) as $objectBean) { $objectBean->getInheritedObject()->getId(); }
foreach ($objects->take(1, 2) as $objectBean) { $objectBean->getInheritedObject()->getId(); }
foreach ($objects->take(2, 3) as $objectBean) { $objectBean->getInheritedObject()->getId(); }
} finally {
$this->tdbmService->getConnection()->exec('set global max_prepared_stmt_count = 16382;');
}
}
}

0 comments on commit 8b9f717

Please sign in to comment.