@@ -695,6 +695,44 @@ public function fieldValueNotEquals($field, $value, TraversableElement $containe
695
695
$ this ->assert (!preg_match ($ regex , $ actual ), $ message );
696
696
}
697
697
698
+ /**
699
+ * Checks that specific field matches provided regex.
700
+ *
701
+ * @param string $field field id|name|label|value
702
+ * @param string $regex pattern
703
+ * @param TraversableElement $container document to check against
704
+ *
705
+ * @throws ExpectationException
706
+ */
707
+ public function fieldValueMatches ($ field , $ regex , TraversableElement $ container = null )
708
+ {
709
+ $ node = $ this ->fieldExists ($ field , $ container );
710
+ $ actual = $ node ->getValue ();
711
+
712
+ $ message = sprintf ('The pattern "%s" was not found in the value "%s" of field "%s". ' , $ regex , $ actual , $ field );
713
+
714
+ $ this ->assert ((bool ) preg_match ($ regex , $ actual ), $ message );
715
+ }
716
+
717
+ /**
718
+ * Checks that specific field have provided value.
719
+ *
720
+ * @param string $field field id|name|label|value
721
+ * @param string $regex pattern
722
+ * @param TraversableElement $container document to check against
723
+ *
724
+ * @throws ExpectationException
725
+ */
726
+ public function fieldValueNotMatches ($ field , $ regex , TraversableElement $ container = null )
727
+ {
728
+ $ node = $ this ->fieldExists ($ field , $ container );
729
+ $ actual = $ node ->getValue ();
730
+
731
+ $ message = sprintf ('The pattern "%s" was found in the value "%s" of field "%s", but it should not. ' , $ regex , $ actual , $ field );
732
+
733
+ $ this ->assert ((bool ) preg_match ($ regex , $ actual ), $ message );
734
+ }
735
+
698
736
/**
699
737
* Checks that specific checkbox is checked.
700
738
*
0 commit comments