Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Fix for legacy Transfer usage of File Validators #3837

Closed
wants to merge 1 commit into from

2 participants

@cgmartin

Related issue: #3771

Did some functional tests also. Source code here: https://gist.github.com/cgmartin/4997016

@weierophinney weierophinney closed this pull request from a commit
@weierophinney weierophinney Merge branch 'hotfix/3837'
Close #3837
Fixes #3771
15690b1
@ghost Unknown referenced this pull request from a commit
@weierophinney weierophinney Merge branch 'hotfix/3837'
Close #3837
Fixes #3771
64a0fcf
@ghost Unknown referenced this pull request from a commit
@weierophinney weierophinney Merge branch 'hotfix/3837' into develop
Forward port #3837
f670e6a
@weierophinney weierophinney referenced this pull request from a commit in zendframework/zend-validator
@weierophinney weierophinney Merge branch 'hotfix/3837' 49a7844
@weierophinney weierophinney referenced this pull request from a commit in zendframework/zend-validator
@weierophinney weierophinney Merge branch 'hotfix/3837' into develop 491d0ec
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 20, 2013
  1. @cgmartin
This page is out of date. Refresh to see the latest.
Showing with 351 additions and 31 deletions.
  1. +7 −2 library/Zend/Validator/File/Crc32.php
  2. +7 −2 library/Zend/Validator/File/ExcludeExtension.php
  3. +8 −2 library/Zend/Validator/File/ExcludeMimeType.php
  4. +8 −2 library/Zend/Validator/File/Exists.php
  5. +7 −2 library/Zend/Validator/File/Extension.php
  6. +7 −2 library/Zend/Validator/File/Hash.php
  7. +7 −2 library/Zend/Validator/File/ImageSize.php
  8. +7 −2 library/Zend/Validator/File/Md5.php
  9. +8 −2 library/Zend/Validator/File/MimeType.php
  10. +8 −2 library/Zend/Validator/File/NotExists.php
  11. +7 −2 library/Zend/Validator/File/Sha1.php
  12. +7 −2 library/Zend/Validator/File/Size.php
  13. +8 −3 library/Zend/Validator/File/WordCount.php
  14. +17 −0 tests/ZendTest/Validator/File/Crc32Test.php
  15. +17 −0 tests/ZendTest/Validator/File/ExcludeExtensionTest.php
  16. +15 −0 tests/ZendTest/Validator/File/ExcludeMimeTypeTest.php
  17. +14 −0 tests/ZendTest/Validator/File/ExistsTest.php
  18. +17 −0 tests/ZendTest/Validator/File/ExtensionTest.php
  19. +17 −0 tests/ZendTest/Validator/File/HashTest.php
  20. +23 −0 tests/ZendTest/Validator/File/ImageSizeTest.php
  21. +29 −4 tests/ZendTest/Validator/File/IsCompressedTest.php
  22. +15 −0 tests/ZendTest/Validator/File/IsImageTest.php
  23. +17 −0 tests/ZendTest/Validator/File/Md5Test.php
  24. +15 −0 tests/ZendTest/Validator/File/MimeTypeTest.php
  25. +14 −0 tests/ZendTest/Validator/File/NotExistsTest.php
  26. +17 −0 tests/ZendTest/Validator/File/Sha1Test.php
  27. +14 −0 tests/ZendTest/Validator/File/SizeTest.php
  28. +14 −0 tests/ZendTest/Validator/File/WordCountTest.php
View
9 library/Zend/Validator/File/Crc32.php
@@ -80,11 +80,16 @@ public function addCrc32($options)
* Returns true if and only if the given file confirms the set hash
*
* @param string|array $value Filename to check for hash
+ * @param array $file File data from \Zend\File\Transfer\Transfer (optional)
* @return bool
*/
- public function isValid($value)
+ public function isValid($value, $file = null)
{
- if (is_array($value)) {
+ if (is_string($value) && is_array($file)) {
+ // Legacy Zend\Transfer API support
+ $filename = $file['name'];
+ $file = $file['tmp_name'];
+ } elseif (is_array($value)) {
if (!isset($value['tmp_name']) || !isset($value['name'])) {
throw new Exception\InvalidArgumentException(
'Value array must be in $_FILES format'
View
9 library/Zend/Validator/File/ExcludeExtension.php
@@ -35,11 +35,16 @@ class ExcludeExtension extends Extension
* set extension list
*
* @param string|array $value Real file to check for extension
+ * @param array $file File data from \Zend\File\Transfer\Transfer (optional)
* @return bool
*/
- public function isValid($value)
+ public function isValid($value, $file = null)
{
- if (is_array($value)) {
+ if (is_string($value) && is_array($file)) {
+ // Legacy Zend\Transfer API support
+ $filename = $file['name'];
+ $file = $file['tmp_name'];
+ } elseif (is_array($value)) {
if (!isset($value['tmp_name']) || !isset($value['name'])) {
throw new Exception\InvalidArgumentException(
'Value array must be in $_FILES format'
View
10 library/Zend/Validator/File/ExcludeMimeType.php
@@ -27,11 +27,17 @@ class ExcludeMimeType extends MimeType
* mime types will not be accepted like "image/gif", "image/jpeg" and so on.
*
* @param string|array $value Real file to check for mimetype
+ * @param array $file File data from \Zend\File\Transfer\Transfer (optional)
* @return bool
*/
- public function isValid($value)
+ public function isValid($value, $file = null)
{
- if (is_array($value)) {
+ if (is_string($value) && is_array($file)) {
+ // Legacy Zend\Transfer API support
+ $filename = $file['name'];
+ $filetype = $file['type'];
+ $file = $file['tmp_name'];
+ } elseif (is_array($value)) {
if (!isset($value['tmp_name']) || !isset($value['name']) || !isset($value['type'])) {
throw new Exception\InvalidArgumentException(
'Value array must be in $_FILES format'
View
10 library/Zend/Validator/File/Exists.php
@@ -139,11 +139,17 @@ public function addDirectory($directory)
* Returns true if and only if the file already exists in the set directories
*
* @param string|array $value Real file to check for existence
+ * @param array $file File data from \Zend\File\Transfer\Transfer (optional)
* @return bool
*/
- public function isValid($value)
+ public function isValid($value, $file = null)
{
- if (is_array($value)) {
+ if (is_string($value) && is_array($file)) {
+ // Legacy Zend\Transfer API support
+ $filename = $file['name'];
+ $file = $file['tmp_name'];
+ $this->setValue($filename);
+ } elseif (is_array($value)) {
if (!isset($value['tmp_name']) || !isset($value['name'])) {
throw new Exception\InvalidArgumentException(
'Value array must be in $_FILES format'
View
9 library/Zend/Validator/File/Extension.php
@@ -171,11 +171,16 @@ public function addExtension($extension)
* set extension list
*
* @param string|array $value Real file to check for extension
+ * @param array $file File data from \Zend\File\Transfer\Transfer (optional)
* @return bool
*/
- public function isValid($value)
+ public function isValid($value, $file = null)
{
- if (is_array($value)) {
+ if (is_string($value) && is_array($file)) {
+ // Legacy Zend\Transfer API support
+ $filename = $file['name'];
+ $file = $file['tmp_name'];
+ } elseif (is_array($value)) {
if (!isset($value['tmp_name']) || !isset($value['name'])) {
throw new Exception\InvalidArgumentException(
'Value array must be in $_FILES format'
View
9 library/Zend/Validator/File/Hash.php
@@ -124,11 +124,16 @@ public function addHash($options)
* Returns true if and only if the given file confirms the set hash
*
* @param string|array $value File to check for hash
+ * @param array $file File data from \Zend\File\Transfer\Transfer (optional)
* @return bool
*/
- public function isValid($value)
+ public function isValid($value, $file = null)
{
- if (is_array($value)) {
+ if (is_string($value) && is_array($file)) {
+ // Legacy Zend\Transfer API support
+ $filename = $file['name'];
+ $file = $file['tmp_name'];
+ } elseif (is_array($value)) {
if (!isset($value['tmp_name']) || !isset($value['name'])) {
throw new Exception\InvalidArgumentException(
'Value array must be in $_FILES format'
View
9 library/Zend/Validator/File/ImageSize.php
@@ -319,11 +319,16 @@ public function setImageHeight($options)
* not bigger than max
*
* @param string|array $value Real file to check for image size
+ * @param array $file File data from \Zend\File\Transfer\Transfer (optional)
* @return bool
*/
- public function isValid($value)
+ public function isValid($value, $file = null)
{
- if (is_array($value)) {
+ if (is_string($value) && is_array($file)) {
+ // Legacy Zend\Transfer API support
+ $filename = $file['name'];
+ $file = $file['tmp_name'];
+ } elseif (is_array($value)) {
if (!isset($value['tmp_name']) || !isset($value['name'])) {
throw new Exception\InvalidArgumentException(
'Value array must be in $_FILES format'
View
9 library/Zend/Validator/File/Md5.php
@@ -80,11 +80,16 @@ public function addMd5($options)
* Returns true if and only if the given file confirms the set hash
*
* @param string|array $value Filename to check for hash
+ * @param array $file File data from \Zend\File\Transfer\Transfer (optional)
* @return bool
*/
- public function isValid($value)
+ public function isValid($value, $file = null)
{
- if (is_array($value)) {
+ if (is_string($value) && is_array($file)) {
+ // Legacy Zend\Transfer API support
+ $filename = $file['name'];
+ $file = $file['tmp_name'];
+ } elseif (is_array($value)) {
if (!isset($value['tmp_name']) || !isset($value['name'])) {
throw new Exception\InvalidArgumentException(
'Value array must be in $_FILES format'
View
10 library/Zend/Validator/File/MimeType.php
@@ -342,11 +342,17 @@ public function addMimeType($mimetype)
* mime types will be accepted like "image/gif", "image/jpeg" and so on.
*
* @param string|array $value Real file to check for mimetype
+ * @param array $file File data from \Zend\File\Transfer\Transfer (optional)
* @return bool
*/
- public function isValid($value)
+ public function isValid($value, $file = null)
{
- if (is_array($value)) {
+ if (is_string($value) && is_array($file)) {
+ // Legacy Zend\Transfer API support
+ $filename = $file['name'];
+ $filetype = $file['type'];
+ $file = $file['tmp_name'];
+ } elseif (is_array($value)) {
if (!isset($value['tmp_name']) || !isset($value['name']) || !isset($value['type'])) {
throw new Exception\InvalidArgumentException(
'Value array must be in $_FILES format'
View
10 library/Zend/Validator/File/NotExists.php
@@ -32,11 +32,17 @@ class NotExists extends Exists
* Returns true if and only if the file does not exist in the set destinations
*
* @param string|array $value Real file to check for existence
+ * @param array $file File data from \Zend\File\Transfer\Transfer (optional)
* @return bool
*/
- public function isValid($value)
+ public function isValid($value, $file = null)
{
- if (is_array($value)) {
+ if (is_string($value) && is_array($file)) {
+ // Legacy Zend\Transfer API support
+ $filename = $file['name'];
+ $file = $file['tmp_name'];
+ $this->setValue($filename);
+ } elseif (is_array($value)) {
if (!isset($value['tmp_name']) || !isset($value['name'])) {
throw new Exception\InvalidArgumentException(
'Value array must be in $_FILES format'
View
9 library/Zend/Validator/File/Sha1.php
@@ -80,11 +80,16 @@ public function addSha1($options)
* Returns true if and only if the given file confirms the set hash
*
* @param string $value|array Filename to check for hash
+ * @param array $file File data from \Zend\File\Transfer\Transfer (optional)
* @return bool
*/
- public function isValid($value)
+ public function isValid($value, $file = null)
{
- if (is_array($value)) {
+ if (is_string($value) && is_array($file)) {
+ // Legacy Zend\Transfer API support
+ $filename = $file['name'];
+ $file = $file['tmp_name'];
+ } elseif (is_array($value)) {
if (!isset($value['tmp_name']) || !isset($value['name'])) {
throw new Exception\InvalidArgumentException(
'Value array must be in $_FILES format'
View
9 library/Zend/Validator/File/Size.php
@@ -229,11 +229,16 @@ protected function setSize($size)
* not bigger than max (when max is not null).
*
* @param string|array $value File to check for size
+ * @param array $file File data from \Zend\File\Transfer\Transfer (optional)
* @return bool
*/
- public function isValid($value)
+ public function isValid($value, $file = null)
{
- if (is_array($value)) {
+ if (is_string($value) && is_array($file)) {
+ // Legacy Zend\Transfer API support
+ $filename = $file['name'];
+ $file = $file['tmp_name'];
+ } elseif (is_array($value)) {
if (!isset($value['tmp_name']) || !isset($value['name'])) {
throw new Exception\InvalidArgumentException(
'Value array must be in $_FILES format'
View
11 library/Zend/Validator/File/WordCount.php
@@ -166,12 +166,17 @@ public function setMax($max)
* Returns true if and only if the counted words are at least min and
* not bigger than max (when max is not null).
*
- * @param string $value|array Filename to check for word count
+ * @param string|array $value Filename to check for word count
+ * @param array $file File data from \Zend\File\Transfer\Transfer (optional)
* @return bool
*/
- public function isValid($value)
+ public function isValid($value, $file = null)
{
- if (is_array($value)) {
+ if (is_string($value) && is_array($file)) {
+ // Legacy Zend\Transfer API support
+ $filename = $file['name'];
+ $file = $file['tmp_name'];
+ } elseif (is_array($value)) {
if (!isset($value['tmp_name']) || !isset($value['name'])) {
throw new Exception\InvalidArgumentException(
'Value array must be in $_FILES format'
View
17 tests/ZendTest/Validator/File/Crc32Test.php
@@ -75,6 +75,23 @@ public function testBasic($options, $isValidParam, $expected, $messageKey)
}
/**
+ * Ensures that the validator follows expected behavior for legacy Zend\Transfer API
+ *
+ * @dataProvider basicBehaviorDataProvider
+ * @return void
+ */
+ public function testLegacy($options, $isValidParam, $expected, $messageKey)
+ {
+ if (is_array($isValidParam)) {
+ $validator = new File\Crc32($options);
+ $this->assertEquals($expected, $validator->isValid($isValidParam['tmp_name'], $isValidParam));
+ if (!$expected) {
+ $this->assertTrue(array_key_exists($messageKey, $validator->getMessages()));
+ }
+ }
+ }
+
+ /**
* Ensures that getCrc32() returns expected value
*
* @return void
View
17 tests/ZendTest/Validator/File/ExcludeExtensionTest.php
@@ -69,6 +69,23 @@ public function testBasic($options, $isValidParam, $expected, $messageKey)
}
}
+ /**
+ * Ensures that the validator follows expected behavior for legacy Zend\Transfer API
+ *
+ * @dataProvider basicBehaviorDataProvider
+ * @return void
+ */
+ public function testLegacy($options, $isValidParam, $expected, $messageKey)
+ {
+ if (is_array($isValidParam)) {
+ $validator = new File\ExcludeExtension($options);
+ $this->assertEquals($expected, $validator->isValid($isValidParam['tmp_name'], $isValidParam));
+ if (!$expected) {
+ $this->assertTrue(array_key_exists($messageKey, $validator->getMessages()));
+ }
+ }
+ }
+
public function testCaseTesting()
{
$files = array(
View
15 tests/ZendTest/Validator/File/ExcludeMimeTypeTest.php
@@ -58,6 +58,21 @@ public function testBasic($options, $isValidParam, $expected)
}
/**
+ * Ensures that the validator follows expected behavior for legacy Zend\Transfer API
+ *
+ * @dataProvider basicBehaviorDataProvider
+ * @return void
+ */
+ public function testLegacy($options, $isValidParam, $expected)
+ {
+ if (is_array($isValidParam)) {
+ $validator = new ExcludeMimeType($options);
+ $validator->enableHeaderCheck();
+ $this->assertEquals($expected, $validator->isValid($isValidParam['tmp_name'], $isValidParam));
+ }
+ }
+
+ /**
* Ensures that getMimeType() returns expected value
*
* @return void
View
14 tests/ZendTest/Validator/File/ExistsTest.php
@@ -55,6 +55,20 @@ public function testBasic($options, $isValidParam, $expected)
}
/**
+ * Ensures that the validator follows expected behavior for legacy Zend\Transfer API
+ *
+ * @dataProvider basicBehaviorDataProvider
+ * @return void
+ */
+ public function testLegacy($options, $isValidParam, $expected)
+ {
+ if (is_array($isValidParam)) {
+ $validator = new File\Exists($options);
+ $this->assertEquals($expected, $validator->isValid($isValidParam['tmp_name'], $isValidParam));
+ }
+ }
+
+ /**
* Ensures that getDirectory() returns expected value
*
* @return void
View
17 tests/ZendTest/Validator/File/ExtensionTest.php
@@ -70,6 +70,23 @@ public function testBasic($options, $isValidParam, $expected, $messageKey)
}
/**
+ * Ensures that the validator follows expected behavior for legacy Zend\Transfer API
+ *
+ * @dataProvider basicBehaviorDataProvider
+ * @return void
+ */
+ public function testLegacy($options, $isValidParam, $expected, $messageKey)
+ {
+ if (is_array($isValidParam)) {
+ $validator = new File\Extension($options);
+ $this->assertEquals($expected, $validator->isValid($isValidParam['tmp_name'], $isValidParam));
+ if (!$expected) {
+ $this->assertTrue(array_key_exists($messageKey, $validator->getMessages()));
+ }
+ }
+ }
+
+ /**
* @return void
*/
public function testZF3891()
View
17 tests/ZendTest/Validator/File/HashTest.php
@@ -93,6 +93,23 @@ public function testBasic($options, $isValidParam, $expected, $messageKey)
}
/**
+ * Ensures that the validator follows expected behavior for legacy Zend\Transfer API
+ *
+ * @dataProvider basicBehaviorDataProvider
+ * @return void
+ */
+ public function testLegacy($options, $isValidParam, $expected, $messageKey)
+ {
+ if (is_array($isValidParam)) {
+ $validator = new File\Hash($options);
+ $this->assertEquals($expected, $validator->isValid($isValidParam['tmp_name'], $isValidParam));
+ if (!$expected) {
+ $this->assertTrue(array_key_exists($messageKey, $validator->getMessages()));
+ }
+ }
+ }
+
+ /**
* Ensures that getHash() returns expected value
*
* @return void
View
23 tests/ZendTest/Validator/File/ImageSizeTest.php
@@ -113,6 +113,29 @@ public function testBasic($options, $isValidParam, $expected, $messageKeys)
}
/**
+ * Ensures that the validator follows expected behavior for legacy Zend\Transfer API
+ *
+ * @dataProvider basicBehaviorDataProvider
+ * @return void
+ */
+ public function testLegacy($options, $isValidParam, $expected, $messageKeys)
+ {
+ // Test legacy Zend\Transfer API
+ if (is_array($isValidParam)) {
+ $validator = new File\ImageSize($options);
+ $this->assertEquals($expected, $validator->isValid($isValidParam['tmp_name'], $isValidParam));
+ if (!$expected) {
+ if (!is_array($messageKeys)) {
+ $messageKeys = array($messageKeys);
+ }
+ foreach ($messageKeys as $messageKey) {
+ $this->assertTrue(array_key_exists($messageKey, $validator->getMessages()));
+ }
+ }
+ }
+ }
+
+ /**
* Ensures that getImageMin() returns expected value
*
* @return void
View
33 tests/ZendTest/Validator/File/IsCompressedTest.php
@@ -59,12 +59,9 @@ public function basicBehaviorDataProvider()
}
/**
- * Ensures that the validator follows expected behavior
- *
- * @dataProvider basicBehaviorDataProvider
* @return void
*/
- public function testBasic($options, $isValidParam, $expected)
+ protected function skipIfNoFileInfoExtension()
{
if (!extension_loaded('fileinfo') &&
function_exists('mime_content_type') && ini_get('mime_magic.magicfile') &&
@@ -75,6 +72,17 @@ function_exists('mime_content_type') && ini_get('mime_magic.magicfile') &&
' but mime_content_type exhibits buggy behavior on this system.'
);
}
+ }
+
+ /**
+ * Ensures that the validator follows expected behavior
+ *
+ * @dataProvider basicBehaviorDataProvider
+ * @return void
+ */
+ public function testBasic($options, $isValidParam, $expected)
+ {
+ $this->skipIfNoFileInfoExtension();
$validator = new File\IsCompressed($options);
$validator->enableHeaderCheck();
@@ -82,6 +90,23 @@ function_exists('mime_content_type') && ini_get('mime_magic.magicfile') &&
}
/**
+ * Ensures that the validator follows expected behavior for legacy Zend\Transfer API
+ *
+ * @dataProvider basicBehaviorDataProvider
+ * @return void
+ */
+ public function testLegacy($options, $isValidParam, $expected)
+ {
+ if (is_array($isValidParam)) {
+ $this->skipIfNoFileInfoExtension();
+
+ $validator = new File\IsCompressed($options);
+ $validator->enableHeaderCheck();
+ $this->assertEquals($expected, $validator->isValid($isValidParam['tmp_name'], $isValidParam));
+ }
+ }
+
+ /**
* Ensures that getMimeType() returns expected value
*
* @return void
View
15 tests/ZendTest/Validator/File/IsImageTest.php
@@ -73,6 +73,21 @@ public function testBasic($options, $isValidParam, $expected)
}
/**
+ * Ensures that the validator follows expected behavior for legacy Zend\Transfer API
+ *
+ * @dataProvider basicBehaviorDataProvider
+ * @return void
+ */
+ public function testLegacy($options, $isValidParam, $expected)
+ {
+ if (is_array($isValidParam)) {
+ $validator = new File\IsImage($options);
+ $validator->enableHeaderCheck();
+ $this->assertEquals($expected, $validator->isValid($isValidParam['tmp_name'], $isValidParam));
+ }
+ }
+
+ /**
* Ensures that getMimeType() returns expected value
*
* @return void
View
17 tests/ZendTest/Validator/File/Md5Test.php
@@ -89,6 +89,23 @@ public function testBasic($options, $isValidParam, $expected, $messageKey)
}
/**
+ * Ensures that the validator follows expected behavior for legacy Zend\Transfer API
+ *
+ * @dataProvider basicBehaviorDataProvider
+ * @return void
+ */
+ public function testLegacy($options, $isValidParam, $expected, $messageKey)
+ {
+ if (is_array($isValidParam)) {
+ $validator = new File\Md5($options);
+ $this->assertEquals($expected, $validator->isValid($isValidParam['tmp_name'], $isValidParam));
+ if (!$expected) {
+ $this->assertTrue(array_key_exists($messageKey, $validator->getMessages()));
+ }
+ }
+ }
+
+ /**
* Ensures that getMd5() returns expected value
*
* @return void
View
15 tests/ZendTest/Validator/File/MimeTypeTest.php
@@ -62,6 +62,21 @@ public function testBasic($options, $isValidParam, $expected)
}
/**
+ * Ensures that the validator follows expected behavior for legacy Zend\Transfer API
+ *
+ * @dataProvider basicBehaviorDataProvider
+ * @return void
+ */
+ public function testLegacy($options, $isValidParam, $expected)
+ {
+ if (is_array($isValidParam)) {
+ $validator = new File\MimeType($options);
+ $validator->enableHeaderCheck();
+ $this->assertEquals($expected, $validator->isValid($isValidParam['tmp_name'], $isValidParam));
+ }
+ }
+
+ /**
* Ensures that getMimeType() returns expected value
*
* @return void
View
14 tests/ZendTest/Validator/File/NotExistsTest.php
@@ -57,6 +57,20 @@ public function testBasic($options, $isValidParam, $expected)
}
/**
+ * Ensures that the validator follows expected behavior for legacy Zend\Transfer API
+ *
+ * @dataProvider basicBehaviorDataProvider
+ * @return void
+ */
+ public function testLegacy($options, $isValidParam, $expected)
+ {
+ if (is_array($isValidParam)) {
+ $validator = new File\NotExists($options);
+ $this->assertEquals($expected, $validator->isValid($isValidParam['tmp_name'], $isValidParam));
+ }
+ }
+
+ /**
* Ensures that getDirectory() returns expected value
*
* @return void
View
17 tests/ZendTest/Validator/File/Sha1Test.php
@@ -76,6 +76,23 @@ public function testBasic($options, $isValidParam, $expected, $messageKey)
}
/**
+ * Ensures that the validator follows expected behavior for legacy Zend\Transfer API
+ *
+ * @dataProvider basicBehaviorDataProvider
+ * @return void
+ */
+ public function testLegacy($options, $isValidParam, $expected, $messageKey)
+ {
+ if (is_array($isValidParam)) {
+ $validator = new File\Sha1($options);
+ $this->assertEquals($expected, $validator->isValid($isValidParam['tmp_name'], $isValidParam));
+ if (!$expected) {
+ $this->assertTrue(array_key_exists($messageKey, $validator->getMessages()));
+ }
+ }
+ }
+
+ /**
* Ensures that getSha1() returns expected value
*
* @return void
View
14 tests/ZendTest/Validator/File/SizeTest.php
@@ -64,6 +64,20 @@ public function testBasic($options, $isValidParam, $expected)
}
/**
+ * Ensures that the validator follows expected behavior for legacy Zend\Transfer API
+ *
+ * @dataProvider basicBehaviorDataProvider
+ * @return void
+ */
+ public function testLegacy($options, $isValidParam, $expected)
+ {
+ if (is_array($isValidParam)) {
+ $validator = new File\Size($options);
+ $this->assertEquals($expected, $validator->isValid($isValidParam['tmp_name'], $isValidParam));
+ }
+ }
+
+ /**
* Ensures that getMin() returns expected value
*
* @return void
View
14 tests/ZendTest/Validator/File/WordCountTest.php
@@ -59,6 +59,20 @@ public function testBasic($options, $isValidParam, $expected)
}
/**
+ * Ensures that the validator follows expected behavior for legacy Zend\Transfer API
+ *
+ * @dataProvider basicBehaviorDataProvider
+ * @return void
+ */
+ public function testLegacy($options, $isValidParam, $expected)
+ {
+ if (is_array($isValidParam)) {
+ $validator = new File\WordCount($options);
+ $this->assertEquals($expected, $validator->isValid($isValidParam['tmp_name'], $isValidParam));
+ }
+ }
+
+ /**
* Ensures that getMin() returns expected value
*
* @return void
Something went wrong with that request. Please try again.