|
2 | 2 |
|
3 | 3 | namespace Tests\AnyDataset\Dataset; |
4 | 4 |
|
| 5 | +use ByJG\AnyDataset\Core\Enum\Relation; |
5 | 6 | use ByJG\AnyDataset\Core\IteratorFilter; |
6 | | -use ByJG\AnyDataset\Core\IteratorFilterXPathFormatter; |
7 | 7 | use ByJG\AnyDataset\Core\Row; |
8 | | -use ByJG\AnyDataset\Core\Enum\Relation; |
9 | 8 | use PHPUnit\Framework\TestCase; |
10 | 9 |
|
11 | 10 | class IteratorFilterAnydatasetTest extends TestCase |
@@ -65,63 +64,63 @@ public function testMatch() |
65 | 64 |
|
66 | 65 | $this->assertEquals($collection, $this->object->match($collection)); |
67 | 66 |
|
68 | | - $this->object->addRelation('field2', Relation::EQUAL, 'other2'); |
| 67 | + $this->object->and('field2', Relation::EQUAL, 'other2'); |
69 | 68 | $this->assertEquals([$row2], $this->object->match($collection)); |
70 | 69 |
|
71 | | - $this->object->addRelationOr('field', Relation::EQUAL, 'last1'); |
| 70 | + $this->object->or('field', Relation::EQUAL, 'last1'); |
72 | 71 | $this->assertEquals([$row2, $row3], $this->object->match($collection)); |
73 | 72 |
|
74 | 73 |
|
75 | 74 | //------------------------ |
76 | 75 |
|
77 | 76 | $this->object = new IteratorFilter(); |
78 | | - $this->object->addRelation('field', Relation::EQUAL, 'last1'); |
79 | | - $this->object->addRelation('field2', Relation::EQUAL, 'last2'); |
| 77 | + $this->object->and('field', Relation::EQUAL, 'last1'); |
| 78 | + $this->object->and('field2', Relation::EQUAL, 'last2'); |
80 | 79 | $this->assertEquals([$row3], $this->object->match($collection)); |
81 | 80 |
|
82 | 81 | // Test Greater Than |
83 | 82 | $this->object = new IteratorFilter(); |
84 | | - $this->object->addRelation('val', Relation::GREATER_THAN, 50); |
| 83 | + $this->object->and('val', Relation::GREATER_THAN, 50); |
85 | 84 | $this->assertEquals([$row2], $this->object->match($collection)); |
86 | 85 |
|
87 | 86 | // Test Less Than |
88 | 87 | $this->object = new IteratorFilter(); |
89 | | - $this->object->addRelation('val', Relation::LESS_THAN, 50); |
| 88 | + $this->object->and('val', Relation::LESS_THAN, 50); |
90 | 89 | $this->assertEquals([$row3, $row4], $this->object->match($collection)); |
91 | 90 |
|
92 | 91 | // Test Greater or Equal Than |
93 | 92 | $this->object = new IteratorFilter(); |
94 | | - $this->object->addRelation('val', Relation::GREATER_OR_EQUAL_THAN, 50); |
| 93 | + $this->object->and('val', Relation::GREATER_OR_EQUAL_THAN, 50); |
95 | 94 | $this->assertEquals([$row1, $row2], $this->object->match($collection)); |
96 | 95 |
|
97 | 96 | // Test Less or Equal Than |
98 | 97 | $this->object = new IteratorFilter(); |
99 | | - $this->object->addRelation('val', Relation::LESS_OR_EQUAL_THAN, 50); |
| 98 | + $this->object->and('val', Relation::LESS_OR_EQUAL_THAN, 50); |
100 | 99 | $this->assertEquals([$row1, $row3, $row4], $this->object->match($collection)); |
101 | 100 |
|
102 | 101 | // Test Not Equal |
103 | 102 | $this->object = new IteratorFilter(); |
104 | | - $this->object->addRelation('val', Relation::NOT_EQUAL, 50); |
| 103 | + $this->object->and('val', Relation::NOT_EQUAL, 50); |
105 | 104 | $this->assertEquals([$row2, $row3, $row4], $this->object->match($collection)); |
106 | 105 |
|
107 | 106 | // Test Starts With |
108 | 107 | $this->object = new IteratorFilter(); |
109 | | - $this->object->addRelation('field', Relation::STARTS_WITH, 'la'); |
| 108 | + $this->object->and('field', Relation::STARTS_WITH, 'la'); |
110 | 109 | $this->assertEquals([$row3], $this->object->match($collection)); |
111 | 110 |
|
112 | 111 | // Test Contains |
113 | 112 | $this->object = new IteratorFilter(); |
114 | | - $this->object->addRelation('field', Relation::CONTAINS, '1'); |
| 113 | + $this->object->and('field', Relation::CONTAINS, '1'); |
115 | 114 | $this->assertEquals([$row1, $row2, $row3], $this->object->match($collection)); |
116 | 115 |
|
117 | 116 | // Test In |
118 | 117 | $this->object = new IteratorFilter(); |
119 | | - $this->object->addRelation('val', Relation::IN, [10, 30, 50]); |
| 118 | + $this->object->and('val', Relation::IN, [10, 30, 50]); |
120 | 119 | $this->assertEquals([$row1, $row3, $row4], $this->object->match($collection)); |
121 | 120 |
|
122 | 121 | // Test Not In |
123 | 122 | $this->object = new IteratorFilter(); |
124 | | - $this->object->addRelation('val', Relation::NOT_IN, [10, 30, 50]); |
| 123 | + $this->object->and('val', Relation::NOT_IN, [10, 30, 50]); |
125 | 124 | $this->assertEquals([$row2], $this->object->match($collection)); |
126 | 125 | } |
127 | 126 |
|
|
0 commit comments