Skip to content

Commit 39cfe5f

Browse files
authored
Merge pull request #4314 from tremani/improve-fixture-loading-with-exceptions
Improve error/exception details when loading fixtures
2 parents ee27781 + 0403c39 commit 39cfe5f

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

CHANGELOG

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ Version 1.1.23 under development
1111
- Bug: Fix CFileHelper::findFiles() to use correct directory separator under Windows (samdark)
1212
- Enh #4305: PHP 7.3 compatibility: Support giving cookies a SameSite=None attribute value (tomfotherby)
1313
- Enh #4308: PHP 7.3 compatibility: Add `samesite` as a session cookie option (tomfotherby)
14+
- Enh #4314: Exceptions thrown while loading fixtures now contain details about the error location (BBoom)
15+
- Enh #4314: Missing fixture files now throw exceptions (BBoom)
1416
- Enh #4315: Added change triggers to clickable checkbox rows in grid views, allowing other script to react to the changed checkbox states (BBoom)
1517
- Enh #4317: Added special option 'encode' to `$htmlOptions` argument in `CHtml::errorSummary` and `CHtml::error` (shidenko97)
1618
- Enh #4323: Add PostgreSQL 12 support (bio, d4rkstar, marcovtwout)

framework/test/CDbFixtureManager.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ public function loadFixture($tableName)
161161
{
162162
$fileName=$this->basePath.DIRECTORY_SEPARATOR.$tableName.'.php';
163163
if(!is_file($fileName))
164-
return false;
164+
throw new CException('Could not load fixture file ' . $fileName);
165165

166166
$rows=array();
167167
$schema=$this->getDbConnection()->getSchema();
@@ -170,7 +170,11 @@ public function loadFixture($tableName)
170170

171171
foreach(require($fileName) as $alias=>$row)
172172
{
173-
$builder->createInsertCommand($table,$row)->execute();
173+
try {
174+
$builder->createInsertCommand($table,$row)->execute();
175+
} catch (CException $e) {
176+
throw new CException('Exception loading row ' . $alias . ' in fixture ' . $fileName, $e->getCode(), $e);
177+
}
174178
$primaryKey=$table->primaryKey;
175179
if($table->sequenceName!==null)
176180
{

0 commit comments

Comments
 (0)