Skip to content

Commit caf151e

Browse files
committed
Merge pull request #2 from niclopez/issue-2501
Extend unit tests in testRegexFilter method
2 parents d238d34 + 8ff6e7e commit caf151e

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

tests/unit/Codeception/Util/JsonTypeTest.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,18 @@ public function testRegexFilter()
6262
$this->assertTrue($jsonType->matches(['numbers' => 'string:regex(~1-2-3~)']));
6363
$this->assertTrue($jsonType->matches(['numbers' => 'string:regex(~\d-\d-\d~)']));
6464
$this->assertNotTrue($jsonType->matches(['numbers' => 'string:regex(~^\d-\d$~)']));
65+
66+
$jsonType = new JsonType(['published' => 1]);
67+
$this->assertTrue($jsonType->matches(['published' => 'integer:regex(~1~)']));
68+
$this->assertTrue($jsonType->matches(['published' => 'integer:regex(~1|2~)']));
69+
$this->assertTrue($jsonType->matches(['published' => 'integer:regex(~2|1~)']));
70+
$this->assertNotTrue($jsonType->matches(['published' => 'integer:regex(~2~)']));
71+
$this->assertNotTrue($jsonType->matches(['published' => 'integer:regex(~2|3~)']));
72+
$this->assertNotTrue($jsonType->matches(['published' => 'integer:regex(~3|2~)']));
73+
74+
$jsonType = new JsonType(['date' => '2011-11-30T04:06:44Z']);
75+
$this->assertTrue($jsonType->matches(['date' => 'string:regex(~2011-11-30T04:06:44Z|2011-11-30T05:07:00Z~)']));
76+
$this->assertNotTrue($jsonType->matches(['date' => 'string:regex(~2015-11-30T04:06:44Z|2016-11-30T05:07:00Z~)']));
6577
}
6678

6779
public function testDateTimeFilter()
@@ -135,4 +147,4 @@ public function testNull()
135147
]));
136148

137149
}
138-
}
150+
}

0 commit comments

Comments
 (0)