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

Commit e69eb4d

Browse files
committed
Incorporated feedback from #14
This patch incorporates feedback from #14, specifically: - Reverts the addition of zend-session to the requirements; it's not used anywhere. - Reverts changes to `HttpTestMockAdapter`; they did not serve any noticeable purpose. - Updates `AbstractAdapter` to cast the `$options` value to an array when scalar, ensuring it works with both v2 and v3 versions of zend-servicemanager. - Updated FilterPluginManager to: - Move the `array_merge()` option before the call to the parent constructor; this ensures any configuration passed at instantation takes precedence. - Use short array notation for the array passed to `array_merge()`. - Document the constructor. - Updated the `AbstractTest` - Reverted the change to `testAdapterShouldAllowPullingFiltersByFile`; it was changing the test to follow observed behavior instead of updating the code to retain existing behavior. - Fixed a number of CS issues with regards to multi-line arguments.
1 parent 12dca2f commit e69eb4d

File tree

5 files changed

+55
-45
lines changed

5 files changed

+55
-45
lines changed

composer.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
"zendframework/zend-servicemanager": "~2.5",
2323
"zendframework/zend-validator": "~2.5",
2424
"zendframework/zend-progressbar": "~2.5",
25-
"zendframework/zend-session": "~2.5",
2625
"fabpot/php-cs-fixer": "1.7.*",
2726
"phpunit/PHPUnit": "~4.0"
2827
},

src/Transfer/Adapter/AbstractAdapter.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -710,6 +710,7 @@ public function hasErrors()
710710
public function addFilter($filter, $options = null, $files = null)
711711
{
712712
if (is_string($filter)) {
713+
$options = (null !== $options && is_scalar($options)) ? [$options] : $options;
713714
$filter = $this->getFilterManager()->get($filter, $options);
714715
}
715716

src/Transfer/Adapter/FilterPluginManager.php

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,19 +21,26 @@
2121
*/
2222
class FilterPluginManager extends BaseManager
2323
{
24-
25-
public function __construct($configOrContainerInstance = null, array $v3config = [])
24+
/**
25+
* Constructor
26+
*
27+
* Merges default aliases pertinent to this plugin manager with those
28+
* defined in the parent filter plugin manager.
29+
*
30+
* @param null|\Zend\ServiceManager\ConfigInterface|\Interop\Container\ContainerInterface $configOrContainerInstance
31+
* @param array $v3config If $configOrContainerInstance is a container, this
32+
* value will be passed to the parent constructor.
33+
*/
34+
public function __construct($configOrContainerInstance = null, array $v3config = [])
2635
{
27-
parent::__construct($configOrContainerInstance, $v3config);
28-
29-
$this->aliases = array_merge(array(
36+
$this->aliases = array_merge([
3037
'decrypt' => File\Decrypt::class,
3138
'encrypt' => File\Encrypt::class,
3239
'lowercase' => File\LowerCase::class,
3340
'rename' => File\Rename::class,
34-
'uppercase' => File\UpperCase::class
35-
), $this->aliases);
36-
}
41+
'uppercase' => File\UpperCase::class,
42+
], $this->aliases);
3743

44+
parent::__construct($configOrContainerInstance, $v3config);
45+
}
3846
}
39-

test/Transfer/Adapter/AbstractTest.php

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ public function testGetFilterShouldReturnNullWhenNoMatchingIdentifierExists()
301301

302302
public function testAdapterShouldAllowPullingFiltersByFile()
303303
{
304-
$this->adapter->addFilter('Boolean', [1], 'foo');
304+
$this->adapter->addFilter('Boolean', 1, 'foo');
305305
$filters = $this->adapter->getFilters('foo');
306306
$this->assertEquals(1, count($filters));
307307
$filter = array_shift($filters);
@@ -412,34 +412,31 @@ public function testAdapterShouldAllowRetrievingDestinationsForAnArrayOfSpecifie
412412

413413
public function testSettingAndRetrievingOptions()
414414
{
415-
$this->assertEquals(
416-
[
417-
'bar' => ['ignoreNoFile' => false, 'useByteString' => true],
418-
'baz' => ['ignoreNoFile' => false, 'useByteString' => true],
419-
'foo' => ['ignoreNoFile' => false, 'useByteString' => true, 'detectInfos' => true],
420-
'file_0_' => ['ignoreNoFile' => false, 'useByteString' => true],
421-
'file_1_' => ['ignoreNoFile' => false, 'useByteString' => true],
422-
], $this->adapter->getOptions());
415+
$this->assertEquals([
416+
'bar' => ['ignoreNoFile' => false, 'useByteString' => true],
417+
'baz' => ['ignoreNoFile' => false, 'useByteString' => true],
418+
'foo' => ['ignoreNoFile' => false, 'useByteString' => true, 'detectInfos' => true],
419+
'file_0_' => ['ignoreNoFile' => false, 'useByteString' => true],
420+
'file_1_' => ['ignoreNoFile' => false, 'useByteString' => true],
421+
], $this->adapter->getOptions());
423422

424423
$this->adapter->setOptions(['ignoreNoFile' => true]);
425-
$this->assertEquals(
426-
[
427-
'bar' => ['ignoreNoFile' => true, 'useByteString' => true],
428-
'baz' => ['ignoreNoFile' => true, 'useByteString' => true],
429-
'foo' => ['ignoreNoFile' => true, 'useByteString' => true, 'detectInfos' => true],
430-
'file_0_' => ['ignoreNoFile' => true, 'useByteString' => true],
431-
'file_1_' => ['ignoreNoFile' => true, 'useByteString' => true],
432-
], $this->adapter->getOptions());
424+
$this->assertEquals([
425+
'bar' => ['ignoreNoFile' => true, 'useByteString' => true],
426+
'baz' => ['ignoreNoFile' => true, 'useByteString' => true],
427+
'foo' => ['ignoreNoFile' => true, 'useByteString' => true, 'detectInfos' => true],
428+
'file_0_' => ['ignoreNoFile' => true, 'useByteString' => true],
429+
'file_1_' => ['ignoreNoFile' => true, 'useByteString' => true],
430+
], $this->adapter->getOptions());
433431

434432
$this->adapter->setOptions(['ignoreNoFile' => false], 'foo');
435-
$this->assertEquals(
436-
[
437-
'bar' => ['ignoreNoFile' => true, 'useByteString' => true],
438-
'baz' => ['ignoreNoFile' => true, 'useByteString' => true],
439-
'foo' => ['ignoreNoFile' => false, 'useByteString' => true, 'detectInfos' => true],
440-
'file_0_' => ['ignoreNoFile' => true, 'useByteString' => true],
441-
'file_1_' => ['ignoreNoFile' => true, 'useByteString' => true],
442-
], $this->adapter->getOptions());
433+
$this->assertEquals([
434+
'bar' => ['ignoreNoFile' => true, 'useByteString' => true],
435+
'baz' => ['ignoreNoFile' => true, 'useByteString' => true],
436+
'foo' => ['ignoreNoFile' => false, 'useByteString' => true, 'detectInfos' => true],
437+
'file_0_' => ['ignoreNoFile' => true, 'useByteString' => true],
438+
'file_1_' => ['ignoreNoFile' => true, 'useByteString' => true],
439+
], $this->adapter->getOptions());
443440
}
444441

445442
public function testGetAllAdditionalFileInfos()
@@ -601,10 +598,9 @@ public function testTransferDestinationAtNonExistingElement()
601598
public function testSettingMagicFile()
602599
{
603600
$this->adapter->setOptions(['magicFile' => 'test/file']);
604-
$this->assertEquals(
605-
[
606-
'bar' => ['magicFile' => 'test/file', 'ignoreNoFile' => false, 'useByteString' => true],
607-
], $this->adapter->getOptions('bar'));
601+
$this->assertEquals([
602+
'bar' => ['magicFile' => 'test/file', 'ignoreNoFile' => false, 'useByteString' => true],
603+
], $this->adapter->getOptions('bar'));
608604
}
609605

610606
/**

test/Transfer/Adapter/HttpTestMockAdapter.php

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
*/
1919
class HttpTestMockAdapter extends Adapter\Http
2020
{
21-
static $aa = true;
22-
2321
public function __construct()
2422
{
2523
self::$callbackApc = ['ZendTest\File\Transfer\Adapter\HttpTestMockAdapter', 'apcTest'];
@@ -38,21 +36,30 @@ public function isValidParent($files = null)
3836

3937
public static function isApcAvailable()
4038
{
41-
return static::$aa;
39+
return true;
4240
}
4341

4442
public static function apcTest($id)
4543
{
46-
return ['total' => 100, 'current' => 100, 'rate' => 10];
44+
return [
45+
'total' => 100,
46+
'current' => 100,
47+
'rate' => 10,
48+
];
4749
}
4850

4951
public static function uPTest($id)
5052
{
51-
return ['bytes_total' => 100, 'bytes_uploaded' => 100, 'speed_average' => 10, 'cancel_upload' => true];
53+
return [
54+
'bytes_total' => 100,
55+
'bytes_uploaded' => 100,
56+
'speed_average' => 10,
57+
'cancel_upload' => true,
58+
];
5259
}
5360

5461
public function switchApcToUP()
55-
{ static::$aa = false;
62+
{
5663
self::$callbackApc = null;
5764
self::$callbackUploadProgress = ['ZendTest\File\Transfer\Adapter\HttpTestMockAdapter', 'uPTest'];
5865
}

0 commit comments

Comments
 (0)