Skip to content

Commit ab435aa

Browse files
committed
Optimize insertFixture in database test trait
1 parent 0e6e183 commit ab435aa

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed

src/Traits/DatabaseTestTrait.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
use DomainException;
66
use PDO;
7-
use PDOException;
87
use PDOStatement;
98
use UnexpectedValueException;
109

@@ -252,14 +251,9 @@ function (&$value) {
252251
$statement = $this->createPreparedStatement(sprintf('INSERT INTO `%s` SET %s', $table, implode(',', $fields)));
253252
$statement->execute($row);
254253

255-
try {
256-
$lastInsertId = $this->getConnection()->lastInsertId();
254+
$lastInsertId = $this->getConnection()->lastInsertId();
257255

258-
return !empty($lastInsertId) && is_numeric($lastInsertId) ? (int)$lastInsertId : null;
259-
} catch (PDOException $PDOException) {
260-
// If the PDO driver does not support this capability
261-
return null;
262-
}
256+
return $lastInsertId !== false ? (int)$lastInsertId : null;
263257
}
264258

265259
/**

0 commit comments

Comments
 (0)