Skip to content

Commit af4f349

Browse files
committed
OXDEV-9583: Make tests green again
1 parent ab118d0 commit af4f349

7 files changed

Lines changed: 27 additions & 17 deletions

File tree

src/DataType/Filter/BoolFilter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public function equals(): bool
3131

3232
public function matches(mixed $value): bool
3333
{
34-
return (is_bool($value) || $value === $this->equals);
34+
return (is_bool($value) && $value === $this->equals);
3535
}
3636

3737
public function addToQuery(QueryBuilder $builder, string $field): void

src/DataType/Filter/DateFilter.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,9 @@ function ($date) use ($zone) {
115115
$between
116116
);
117117
}
118+
119+
public function matches(mixed $value): bool
120+
{
121+
// TODO: Implement matches() method.
122+
}
118123
}

src/DataType/Filter/FloatFilter.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,4 +72,9 @@ public static function fromUserInput(
7272
$between
7373
);
7474
}
75+
76+
public function matches(mixed $value): bool
77+
{
78+
// TODO: Implement matches() method.
79+
}
7580
}

src/DataType/Filter/IntegerFilter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ public function matches(mixed $value): bool
6969
return false;
7070
}
7171

72-
if ($this->between !== null && ($value <= $this->between[0] || $value >= $this->between[1])) {
72+
if ($this->between !== null && !($value >= $this->between[0] && $value <= $this->between[1])) {
7373
return false;
7474
}
7575

tests/Unit/DataType/Filter/IDFilterTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -80,10 +80,10 @@ public function testAddQueryPartWithAlias(): void
8080
}
8181

8282
/** @dataProvider matchesDataProvider */
83-
public function testMatches(mixed $value, IDFilter $filter, bool $expected): void
83+
public function testMatches(mixed $value, IDFilter $filter, bool $result): void
8484
{
8585
$this->assertSame(
86-
$expected,
86+
$result,
8787
$filter->matches($value)
8888
);
8989
}
@@ -92,31 +92,31 @@ public static function matchesDataProvider(): \Generator
9292
{
9393
yield "test string is matching" => [
9494
'value' => '1abc',
95-
'initFilter' => new IDFilter(equals: new ID('1abc')),
95+
'filter' => new IDFilter(equals: new ID('1abc')),
9696
'result' => true,
9797
];
9898

9999
yield "test id class is matching" => [
100100
'value' => new ID('id_text'),
101-
'initFilter' => new IDFilter(equals: new ID('id_text')),
101+
'filter' => new IDFilter(equals: new ID('id_text')),
102102
'result' => true,
103103
];
104104

105105
yield "test no string or no ID-class is not matching" => [
106106
'value' => 123,
107-
'initFilter' => new IDFilter(equals: new ID('123')),
107+
'filter' => new IDFilter(equals: new ID('123')),
108108
'result' => false,
109109
];
110110

111111
yield "test wrong string is not matching" => [
112112
'value' => 'wrong1abc',
113-
'initFilter' => new IDFilter(equals: new ID('1abc')),
113+
'filter' => new IDFilter(equals: new ID('1abc')),
114114
'result' => false,
115115
];
116116

117117
yield "test wrong ID-class is not matching" => [
118118
'value' => new ID('wrong_id_text'),
119-
'initFilter' => new IDFilter(equals: new ID('id_text')),
119+
'filter' => new IDFilter(equals: new ID('id_text')),
120120
'result' => false,
121121
];
122122
}

tests/Unit/DataType/Filter/IntegerFilterTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -209,37 +209,37 @@ public static function matchesDataProvider(): \Generator
209209
'initFilter' => new IntegerFilter(equals: 1)
210210
];
211211

212-
yield "test match contains" => [
212+
yield "test match less than" => [
213213
'stringForTrueCase' => 1,
214214
'stringForFalseCase' => 5,
215215
'initFilter' => new IntegerFilter(lessThan: 3)
216216
];
217217

218-
yield "test match begins with" => [
218+
yield "test match greater than" => [
219219
'stringForTrueCase' => 6,
220220
'stringForFalseCase' => 2,
221221
'initFilter' => new IntegerFilter(greaterThan: 4)
222222
];
223223

224-
yield "test match begins with and contains" => [
224+
yield "test match between" => [
225225
'stringForTrueCase' => 5,
226226
'stringForFalseCase' => 2,
227227
'initFilter' => new IntegerFilter(between: [3, 5])
228228
];
229229

230-
yield "test match equals and contains" => [
230+
yield "test match less and greater than" => [
231231
'stringForTrueCase' => 7,
232232
'stringForFalseCase' => 3,
233233
'initFilter' => new IntegerFilter(lessThan: 10, greaterThan: 4)
234234
];
235235

236-
yield "test is and is not integer" => [
236+
yield "test not matches with float" => [
237237
'stringForTrueCase' => 2,
238238
'stringForFalseCase' => 2.1,
239239
'initFilter' => new IntegerFilter(equals: 2)
240240
];
241241

242-
yield "test is and is not integer with string" => [
242+
yield "test not matches with string" => [
243243
'stringForTrueCase' => 3,
244244
'stringForFalseCase' => '3',
245245
'initFilter' => new IntegerFilter(equals: 3)

tests/Unit/DataType/Filter/StringFilterTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ public static function matchesDataProvider(): \Generator
178178
yield "test match begins with and contains" => [
179179
'stringForTrueCase' => 'this start with abc',
180180
'stringForFalseCase' => 'this does not start with abc',
181-
'initFilter' => new StringFilter(beginsWith: 'THIS start', contains: 'abc')
181+
'initFilter' => new StringFilter(contains: 'abc', beginsWith: 'THIS start')
182182
];
183183

184184
yield "test match equals and contains" => [
@@ -188,7 +188,7 @@ public static function matchesDataProvider(): \Generator
188188
];
189189

190190
yield "test is and is not string" => [
191-
'stringForTrueCase' => 'This is abc',
191+
'stringForTrueCase' => '23',
192192
'stringForFalseCase' => 23,
193193
'initFilter' => new StringFilter(equals: '23')
194194
];

0 commit comments

Comments
 (0)