示例#1
0
 /**
  * Ensures that the validator follows expected behavior
  *
  * @return void
  */
 public function testBasic()
 {
     $valuesExpected = array(array(15, true), array(4, false), array(array('min' => 0, 'max' => 10), true), array(array('min' => 10, 'max' => 15), false));
     foreach ($valuesExpected as $element) {
         $validator = new File\WordCount($element[0]);
         $this->assertEquals($element[1], $validator->isValid(dirname(__FILE__) . '/_files/wordcount.txt'), "Tested with " . var_export($element, 1));
     }
 }
示例#2
0
 public function testEmptyFileShouldReturnFalseAndDisplayNotFoundMessage()
 {
     $validator = new File\WordCount();
     $this->assertFalse($validator->isValid(''));
     $this->assertArrayHasKey(File\WordCount::NOT_FOUND, $validator->getMessages());
     $filesArray = array('name' => '', 'size' => 0, 'tmp_name' => '', 'error' => UPLOAD_ERR_NO_FILE, 'type' => '');
     $this->assertFalse($validator->isValid($filesArray));
     $this->assertArrayHasKey(File\WordCount::NOT_FOUND, $validator->getMessages());
 }
示例#3
0
 /**
  * @group ZF-11258
  */
 public function testZF11258()
 {
     $validator = new File\WordCount(array('min' => 1, 'max' => 10000));
     $this->assertFalse($validator->isValid(__DIR__ . '/_files/nofile.mo'));
     $this->assertTrue(array_key_exists('fileWordCountNotFound', $validator->getMessages()));
     $this->assertContains("'nofile.mo'", current($validator->getMessages()));
 }