1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
<?php declare(strict_types = 1);
/*
* This file is part of PharIo\Version.
*
* (c) Arne Blankerts <arne@blankerts.de>, Sebastian Heuer <sebastian@phpeople.de>, Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace PharIo\Version;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
class CompliesTest extends TestCase {
#[DataProvider('complyingProvider')]
public function testCompliesWhenExcepted(string $constraint, string $version): void {
$this->assertTrue(
(new VersionConstraintParser())->parse($constraint)->complies(new Version($version))
);
}
#[DataProvider('notComplyingProvider')]
public function testNotCompliesWhenExcepted(string $constraint, string $version): void {
$this->assertFalse(
(new VersionConstraintParser())->parse($constraint)->complies(new Version($version))
);
}
public static function complyingProvider(): array {
return [
'1.0.0' => ['1.0.0', '1.0.0'],
'~7.0.0' => ['~7.0.0', '7.0.1'],
'~7.0' => ['~7.0', '7.0.1'],
'~8.0' => ['~8.0', '8.2.3'],
'^7.0.0' => ['^7.0.0', '7.0.1'],
'^7.0' => ['^7.0', '7.0.1'],
'^8.0' => ['^8.0', '8.2.3'],
'^7.2 || ^8.0' => ['^7.2 || ^8.0', '7.4.12'],
'^7.3 || ^8.0' => ['^7.3 || ^8.0', '8.0.3'],
'^7.4 || ^8.0' => ['^7.3 || ^8.0', '8.1.3'],
'5.1.*' => ['5.1.*', '5.1.3'],
'^0.3' => ['^0.3', '0.3.1']
];
}
public static function notComplyingProvider(): array {
return [
'1.0.0' => ['1.0.0', '1.0.1'],
'~4.6' => ['~4.6', '4.5.3'],
'~8.0.0' => ['~8.0.0', '8.1.0'],
'5.1.*' => ['5.1.*', '5.2.1'],
'5.2.*' => ['5.2.*', '5.1.9'],
'^0.3' => ['^0.3', '0.4.1']
];
}
}
|