Skip to content

Commit 3e8c8a2

Browse files
committed
Update requirement tests
1 parent dc459ed commit 3e8c8a2

File tree

2 files changed

+58
-1
lines changed

2 files changed

+58
-1
lines changed

tests/Annotation/Requirement/ClientPackerRequirementTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ public function testCheckFailsForMismatchedPacker(Packer $packer, string $requir
5757
->willUsePacker($packer)
5858
->build();
5959

60-
$errorMessage = sprintf('Client packer "%s" is required', $expectedPackerClass);
6160
$requirement = new ClientPackerRequirement($mockClient);
61+
$errorMessage = sprintf('Client packer "%s" is required', $expectedPackerClass);
6262

6363
self::assertSame($errorMessage, $requirement->check($requiredPackerName));
6464
}

tests/Annotation/Requirement/TarantoolVersionRequirementTest.php

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ public function provideCheckPassesForValidConstraintsData() : iterable
4444
$v2_3_1_3 = '2.3.1-3-g878e2a42c';
4545

4646
return [
47+
[$v2_3_1_3, '^2.3.1-2'],
48+
[$v2_3_1_3, '^2.3.0-4'],
49+
[$v2_3_1_3, '^2.3.1'],
4750
[$v2_3_1_3, '^1|^2'],
4851
[$v2_3_1_3, '^2'],
4952

@@ -82,4 +85,58 @@ public function provideCheckPassesForValidConstraintsData() : iterable
8285
[$v2_3_1_3, '< 3'],
8386
];
8487
}
88+
89+
/**
90+
* @dataProvider provideCheckFailsForInvalidConstraintsData()
91+
*/
92+
public function testCheckFailsForInvalidConstraints(string $serverVersion, string $constraints) : void
93+
{
94+
$mockClient = $this->getMockClientBuilder()
95+
->shouldHandle(
96+
new CallRequest('box.info'), // $this->logicalOr()
97+
DummyFactory::createResponseFromData([['version' => $serverVersion]]))
98+
->build();
99+
100+
$requirement = new TarantoolVersionRequirement($mockClient);
101+
$errorMessage = sprintf('Tarantool version %s is required', $constraints);
102+
103+
self::assertSame($errorMessage, $requirement->check($constraints));
104+
}
105+
106+
public function provideCheckFailsForInvalidConstraintsData() : iterable
107+
{
108+
$v2_3_1_3 = '2.3.1-3-g878e2a42c';
109+
110+
return [
111+
[$v2_3_1_3, '^2.3.1-4'],
112+
[$v2_3_1_3, '^3|^4'],
113+
[$v2_3_1_3, '^3'],
114+
115+
[$v2_3_1_3, '2.3.1-4'],
116+
[$v2_3_1_3, '2.3.2'],
117+
[$v2_3_1_3, '2.4'],
118+
[$v2_3_1_3, '3'],
119+
120+
[$v2_3_1_3, '>= 2.3.1-4'],
121+
[$v2_3_1_3, '>= 2.3.2'],
122+
[$v2_3_1_3, '>= 2.4'],
123+
[$v2_3_1_3, '>= 3'],
124+
125+
[$v2_3_1_3, '> 2.3.1-3'],
126+
[$v2_3_1_3, '> 2.3.2'],
127+
[$v2_3_1_3, '> 2.4'],
128+
[$v2_3_1_3, '> 3'],
129+
130+
[$v2_3_1_3, '<= 2.3.1-2'],
131+
[$v2_3_1_3, '<= 2.3.1'],
132+
[$v2_3_1_3, '<= 2.3.0'],
133+
[$v2_3_1_3, '<= 2.3'],
134+
[$v2_3_1_3, '<= 2'],
135+
136+
[$v2_3_1_3, '< 2.3.1-3'],
137+
[$v2_3_1_3, '< 2.3.1'],
138+
[$v2_3_1_3, '< 2.3'],
139+
[$v2_3_1_3, '< 2'],
140+
];
141+
}
85142
}

0 commit comments

Comments
 (0)