Skip to content
This repository was archived by the owner on Jan 30, 2020. It is now read-only.

Commit 9c496b9

Browse files
committed
Merge branch 'master' of git://git.zendframework.com/zf
3 parents 6af0cbc + ef88b1e + 90cc750 commit 9c496b9

File tree

4 files changed

+35
-28
lines changed

4 files changed

+35
-28
lines changed

src/Transfer/Transfer.php renamed to src/Transfer.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,18 @@ public function __construct($adapter = 'Http', $direction = false, $options = ar
6666
*/
6767
public function setAdapter($adapter, $direction = false, $options = array())
6868
{
69-
if (end\Loader::isReadable('Zend/File/Transfer/Adapter/' . ucfirst($adapter). '.php')) {
70-
$adapter = 'Zend_File_Transfer_Adapter_' . ucfirst($adapter);
69+
if (\Zend\Loader::isReadable('Zend/File/Transfer/Adapter/' . ucfirst($adapter). '.php')) {
70+
$adapter = 'Zend\File\Transfer\Adapter\\' . ucfirst($adapter);
7171
}
7272

7373
if (!class_exists($adapter)) {
74-
end\Loader::loadClass($adapter);
74+
\Zend\Loader::loadClass($adapter);
7575
}
7676

7777
$direction = (integer) $direction;
7878
$this->_adapter[$direction] = new $adapter($options);
7979
if (!$this->_adapter[$direction] instanceof Adapter\AbstractAdapter) {
80-
throw new Exception("Adapter " . $adapter . " does not extend Zend_File_Transfer_Adapter_Abstract");
80+
throw new Transfer\Exception("Adapter " . $adapter . " does not extend Zend_File_Transfer_Adapter_Abstract");
8181
}
8282

8383
return $this;
@@ -120,6 +120,6 @@ public function __call($method, array $options)
120120
return call_user_func_array(array($this->_adapter[$direction], $method), $options);
121121
}
122122

123-
throw new Exception("Unknown method '" . $method . "' called!");
123+
throw new Transfer\Exception("Unknown method '" . $method . "' called!");
124124
}
125125
}

src/Transfer/Adapter/AbstractAdapter.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,14 @@ public function addValidator($validator, $breakChainOnFailure = false, $options
363363
$this->_break[$name] = $breakChainOnFailure;
364364
$files = $this->_getFiles($files, true, true);
365365
foreach ($files as $file) {
366-
$this->_files[$file]['validators'][] = $name;
366+
if ($name == 'NotEmpty') {
367+
$temp = $this->_files[$file]['validators'];
368+
$this->_files[$file]['validators'] = array($name);
369+
$this->_files[$file]['validators'] += $temp;
370+
} else {
371+
$this->_files[$file]['validators'][] = $name;
372+
}
373+
367374
$this->_files[$file]['validated'] = false;
368375
}
369376

@@ -1284,7 +1291,7 @@ protected function _detectMimeType($value)
12841291
$mime = @finfo_open($const);
12851292
}
12861293

1287-
if ($mime !== false) {
1294+
if (!empty($mime)) {
12881295
$result = finfo_file($mime, $file);
12891296
}
12901297

test/Transfer/Adapter/AbstractTest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -498,15 +498,15 @@ public function testAdapterShouldAllowRemovingAllFiltersAtOnce()
498498

499499
public function testTransferDestinationShouldBeMutable()
500500
{
501-
$directory = dirname(__FILE__);
501+
$directory = __DIR__;
502502
$this->adapter->setDestination($directory);
503503
$destinations = $this->adapter->getDestination();
504504
$this->assertTrue(is_array($destinations));
505505
foreach ($destinations as $file => $destination) {
506506
$this->assertEquals($directory, $destination);
507507
}
508508

509-
$newdirectory = dirname(__FILE__)
509+
$newdirectory = __DIR__
510510
. DIRECTORY_SEPARATOR . '_files';
511511
$this->adapter->setDestination($newdirectory, 'foo');
512512
$this->assertEquals($newdirectory, $this->adapter->getDestination('foo'));
@@ -515,10 +515,10 @@ public function testTransferDestinationShouldBeMutable()
515515

516516
public function testAdapterShouldAllowRetrievingDestinationsForAnArrayOfSpecifiedFiles()
517517
{
518-
$this->adapter->setDestination(dirname(__FILE__));
518+
$this->adapter->setDestination(__DIR__);
519519
$destinations = $this->adapter->getDestination(array('bar', 'baz'));
520520
$this->assertTrue(is_array($destinations));
521-
$directory = dirname(__FILE__);
521+
$directory = __DIR__;
522522
foreach ($destinations as $file => $destination) {
523523
$this->assertTrue(in_array($file, array('bar', 'baz')));
524524
$this->assertEquals($directory, $destination);
@@ -621,23 +621,23 @@ public function testAddTypeIsNotImplemented()
621621

622622
public function testAdapterShouldAllowRetrievingFileName()
623623
{
624-
$path = dirname(__FILE__)
624+
$path = __DIR__
625625
. DIRECTORY_SEPARATOR . '_files';
626626
$this->adapter->setDestination($path);
627627
$this->assertEquals($path . DIRECTORY_SEPARATOR . 'foo.jpg', $this->adapter->getFileName('foo'));
628628
}
629629

630630
public function testAdapterShouldAllowRetrievingFileNameWithoutPath()
631631
{
632-
$path = dirname(__FILE__)
632+
$path = __DIR__
633633
. DIRECTORY_SEPARATOR . '_files';
634634
$this->adapter->setDestination($path);
635635
$this->assertEquals('foo.jpg', $this->adapter->getFileName('foo', false));
636636
}
637637

638638
public function testAdapterShouldAllowRetrievingAllFileNames()
639639
{
640-
$path = dirname(__FILE__)
640+
$path = __DIR__
641641
. DIRECTORY_SEPARATOR . '_files';
642642
$this->adapter->setDestination($path);
643643
$files = $this->adapter->getFileName();
@@ -647,7 +647,7 @@ public function testAdapterShouldAllowRetrievingAllFileNames()
647647

648648
public function testAdapterShouldAllowRetrievingAllFileNamesWithoutPath()
649649
{
650-
$path = dirname(__FILE__)
650+
$path = __DIR__
651651
. DIRECTORY_SEPARATOR . '_files';
652652
$this->adapter->setDestination($path);
653653
$files = $this->adapter->getFileName(null, false);
@@ -759,7 +759,7 @@ public function testSetOwnErrorMessage()
759759

760760
public function testTransferDestinationAtNonExistingElement()
761761
{
762-
$directory = dirname(__FILE__);
762+
$directory = __DIR__;
763763
$this->adapter->setDestination($directory, 'nonexisting');
764764
$this->assertEquals($directory, $this->adapter->getDestination('nonexisting'));
765765
try {
@@ -847,7 +847,7 @@ class AbstractTestMockAdapter extends \Zend\File\Transfer\Adapter\AbstractAdapte
847847

848848
public function __construct()
849849
{
850-
$testfile = dirname(__FILE__) . '/_files/test.txt';
850+
$testfile = __DIR__ . '/_files/test.txt';
851851
$this->_files = array(
852852
'foo' => array(
853853
'name' => 'foo.jpg',

test/Transfer/Adapter/HTTPTest.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,10 @@ public function setUp()
4949
{
5050
$_FILES = array(
5151
'txt' => array(
52-
'name' => dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'test.txt',
52+
'name' => __DIR__ . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'test.txt',
5353
'type' => 'plain/text',
5454
'size' => 8,
55-
'tmp_name' => dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'test.txt',
55+
'tmp_name' => __DIR__ . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'test.txt',
5656
'error' => 0));
5757
$this->adapter = new HTTPTestMockAdapter();
5858
}
@@ -159,7 +159,7 @@ public function testReceiveWithRenameFilter()
159159

160160
public function testReceiveWithRenameFilterButWithoutDirectory()
161161
{
162-
$this->adapter->setDestination(dirname(__FILE__));
162+
$this->adapter->setDestination(__DIR__);
163163
$this->adapter->addFilter('Rename', array('overwrite' => false));
164164
$this->adapter->setOptions(array('ignoreNoFile' => true));
165165
$this->assertTrue($this->adapter->receive());
@@ -169,33 +169,33 @@ public function testMultiFiles()
169169
{
170170
$_FILES = array(
171171
'txt' => array(
172-
'name' => dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'test.txt',
172+
'name' => __DIR__ . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'test.txt',
173173
'type' => 'plain/text',
174174
'size' => 8,
175-
'tmp_name' => dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'test.txt',
175+
'tmp_name' => __DIR__ . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'test.txt',
176176
'error' => 0),
177177
'exe' => array(
178178
'name' => array(
179-
0 => dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'file1.txt',
180-
1 => dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'file2.txt'),
179+
0 => __DIR__ . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'file1.txt',
180+
1 => __DIR__ . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'file2.txt'),
181181
'type' => array(
182182
0 => 'plain/text',
183183
1 => 'plain/text'),
184184
'size' => array(
185185
0 => 8,
186186
1 => 8),
187187
'tmp_name' => array(
188-
0 => dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'file1.txt',
189-
1 => dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'file2.txt'),
188+
0 => __DIR__ . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'file1.txt',
189+
1 => __DIR__ . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'file2.txt'),
190190
'error' => array(
191191
0 => 0,
192192
1 => 0)));
193193
$adapter = new HTTPTestMockAdapter();
194194
$adapter->setOptions(array('ignoreNoFile' => true));
195195
$this->assertTrue($adapter->receive('exe'));
196196
$this->assertEquals(
197-
array('exe_0_' => dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'file1.txt',
198-
'exe_1_' => dirname(__FILE__) . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'file2.txt'),
197+
array('exe_0_' => __DIR__ . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'file1.txt',
198+
'exe_1_' => __DIR__ . DIRECTORY_SEPARATOR . '_files' . DIRECTORY_SEPARATOR . 'file2.txt'),
199199
$adapter->getFileName('exe', false));
200200
}
201201

0 commit comments

Comments
 (0)