assertEquals( $element[1], $validator->isValid(dirname(__FILE__) . '/_files/picture.jpg'), "Tested with " . var_export($element, 1) ); } $validator = new Zend_Validate_File_Sha1('b2a5334847b4328e7d19d9b41fd874dffa911c98'); $this->assertFalse($validator->isValid(dirname(__FILE__) . '/_files/nofile.mo')); $this->assertTrue(array_key_exists('fileSha1NotFound', $validator->getMessages())); $files = array( 'name' => 'test1', 'type' => 'text', 'size' => 200, 'tmp_name' => 'tmp_test1', 'error' => 0 ); $validator = new Zend_Validate_File_Sha1('b2a5334847b4328e7d19d9b41fd874dffa911c98'); $this->assertFalse($validator->isValid(dirname(__FILE__) . '/_files/nofile.mo', $files)); $this->assertTrue(array_key_exists('fileSha1NotFound', $validator->getMessages())); $files = array( 'name' => 'testsize.mo', 'type' => 'text', 'size' => 200, 'tmp_name' => dirname(__FILE__) . '/_files/testsize.mo', 'error' => 0 ); $validator = new Zend_Validate_File_Sha1('b2a5334847b4328e7d19d9b41fd874dffa911c98'); $this->assertTrue($validator->isValid(dirname(__FILE__) . '/_files/picture.jpg', $files)); $files = array( 'name' => 'testsize.mo', 'type' => 'text', 'size' => 200, 'tmp_name' => dirname(__FILE__) . '/_files/testsize.mo', 'error' => 0 ); $validator = new Zend_Validate_File_Sha1('42a5334847b4328e7d19d9b41fd874dffa911c98'); $this->assertFalse($validator->isValid(dirname(__FILE__) . '/_files/picture.jpg', $files)); $this->assertTrue(array_key_exists('fileSha1DoesNotMatch', $validator->getMessages())); } /** * Ensures that getSha1() returns expected value * * @return void */ public function testgetSha1() { $validator = new Zend_Validate_File_Sha1('12345'); $this->assertEquals(array('12345' => 'sha1'), $validator->getSha1()); $validator = new Zend_Validate_File_Sha1(array('12345', '12333', '12344')); $this->assertEquals(array('12345' => 'sha1', '12333' => 'sha1', '12344' => 'sha1'), $validator->getSha1()); } /** * Ensures that getHash() returns expected value * * @return void */ public function testgetHash() { $validator = new Zend_Validate_File_Sha1('12345'); $this->assertEquals(array('12345' => 'sha1'), $validator->getHash()); $validator = new Zend_Validate_File_Sha1(array('12345', '12333', '12344')); $this->assertEquals(array('12345' => 'sha1', '12333' => 'sha1', '12344' => 'sha1'), $validator->getHash()); } /** * Ensures that setSha1() returns expected value * * @return void */ public function testSetSha1() { $validator = new Zend_Validate_File_Sha1('12345'); $validator->setSha1('12333'); $this->assertEquals(array('12333' => 'sha1'), $validator->getSha1()); $validator->setSha1(array('12321', '12121')); $this->assertEquals(array('12321' => 'sha1', '12121' => 'sha1'), $validator->getSha1()); } /** * Ensures that setHash() returns expected value * * @return void */ public function testSetHash() { $validator = new Zend_Validate_File_Sha1('12345'); $validator->setHash('12333'); $this->assertEquals(array('12333' => 'sha1'), $validator->getSha1()); $validator->setHash(array('12321', '12121')); $this->assertEquals(array('12321' => 'sha1', '12121' => 'sha1'), $validator->getSha1()); } /** * Ensures that addSha1() returns expected value * * @return void */ public function testAddSha1() { $validator = new Zend_Validate_File_Sha1('12345'); $validator->addSha1('12344'); $this->assertEquals(array('12345' => 'sha1', '12344' => 'sha1'), $validator->getSha1()); $validator->addSha1(array('12321', '12121')); $this->assertEquals(array('12345' => 'sha1', '12344' => 'sha1', '12321' => 'sha1', '12121' => 'sha1'), $validator->getSha1()); } /** * Ensures that addHash() returns expected value * * @return void */ public function testAddHash() { $validator = new Zend_Validate_File_Sha1('12345'); $validator->addHash('12344'); $this->assertEquals(array('12345' => 'sha1', '12344' => 'sha1'), $validator->getSha1()); $validator->addHash(array('12321', '12121')); $this->assertEquals(array('12345' => 'sha1', '12344' => 'sha1', '12321' => 'sha1', '12121' => 'sha1'), $validator->getSha1()); } } // Call Zend_Validate_File_Sha1Test::main() if this source file is executed directly. if (PHPUnit_MAIN_METHOD == "Zend_Validate_File_Sha1Test::main") { Zend_Validate_File_Sha1Test::main(); }