Skip to content

Commit

Permalink
DataProvider: parses INI files using INI_SCANNER_TYPED mode (BC break)
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed Sep 4, 2024
1 parent 8b22550 commit 08387d5
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/Framework/DataProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public static function load(string $file, string $query = ''): array
throw new \Exception("Data provider '$file' did not return array or Traversable.");
}
} else {
$data = @parse_ini_file($file, process_sections: true); // @ is escalated to exception
$data = @parse_ini_file($file, true, INI_SCANNER_TYPED); // @ is escalated to exception
if ($data === false) {
throw new \Exception("Cannot parse data provider file '$file'.");
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Framework/DataProvider.load.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ test('', function () {

test('', function () {
$expect = [
'bar 1.2.3' => ['a' => '1'],
'bar' => ['b' => '2'],
'bar 1.2.3' => ['a' => 1],
'bar' => ['b' => 2],
];

Assert::same($expect, DataProvider::load('fixtures/dataprovider.query.ini', ' = bar'));
Expand Down
4 changes: 2 additions & 2 deletions tests/Framework/TestCase.dataProvider.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,8 @@ Assert::same([
$test = new MyTest;
$test->runTest('testFileDataProvider');
Assert::same([
['MyTest::testFileDataProvider', ['1', 'b']],
['MyTest::testFileDataProvider', ['a', '2']],
['MyTest::testFileDataProvider', [1, 'b']],
['MyTest::testFileDataProvider', ['a', 2]],
], $test->order);


Expand Down
4 changes: 2 additions & 2 deletions tests/Framework/fixtures/dataprovider.query.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
'foo 1.2.3 yyy' => [],
'foo 2.2.3' => [],
'foo 3 xxx' => [],
'bar 1.2.3' => ['a' => '1'],
'bar' => ['b' => '2'],
'bar 1.2.3' => ['a' => 1],
'bar' => ['b' => 2],
];

0 comments on commit 08387d5

Please sign in to comment.