Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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\Driver as MySQLiDriver;
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()->getDriver() instanceof MySQLiDriver) {
$this->markTestSkipped('This test only applies for MySQLi driver.');
}

$this->tdbmService->getConnection()->exec('set global max_prepared_stmt_count = 2;');
try {
$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;');
}
}
}