From 08387d5a80b674726ed774559e42c538dcfa4f4d Mon Sep 17 00:00:00 2001 From: David Grudl Date: Wed, 4 Sep 2024 06:19:16 +0200 Subject: [PATCH] DataProvider: parses INI files using INI_SCANNER_TYPED mode (BC break) --- src/Framework/DataProvider.php | 2 +- tests/Framework/DataProvider.load.phpt | 4 ++-- tests/Framework/TestCase.dataProvider.phpt | 4 ++-- tests/Framework/fixtures/dataprovider.query.php | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Framework/DataProvider.php b/src/Framework/DataProvider.php index f413c071..ac59b330 100644 --- a/src/Framework/DataProvider.php +++ b/src/Framework/DataProvider.php @@ -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'."); } diff --git a/tests/Framework/DataProvider.load.phpt b/tests/Framework/DataProvider.load.phpt index bfc6dbec..c676d692 100644 --- a/tests/Framework/DataProvider.load.phpt +++ b/tests/Framework/DataProvider.load.phpt @@ -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')); diff --git a/tests/Framework/TestCase.dataProvider.phpt b/tests/Framework/TestCase.dataProvider.phpt index 8bb60512..f20b5949 100644 --- a/tests/Framework/TestCase.dataProvider.phpt +++ b/tests/Framework/TestCase.dataProvider.phpt @@ -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); diff --git a/tests/Framework/fixtures/dataprovider.query.php b/tests/Framework/fixtures/dataprovider.query.php index 3c76d88a..1365b4db 100644 --- a/tests/Framework/fixtures/dataprovider.query.php +++ b/tests/Framework/fixtures/dataprovider.query.php @@ -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], ];