Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MySQLi - max_prepared_stmt_count: Add failing test case #228

Draft
wants to merge 1 commit into
base: 5.1
Choose a base branch
from
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;');
}
}
}