Improve tests

This commit is contained in:
Daniil Gentili 2024-04-06 19:45:35 +02:00
parent be9b7e1039
commit b6bacba615
3 changed files with 10 additions and 1 deletions

View File

@ -101,7 +101,6 @@ final class MysqlArray extends SqlArray
if (!\extension_loaded('pdo_mysql')) {
throw new AssertionError("PDO is needed for the mysql backend!");
}
// @codeCoverageIgnoreEnd
$pdo = new PDO(
$host[0] === '/'
@ -110,6 +109,7 @@ final class MysqlArray extends SqlArray
$settings->config->getUser(),
$settings->config->getPassword(),
);
// @codeCoverageIgnoreEnd
self::$connections[$dbKey] = [
new MysqlConnectionPool($settings->config, $settings->maxConnections, $settings->idleTimeout),

View File

@ -163,8 +163,10 @@ final class RedisArray extends DriverArray
foreach ($request as $key) {
$keys[] = $key;
if (\count($keys) === 10) {
// @codeCoverageIgnoreStart
$this->db->delete(...$keys);
$keys = [];
// @codeCoverageIgnoreEnd
}
}
if ($keys) {

View File

@ -50,6 +50,7 @@ use danog\AsyncOrm\ValueType;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use ReflectionProperty;
use Revolt\EventLoop;
use WeakReference;
use function Amp\async;
@ -561,6 +562,12 @@ final class OrmTest extends TestCase
$f2 = async($orm->get(...), $key);
$this->assertSame($value, $f1->await());
$this->assertSame($value, $f2->await());
$orm[$key] = PHP_INT_MAX;
$this->assertSame(PHP_INT_MAX, $orm[$key]);
EventLoop::queue($orm->set(...), $key, $value);
$c->flushCache();
$this->assertSame($value, $orm[$key]);
}
$orm->clear();