Skip to content

Commit 099a495

Browse files
committed
test: improve test code
1 parent 2945261 commit 099a495

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

tests/system/Database/Live/ForgeTest.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use CodeIgniter\Test\CIUnitTestCase;
1717
use CodeIgniter\Test\DatabaseTestTrait;
1818
use Config\Database;
19+
use LogicException;
1920
use RuntimeException;
2021
use stdClass;
2122
use Tests\Support\Database\Seeds\CITestSeeder;
@@ -1347,11 +1348,17 @@ private function getMetaData(string $column, string $table): stdClass
13471348
{
13481349
$fields = $this->db->getFieldData($table);
13491350

1350-
return $fields[array_search(
1351+
$name = array_search(
13511352
$column,
13521353
array_column($fields, 'name'),
13531354
true
1354-
)];
1355+
);
1356+
1357+
if ($name === false) {
1358+
throw new LogicException('Column not found: ' . $column);
1359+
}
1360+
1361+
return $fields[$name];
13551362
}
13561363

13571364
public function testConnectWithArrayGroup()

0 commit comments

Comments
 (0)