[ZF-10089] Zend_Log
[zend/radio.git] / tests / Zend / Validate / File / NotExistsTest.php
blobccb326f3efa1da8c2635d5c8e36541b7efeaa2fd
1 <?php
2 /**
3 * Zend Framework
5 * LICENSE
7 * This source file is subject to the new BSD license that is bundled
8 * with this package in the file LICENSE.txt.
9 * It is also available through the world-wide-web at this URL:
10 * http://framework.zend.com/license/new-bsd
11 * If you did not receive a copy of the license and are unable to
12 * obtain it through the world-wide-web, please send an email
13 * to license@zend.com so we can send you a copy immediately.
15 * @category Zend
16 * @package Zend_Validate_File
17 * @subpackage UnitTests
18 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
19 * @license http://framework.zend.com/license/new-bsd New BSD License
20 * @version $Id$
23 // Call Zend_Validate_File_NotExistsTest::main() if this source file is executed directly.
24 if (!defined("PHPUnit_MAIN_METHOD")) {
25 define("PHPUnit_MAIN_METHOD", "Zend_Validate_File_NotExistsTest::main");
28 /**
29 * Test helper
31 require_once dirname(__FILE__) . '/../../../TestHelper.php';
33 /**
34 * @see Zend_Validate_File_Size
36 require_once 'Zend/Validate/File/NotExists.php';
38 /**
39 * NotExists testbed
41 * @category Zend
42 * @package Zend_Validate_File
43 * @subpackage UnitTests
44 * @copyright Copyright (c) 2005-2010 Zend Technologies USA Inc. (http://www.zend.com)
45 * @license http://framework.zend.com/license/new-bsd New BSD License
46 * @group Zend_Validate
48 class Zend_Validate_File_NotExistsTest extends PHPUnit_Framework_TestCase
50 /**
51 * Runs the test methods of this class.
53 * @return void
55 public static function main()
57 $suite = new PHPUnit_Framework_TestSuite("Zend_Validate_File_NotExistsTest");
58 $result = PHPUnit_TextUI_TestRunner::run($suite);
61 /**
62 * Ensures that the validator follows expected behavior
64 * @return void
66 public function testBasic()
68 $baseDir = dirname(__FILE__);
69 $valuesExpected = array(
70 array($baseDir, 'testsize.mo', true),
71 array($baseDir . '/_files', 'testsize.mo', false)
74 $files = array(
75 'name' => 'testsize.mo',
76 'type' => 'text',
77 'size' => 200,
78 'tmp_name' => dirname(__FILE__) . '/_files/testsize.mo',
79 'error' => 0
82 foreach ($valuesExpected as $element) {
83 $validator = new Zend_Validate_File_NotExists($element[0]);
84 $this->assertEquals(
85 $element[2],
86 $validator->isValid($element[1]),
87 "Tested with " . var_export($element, 1)
89 $this->assertEquals(
90 $element[2],
91 $validator->isValid($element[1], $files),
92 "Tested with " . var_export($element, 1)
96 $valuesExpected = array(
97 array($baseDir, 'testsize.mo', true, false),
98 array($baseDir . '/_files', 'testsize.mo', false, false)
101 $files = array(
102 'name' => 'testsize.mo',
103 'type' => 'text',
104 'size' => 200,
105 'tmp_name' => dirname(__FILE__) . '/_files/testsize.mo',
106 'error' => 0,
107 'destination' => dirname(__FILE__) . '/_files'
110 foreach ($valuesExpected as $element) {
111 $validator = new Zend_Validate_File_NotExists($element[0]);
112 $this->assertEquals(
113 $element[2],
114 $validator->isValid($element[1]),
115 "Tested with " . var_export($element, 1)
117 $this->assertEquals(
118 $element[3],
119 $validator->isValid($element[1], $files),
120 "Tested with " . var_export($element, 1)
124 $valuesExpected = array(
125 array($baseDir, 'testsize.mo', false, false),
126 array($baseDir . '/_files', 'testsize.mo', false, false)
129 foreach ($valuesExpected as $element) {
130 $validator = new Zend_Validate_File_NotExists();
131 $this->assertEquals(
132 $element[2],
133 $validator->isValid($element[1]),
134 "Tested with " . var_export($element, 1)
136 $this->assertEquals(
137 $element[3],
138 $validator->isValid($element[1], $files),
139 "Tested with " . var_export($element, 1)
145 * Ensures that getDirectory() returns expected value
147 * @return void
149 public function testGetDirectory()
151 $validator = new Zend_Validate_File_NotExists('C:/temp');
152 $this->assertEquals('C:/temp', $validator->getDirectory());
154 $validator = new Zend_Validate_File_NotExists(array('temp', 'dir', 'jpg'));
155 $this->assertEquals('temp,dir,jpg', $validator->getDirectory());
157 $validator = new Zend_Validate_File_NotExists(array('temp', 'dir', 'jpg'));
158 $this->assertEquals(array('temp', 'dir', 'jpg'), $validator->getDirectory(true));
162 * Ensures that setDirectory() returns expected value
164 * @return void
166 public function testSetDirectory()
168 $validator = new Zend_Validate_File_NotExists('temp');
169 $validator->setDirectory('gif');
170 $this->assertEquals('gif', $validator->getDirectory());
171 $this->assertEquals(array('gif'), $validator->getDirectory(true));
173 $validator->setDirectory('jpg, temp');
174 $this->assertEquals('jpg,temp', $validator->getDirectory());
175 $this->assertEquals(array('jpg', 'temp'), $validator->getDirectory(true));
177 $validator->setDirectory(array('zip', 'ti'));
178 $this->assertEquals('zip,ti', $validator->getDirectory());
179 $this->assertEquals(array('zip', 'ti'), $validator->getDirectory(true));
183 * Ensures that addDirectory() returns expected value
185 * @return void
187 public function testAddDirectory()
189 $validator = new Zend_Validate_File_NotExists('temp');
190 $validator->addDirectory('gif');
191 $this->assertEquals('temp,gif', $validator->getDirectory());
192 $this->assertEquals(array('temp', 'gif'), $validator->getDirectory(true));
194 $validator->addDirectory('jpg, to');
195 $this->assertEquals('temp,gif,jpg,to', $validator->getDirectory());
196 $this->assertEquals(array('temp', 'gif', 'jpg', 'to'), $validator->getDirectory(true));
198 $validator->addDirectory(array('zip', 'ti'));
199 $this->assertEquals('temp,gif,jpg,to,zip,ti', $validator->getDirectory());
200 $this->assertEquals(array('temp', 'gif', 'jpg', 'to', 'zip', 'ti'), $validator->getDirectory(true));
202 $validator->addDirectory('');
203 $this->assertEquals('temp,gif,jpg,to,zip,ti', $validator->getDirectory());
204 $this->assertEquals(array('temp', 'gif', 'jpg', 'to', 'zip', 'ti'), $validator->getDirectory(true));
208 // Call Zend_Validate_File_NotExistsTest::main() if this source file is executed directly.
209 if (PHPUnit_MAIN_METHOD == "Zend_Validate_File_NotExistsTest::main") {
210 Zend_Validate_File_NotExistsTest::main();