Skip to content

Commit e91ca18

Browse files
committed
feat: add tests for is null and not null
1 parent f65b3a6 commit e91ca18

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

tests/IteratorFilterAnydatasetTest.php

+23-4
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,15 @@ public function testMatch()
6060
'val' => 10,
6161
]
6262
),
63+
64+
$row5 = new Row(
65+
[
66+
'id' => 5,
67+
'field' => 'ab',
68+
'field2' => 'ba',
69+
'val' => null,
70+
]
71+
),
6372
];
6473

6574
$this->assertEquals($collection, $this->object->match($collection));
@@ -86,7 +95,7 @@ public function testMatch()
8695
// Test Less Than
8796
$this->object = new IteratorFilter();
8897
$this->object->and('val', Relation::LESS_THAN, 50);
89-
$this->assertEquals([$row3, $row4], $this->object->match($collection));
98+
$this->assertEquals([$row3, $row4, $row5], $this->object->match($collection));
9099

91100
// Test Greater or Equal Than
92101
$this->object = new IteratorFilter();
@@ -96,12 +105,12 @@ public function testMatch()
96105
// Test Less or Equal Than
97106
$this->object = new IteratorFilter();
98107
$this->object->and('val', Relation::LESS_OR_EQUAL_THAN, 50);
99-
$this->assertEquals([$row1, $row3, $row4], $this->object->match($collection));
108+
$this->assertEquals([$row1, $row3, $row4, $row5], $this->object->match($collection));
100109

101110
// Test Not Equal
102111
$this->object = new IteratorFilter();
103112
$this->object->and('val', Relation::NOT_EQUAL, 50);
104-
$this->assertEquals([$row2, $row3, $row4], $this->object->match($collection));
113+
$this->assertEquals([$row2, $row3, $row4, $row5], $this->object->match($collection));
105114

106115
// Test Starts With
107116
$this->object = new IteratorFilter();
@@ -121,7 +130,17 @@ public function testMatch()
121130
// Test Not In
122131
$this->object = new IteratorFilter();
123132
$this->object->and('val', Relation::NOT_IN, [10, 30, 50]);
124-
$this->assertEquals([$row2], $this->object->match($collection));
133+
$this->assertEquals([$row2, $row5], $this->object->match($collection));
134+
135+
// Test Is Null
136+
$this->object = new IteratorFilter();
137+
$this->object->and('val', Relation::IS_NULL);
138+
$this->assertEquals([$row5], $this->object->match($collection));
139+
140+
// Test Is Not Null
141+
$this->object = new IteratorFilter();
142+
$this->object->and('val', Relation::IS_NOT_NULL);
143+
$this->assertEquals([$row1, $row2, $row3, $row4], $this->object->match($collection));
125144
}
126145

127146

0 commit comments

Comments
 (0)