public function testEmptyFieldsAreSkipped() { $mockEmpty = $this->getMock('HTML_QuickForm2_Element', array('getType', 'getValue', 'setValue', '__toString')); $mockEmpty->expects($this->once())->method('getValue')->will($this->returnValue('')); $ruleSimple = new HTML_QuickForm2_Rule_Regex($mockEmpty, 'an error', '/^[a-zA-Z]+$/'); $this->assertTrue($ruleSimple->validate()); $mockNoUpload = $this->getMock('HTML_QuickForm2_Element_InputFile', array('getValue')); $mockNoUpload->expects($this->once())->method('getValue')->will($this->returnValue(array('name' => '', 'type' => '', 'tmp_name' => '', 'error' => UPLOAD_ERR_NO_FILE, 'size' => 0))); $ruleFile = new HTML_QuickForm2_Rule_Regex($mockNoUpload, 'an error', '/\\.(jpe?g|gif|png)$/i'); $this->assertTrue($ruleFile->validate()); }
public function testRequest12736() { $mockEl = $this->getMock('HTML_QuickForm2_Element', array('getType', 'getRawValue', 'setValue', '__toString')); $mockEl->expects($this->once())->method('getRawValue')->will($this->returnValue('no Cyrillic letters here')); $ruleCyr = new HTML_QuickForm2_Rule_Regex($mockEl, 'an error', '/\\x{0445}\\x{0443}\\x{0439}/ui'); $this->assertFalse($ruleCyr->validate()); $this->assertContains('/\\u0445\\u0443\\u0439/i.test(', $ruleCyr->getJavascript()); }