Пример #1
0
 /**
  * Ensures that the validator follows expected behavior
  *
  * @return void
  */
 public function testBasic()
 {
     $valuesExpected = array(array(5, null, true, true, true, true), array(0, 3, true, true, true, false), array(2, 3, false, true, true, false));
     foreach ($valuesExpected as $element) {
         $validator = new Zend_Validate_File_Count($element[0], $element[1]);
         $this->assertEquals($element[2], $validator->isValid(dirname(__FILE__) . '/_files/testsize.mo'));
         $this->assertEquals($element[3], $validator->isValid(dirname(__FILE__) . '/_files/testsize2.mo'));
         $this->assertEquals($element[4], $validator->isValid(dirname(__FILE__) . '/_files/testsize3.mo'));
         $this->assertEquals($element[5], $validator->isValid(dirname(__FILE__) . '/_files/testsize4.mo'));
     }
     foreach ($valuesExpected as $element) {
         $validator = new Zend_Validate_File_Count(array($element[0], $element[1]));
         $this->assertEquals($element[2], $validator->isValid(dirname(__FILE__) . '/_files/testsize.mo'));
         $this->assertEquals($element[3], $validator->isValid(dirname(__FILE__) . '/_files/testsize2.mo'));
         $this->assertEquals($element[4], $validator->isValid(dirname(__FILE__) . '/_files/testsize3.mo'));
         $this->assertEquals($element[5], $validator->isValid(dirname(__FILE__) . '/_files/testsize4.mo'));
     }
     foreach ($valuesExpected as $element) {
         $validator = new Zend_Validate_File_Count(array('min' => $element[0], 'max' => $element[1]));
         $this->assertEquals($element[2], $validator->isValid(dirname(__FILE__) . '/_files/testsize.mo'));
         $this->assertEquals($element[3], $validator->isValid(dirname(__FILE__) . '/_files/testsize2.mo'));
         $this->assertEquals($element[4], $validator->isValid(dirname(__FILE__) . '/_files/testsize3.mo'));
         $this->assertEquals($element[5], $validator->isValid(dirname(__FILE__) . '/_files/testsize4.mo'));
     }
     $validator = new Zend_Validate_File_Count(array(1));
     $this->assertEquals(true, $validator->isValid(dirname(__FILE__) . '/_files/testsize.mo'));
     $this->assertEquals(false, $validator->isValid(dirname(__FILE__) . '/_files/testsize2.mo'));
 }
Пример #2
0
 /**
  * Ensures that the validator follows expected behavior
  *
  * @return void
  */
 public function testBasic()
 {
     $valuesExpected = array(array(5, true, true, true, true), array(array('min' => 0, 'max' => 3), true, true, true, false), array(array('min' => 2, 'max' => 3), false, true, true, false), array(array('min' => 2), false, true, true, true), array(array('max' => 5), true, true, true, true));
     foreach ($valuesExpected as $element) {
         $validator = new Zend_Validate_File_Count($element[0]);
         $this->assertEquals($element[1], $validator->isValid(dirname(__FILE__) . '/_files/testsize.mo'), "Tested with " . var_export($element, 1));
         $this->assertEquals($element[2], $validator->isValid(dirname(__FILE__) . '/_files/testsize2.mo'), "Tested with " . var_export($element, 1));
         $this->assertEquals($element[3], $validator->isValid(dirname(__FILE__) . '/_files/testsize3.mo'), "Tested with " . var_export($element, 1));
         $this->assertEquals($element[4], $validator->isValid(dirname(__FILE__) . '/_files/testsize4.mo'), "Tested with " . var_export($element, 1));
     }
 }