versionParser = new VersionParser(); } /** * @return array */ public function versionProvider() { return [ [ '*', new Version('', ''), ], [ '<=8.1.2', new Version('', '8.1.2'), ], [ '<=9', new Version('', '9'), ], [ '>=9.3.2', new Version('9.3.2', ''), ], [ '>=8.1.2 <=9.3.2', new Version('8.1.2', '9.3.2'), ], [ '>=8.2 <=9.1', new Version('8.2', '9.1'), ], [ '>=9 <=11', new Version('9', '11'), ], ]; } /** * @dataProvider versionProvider * * @param string $input * @param Version $expected */ public function testGetVersion($input, Version $expected): void { $this->assertEquals($expected, $this->versionParser->getVersion($input)); } public function testGetVersionException(): void { $this->expectException(\Exception::class); $this->expectExceptionMessage('Version cannot be parsed: BogusVersion'); $this->versionParser->getVersion('BogusVersion'); } public function testGetVersionExceptionWithMultiple(): void { $this->expectException(\Exception::class); $this->expectExceptionMessage('Version cannot be parsed: >=8.2 <=9.1a'); $this->versionParser->getVersion('>=8.2 <=9.1a'); } }