'bar'], iterator_to_array($source)); self::assertSame($filename, $source->sourceName()); } public function file_is_handled_properly_data_provider(): iterable { yield [$this->file('test-json.json', '{"foo": "bar"}')]; yield [$this->file('test-json.JSON', '{"foo": "bar"}')]; if (function_exists('yaml_parse')) { yield [$this->file('test-yaml.yaml', 'foo: bar')]; yield [$this->file('test-yaml.YAML', 'foo: bar')]; yield [$this->file('test-yml.yml', 'foo: bar')]; yield [$this->file('test-yml.YML', 'foo: bar')]; } } public function test_unhandled_extension_throws_exception(): void { $this->expectException(FileExtensionNotHandled::class); $this->expectExceptionCode(1629991744); $this->expectExceptionMessage('The file extension `foo` is not handled.'); $filename = $this->file('some-unhandled-extension.foo', 'foo'); new FileSource(new SplFileObject($filename)); } private function file(string $name, string $data): string { $filename = sys_get_temp_dir() . DIRECTORY_SEPARATOR . uniqid('', true) . $name; file_put_contents($filename, $data); return $filename; } }