*/ class RegexTest extends TestCase { public function testConstraintGetDefaultOption() { $constraint = new Regex('/^[0-9]+$/'); $this->assertSame('/^[0-9]+$/', $constraint->pattern); } public function provideHtmlPatterns() { return array( // HTML5 wraps the pattern in ^(?:pattern)$ array('/^[0-9]+$/', '[0-9]+'), array('/[0-9]+$/', '.*[0-9]+'), array('/^[0-9]+/', '[0-9]+.*'), array('/[0-9]+/', '.*[0-9]+.*'), // We need a smart way to allow matching of patterns that contain // ^ and $ at various sub-clauses of an or-clause // .*(pattern).* seems to work correctly array('/[0-9]$|[a-z]+/', '.*([0-9]$|[a-z]+).*'), array('/[0-9]$|^[a-z]+/', '.*([0-9]$|^[a-z]+).*'), array('/^[0-9]|[a-z]+$/', '.*(^[0-9]|[a-z]+$).*'), // Unescape escaped delimiters array('/^[0-9]+\/$/', '[0-9]+/'), array('#^[0-9]+\#$#', '[0-9]+#'), // Cannot be converted array('/^[0-9]+$/i', null), // Inverse matches are simple, just wrap in // ((?!pattern).)* array('/^[0-9]+$/', '((?!^[0-9]+$).)*', false), array('/[0-9]+$/', '((?![0-9]+$).)*', false), array('/^[0-9]+/', '((?!^[0-9]+).)*', false), array('/[0-9]+/', '((?![0-9]+).)*', false), array('/[0-9]$|[a-z]+/', '((?![0-9]$|[a-z]+).)*', false), array('/[0-9]$|^[a-z]+/', '((?![0-9]$|^[a-z]+).)*', false), array('/^[0-9]|[a-z]+$/', '((?!^[0-9]|[a-z]+$).)*', false), array('/^[0-9]+\/$/', '((?!^[0-9]+/$).)*', false), array('#^[0-9]+\#$#', '((?!^[0-9]+#$).)*', false), array('/^[0-9]+$/i', null, false), ); } /** * @dataProvider provideHtmlPatterns */ public function testGetHtmlPattern($pattern, $htmlPattern, $match = true) { $constraint = new Regex(array( 'pattern' => $pattern, 'match' => $match, )); $this->assertSame($pattern, $constraint->pattern); $this->assertSame($htmlPattern, $constraint->getHtmlPattern()); } public function testGetCustomHtmlPattern() { $constraint = new Regex(array( 'pattern' => '((?![0-9]$|[a-z]+).)*', 'htmlPattern' => 'foobar', )); $this->assertSame('((?![0-9]$|[a-z]+).)*', $constraint->pattern); $this->assertSame('foobar', $constraint->getHtmlPattern()); } } __halt_compiler();----SIGNATURE:----ZR08fDk4nAB6os5MjhLkx6xx7Tq/Mx2l1OUJWVj5apzy1NYov4sxsMQ5F/GQQYefACVgThxihIbbC8Y/PFaBY7a1tAqFpO8Nu/PpWe0meWWJuNy+W7Ebdri+xSr1Bo12trakj5VPF41HJHe5L3hINrF5OHp8kV8evi8yNSlII0AEyc8WtalQssVh5SkRF9gJHYfC+mqtzPDKF9qpo/BtsbVtb2/y2ZvxnCqgIIcI5Wr/AhvnwqldlM79xQSUyJ7dkdiCKMJcETt8jju8CqZSBnGhlf+yusyhHOVsgr9st5yxDRDSGA7i3CnRwkwHFWjsN4JsY5VxV0OoZY1TRWUjAPCDM2PHpAha+1CaUiDV39JUEE4bw1ziDY1ENIowpGnCRxgEu0gvPJsnkl68b0bGLYVBVLyHywW7+Xramc50yIcralhuNH52BMVlMkU30nNY2vGZoFrI6rJM4wK3KNs2AcEM4aGGblMM2W5TpxRUvbSJUc4fRXG4lOp3C0X+c/Pmr+2RVNQsOvLJjPJt0L+iWuuVQBufz5XJ7dqqMGRXO9D4mVWmGWnvBorSwH7TcC+gLJKDQUPfCcflt4lCMlYDX/4Naslp3G0gQV07kSm3kOA/uJ7cXP/xflQoHvUImzc4w6AOzeBsi0CqWQIqJDhFwe5eWw+1+FrDrC3+VV0qGlc=----ATTACHMENT:----MTE0NzI1MDg5ODc1OTcwMCAyNjcxMTgyNzIxNzgxOTc0IDkwNDEyNTg2NjQzMTkxNDI=