Skip to content

Commit 1f4bce2

Browse files
milodg
authored andcommitted
DataProvider::load() may return empty data set (BC break)
1 parent fd3bcad commit 1f4bce2

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

src/Framework/DataProvider.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,14 +44,11 @@ public static function load(string $file, string $query = ''): array
4444
}
4545

4646
foreach ($data as $key => $value) {
47-
if (!is_int($key) && !self::testQuery($key, $query)) {
47+
if (!self::testQuery((string) $key, $query)) {
4848
unset($data[$key]);
4949
}
5050
}
5151

52-
if (!$data) {
53-
throw new \Exception("No records in data-provider file '$file'" . ($query ? " for query '$query'" : '') . '.');
54-
}
5552
return $data;
5653
}
5754

tests/Framework/DataProvider.load.phpt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,9 @@ test(function () {
3131
Assert::same($expect, DataProvider::load('fixtures/dataprovider.query.ini', ' = bar'));
3232
Assert::same($expect, DataProvider::load('fixtures/dataprovider.query.php', ' = bar'));
3333
});
34+
35+
36+
test(function () {
37+
Assert::same([], DataProvider::load('fixtures/dataprovider.query.ini', 'non-existent'));
38+
Assert::same([], DataProvider::load('fixtures/dataprovider.query.php', 'non-existent'));
39+
});

0 commit comments

Comments
 (0)