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

Commit

Permalink
Updated and reduced dependencies
Browse files Browse the repository at this point in the history
- Updated PHP to `^5.5 || ^7.0`
- Updated zend-stdlib to `^2.7 || ^3.0`
- Updated zend-crypt to `^2.6`
- Updated zend-uri to `^2.5`
- Added pear/archive_tar (used by the Compress\Tar filter; previously we relied
  on a PEAR installation, but PEAR packages are now published to packagist)
- Removed zend-config, zend-i18n, and zend-loader dependencies.
  - Replaced references to `Zend\Config\Config` with `ArrayObject`, as it's
    equivalent for purposes of what's being tested (`Traversable`
    configuration).
  - Replaced i18n assets used in testing with local test asset classes.
  - zend-loader is no longer necessary with the addition of pear/archive_tar.

zend-stdlib is installed at 2.7.4, due to the fact that zend-uri uses
zend-validator, which is still pinned to v2 of the service manager and v2 of
zend-stdlib.

All tests continue to pass.
  • Loading branch information
weierophinney committed Feb 4, 2016
1 parent a26f0cd commit 10a9d1e
Show file tree
Hide file tree
Showing 11 changed files with 126 additions and 142 deletions.
22 changes: 10 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,22 @@
}
},
"require": {
"php": ">=5.5",
"zendframework/zend-stdlib": "~2.5"
"php": "^5.5 || ^7.0",
"zendframework/zend-stdlib": "^2.7 || ^3.0"
},
"require-dev": {
"zendframework/zend-config": "~2.5",
"zendframework/zend-crypt": "dev-develop as 2.7",
"zendframework/zend-i18n": "~2.5",
"zendframework/zend-loader": "~2.5",
"zendframework/zend-servicemanager": "^2.7.3 || ^3.0",
"zendframework/zend-uri": "~2.5",
"pear/archive_tar": "^1.4",
"zendframework/zend-crypt": "^2.6",
"zendframework/zend-servicemanager": "^2.7.5 || ^3.0.3",
"zendframework/zend-uri": "^2.5",
"fabpot/php-cs-fixer": "1.7.*",
"phpunit/PHPUnit": "~4.0"
},
"suggest": {
"zendframework/zend-crypt": "Zend\\Crypt component",
"zendframework/zend-i18n": "Zend\\I18n component",
"zendframework/zend-servicemanager": "Zend\\ServiceManager component",
"zendframework/zend-uri": "Zend\\Uri component for UriNormalize filter"
"zendframework/zend-crypt": "Zend\\Crypt component, for encryption filters",
"zendframework/zend-i18n": "Zend\\I18n component for filters depending on i18n functionality",
"zendframework/zend-servicemanager": "Zend\\ServiceManager component, for using the filter chain functionality",
"zendframework/zend-uri": "Zend\\Uri component, for the UriNormalize filter"
},
"minimum-stability": "dev",
"prefer-stable": true,
Expand Down
8 changes: 4 additions & 4 deletions src/FilterPluginManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -294,10 +294,10 @@ class FilterPluginManager extends AbstractPluginManager

'zendfiltertoint' => InvokableFactory::class,
'zendfiltertonull' => InvokableFactory::class,
'zendinfilteralnum' => InvokableFactory::class,
'zendinfilteralpha' => InvokableFactory::class,
'zendinviewhelpernumberformat' => InvokableFactory::class,
'zendinfilternumberparse' => InvokableFactory::class,
'zendi18nfilteralnum' => InvokableFactory::class,
'zendi18nfilteralpha' => InvokableFactory::class,
'zendi18nviewhelpernumberformat' => InvokableFactory::class,
'zendi18nfilternumberparse' => InvokableFactory::class,
'zendfilterbasename' => InvokableFactory::class,
'zendfilterblacklist' => InvokableFactory::class,
'zendfilterboolean' => InvokableFactory::class,
Expand Down
10 changes: 1 addition & 9 deletions test/Compress/TarTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

namespace ZendTest\Filter\Compress;

use Archive_Tar;
use Zend\Filter\Compress\Tar as TarCompression;
use Zend\Loader\StandardAutoloader;

/**
* @group Zend_Filter
Expand All @@ -21,14 +21,6 @@ class TarTest extends \PHPUnit_Framework_TestCase

public function setUp()
{
if (!class_exists('Archive_Tar')) {
$autoloader = new StandardAutoloader();
$autoloader->setFallbackAutoloader(true);
if (!$autoloader->autoload('Archive_Tar')) {
$this->markTestSkipped('This filter needs PEARs Archive_Tar');
}
}

$this->tmp = sprintf('%s/%s', sys_get_temp_dir(), uniqid('zfilter'));
mkdir($this->tmp, 0775, true);
}
Expand Down
50 changes: 16 additions & 34 deletions test/FilterChainTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace ZendTest\Filter;

use Zend\Filter\AbstractFilter;
use ArrayIterator;
use Zend\Filter\FilterChain;
use Zend\Filter\PregReplace;
use Zend\Filter\StringToLower;
Expand All @@ -31,8 +31,8 @@ public function testEmptyFilterChainReturnsOriginalValue()
public function testFiltersAreExecutedInFifoOrder()
{
$chain = new FilterChain();
$chain->attach(new LowerCase())
->attach(new StripUpperCase());
$chain->attach(new TestAsset\LowerCase())
->attach(new TestAsset\StripUpperCase());
$value = 'AbC';
$valueExpected = 'abc';
$this->assertEquals($valueExpected, $chain->filter($value));
Expand All @@ -41,8 +41,8 @@ public function testFiltersAreExecutedInFifoOrder()
public function testFiltersAreExecutedAccordingToPriority()
{
$chain = new FilterChain();
$chain->attach(new StripUpperCase())
->attach(new LowerCase, 100);
$chain->attach(new TestAsset\StripUpperCase())
->attach(new TestAsset\LowerCase, 100);
$value = 'AbC';
$valueExpected = 'b';
$this->assertEquals($valueExpected, $chain->filter($value));
Expand Down Expand Up @@ -96,7 +96,7 @@ public function testAllowsConfiguringFiltersViaConstructor()
public function testConfigurationAllowsTraversableObjects()
{
$config = $this->getChainConfig();
$config = new \ArrayIterator($config);
$config = new ArrayIterator($config);
$chain = new FilterChain($config);
$value = '<a name="foo"> abc </a>';
$valueExpected = 'ABC';
Expand Down Expand Up @@ -180,8 +180,8 @@ public function testClone()
public function testCanSerializeFilterChain()
{
$chain = new FilterChain();
$chain->attach(new LowerCase())
->attach(new StripUpperCase());
$chain->attach(new TestAsset\LowerCase())
->attach(new TestAsset\StripUpperCase());
$serialized = serialize($chain);

$unserialized = unserialize($serialized);
Expand All @@ -198,47 +198,29 @@ public function testMergingTwoFilterChainsKeepFiltersPriority()
$valueExpected = 'abc';

$chain = new FilterChain();
$chain->attach(new StripUpperCase())
->attach(new LowerCase(), 1001);
$chain->attach(new TestAsset\StripUpperCase())
->attach(new TestAsset\LowerCase(), 1001);
$this->assertEquals($valueExpected, $chain->filter($value));

$chain = new FilterChain();
$chain->attach(new LowerCase(), 1001)
->attach(new StripUpperCase());
$chain->attach(new TestAsset\LowerCase(), 1001)
->attach(new TestAsset\StripUpperCase());
$this->assertEquals($valueExpected, $chain->filter($value));

$chain = new FilterChain();
$chain->attach(new LowerCase(), 1001);
$chain->attach(new TestAsset\LowerCase(), 1001);
$chainToMerge = new FilterChain();
$chainToMerge->attach(new StripUpperCase());
$chainToMerge->attach(new TestAsset\StripUpperCase());
$chain->merge($chainToMerge);
$this->assertEquals(2, $chain->count());
$this->assertEquals($valueExpected, $chain->filter($value));

$chain = new FilterChain();
$chain->attach(new StripUpperCase());
$chain->attach(new TestAsset\StripUpperCase());
$chainToMerge = new FilterChain();
$chainToMerge->attach(new LowerCase(), 1001);
$chainToMerge->attach(new TestAsset\LowerCase(), 1001);
$chain->merge($chainToMerge);
$this->assertEquals(2, $chain->count());
$this->assertEquals($valueExpected, $chain->filter($value));
}
}


class LowerCase extends AbstractFilter
{
public function filter($value)
{
return strtolower($value);
}
}


class StripUpperCase extends AbstractFilter
{
public function filter($value)
{
return preg_replace('/[A-Z]/', '', $value);
}
}
7 changes: 6 additions & 1 deletion test/HtmlEntitiesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

namespace ZendTest\Filter;

use ArrayObject;
use Zend\Filter\HtmlEntities as HtmlEntitiesFilter;
use Zend\Filter\Exception;
use Zend\Stdlib\ErrorHandler;
Expand Down Expand Up @@ -132,12 +133,16 @@ public function testFluentInterface()
}

/**
* This test uses an ArrayObject in place of a Zend\Config\Config instance;
* they two are interchangeable in this scenario, as HtmlEntitiesFilter is
* checking for arrays or Traversable instances.
*
* @group ZF-8995
*/
public function testConfigObject()
{
$options = ['quotestyle' => 5, 'encoding' => 'ISO-8859-1'];
$config = new \Zend\Config\Config($options);
$config = new ArrayObject($options);

$filter = new HtmlEntitiesFilter(
$config
Expand Down
63 changes: 25 additions & 38 deletions test/InflectorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@

namespace ZendTest\Filter;

use ArrayObject;
use Zend\Filter\FilterPluginManager;
use Zend\Filter\Inflector as InflectorFilter;
use Zend\Filter\PregReplace;
use Zend\Filter\StringToLower;
use Zend\Filter\StringToUpper;
use Zend\Filter\Word\CamelCaseToDash;
use Zend\Filter\Word\CamelCaseToUnderscore;
use Zend\I18n\Filter\Alpha;
use Zend\ServiceManager\ServiceManager;

/**
Expand Down Expand Up @@ -116,13 +116,9 @@ public function testSetFilterRuleWithFilterObjectCreatesRuleEntryWithFilterObjec

public function testAddFilterRuleAppendsRuleEntries()
{
if (!extension_loaded('intl')) {
$this->markTestSkipped('ext/intl not enabled');
}

$rules = $this->inflector->getRules();
$this->assertEquals(0, count($rules));
$this->inflector->setFilterRule('controller', [PregReplace::class, Alpha::class]);
$this->inflector->setFilterRule('controller', [PregReplace::class, TestAsset\Alpha::class]);
$rules = $this->inflector->getRules('controller');
$this->assertEquals(2, count($rules));
$this->assertInstanceOf('Zend\Filter\FilterInterface', $rules[0]);
Expand Down Expand Up @@ -165,14 +161,11 @@ public function testSetStaticRuleReferenceAllowsUpdatingRuleByReference()

public function testAddRulesCreatesAppropriateRuleEntries()
{
if (!extension_loaded('intl')) {
$this->markTestSkipped('ext/intl not enabled');
}

$rules = $this->inflector->getRules();
$this->assertEquals(0, count($rules));
$this->inflector->addRules([
':controller' => [PregReplace::class, Alpha::class],
':controller' => [PregReplace::class, TestAsset\Alpha::class],
'suffix' => 'phtml',
]);
$rules = $this->inflector->getRules();
Expand All @@ -183,15 +176,11 @@ public function testAddRulesCreatesAppropriateRuleEntries()

public function testSetRulesCreatesAppropriateRuleEntries()
{
if (!extension_loaded('intl')) {
$this->markTestSkipped('ext/intl not enabled');
}

$this->inflector->setStaticRule('some-rules', 'some-value');
$rules = $this->inflector->getRules();
$this->assertEquals(1, count($rules));
$this->inflector->setRules([
':controller' => [PregReplace::class, Alpha::class],
':controller' => [PregReplace::class, TestAsset\Alpha::class],
'suffix' => 'phtml',
]);
$rules = $this->inflector->getRules();
Expand All @@ -202,11 +191,7 @@ public function testSetRulesCreatesAppropriateRuleEntries()

public function testGetRule()
{
if (!extension_loaded('intl')) {
$this->markTestSkipped('ext/intl not enabled');
}

$this->inflector->setFilterRule(':controller', [Alpha::class, StringToLower::class]);
$this->inflector->setFilterRule(':controller', [TestAsset\Alpha::class, StringToLower::class]);
$this->assertInstanceOf('Zend\Filter\StringToLower', $this->inflector->getRule('controller', 1));
$this->assertFalse($this->inflector->getRule('controller', 2));
}
Expand Down Expand Up @@ -327,11 +312,18 @@ public function getOptions()
return $options;
}

/**
* This method returns an ArrayObject instance in place of a
* Zend\Config\Config instance; the two are interchangeable, as inflectors
* consume the more general array or Traversable types.
*
* @return \Traversable
*/
public function getConfig()
{
$options = $this->getOptions();

return new \Zend\Config\Config($options);
return new ArrayObject($options);
}

protected function _testOptions($inflector)
Expand All @@ -356,13 +348,6 @@ protected function _testOptions($inflector)
$this->assertEquals($options['rules']['suffix'], $rules['suffix']);
}

public function testPassingConfigObjectToConstructorSetsStateAndRules()
{
$config = $this->getConfig();
$inflector = new InflectorFilter($config);
$this->_testOptions($inflector);
}

public function testSetConfigSetsStateAndRules()
{
$config = $this->getConfig();
Expand Down Expand Up @@ -395,8 +380,14 @@ public function testCheckInflectorWithPregBackreferenceLikeParts()
'controller' => 'FooBar',
'action' => 'MooToo'
]);
$this->assertEquals($filtered,
'C:\htdocs\public\cache\00\01\42\app\modules' . DIRECTORY_SEPARATOR . 'foo-bar' . DIRECTORY_SEPARATOR . 'Moo-Too.phtml');
$this->assertEquals(
$filtered,
'C:\htdocs\public\cache\00\01\42\app\modules'
. DIRECTORY_SEPARATOR
. 'foo-bar'
. DIRECTORY_SEPARATOR
. 'Moo-Too.phtml'
);
}

/**
Expand Down Expand Up @@ -426,21 +417,17 @@ public function testNoInflectableTarget()
*/
public function testAddFilterRuleMultipleTimes()
{
if (!extension_loaded('intl')) {
$this->markTestSkipped('ext/intl not enabled');
}

$rules = $this->inflector->getRules();
$this->assertEquals(0, count($rules));
$this->inflector->setFilterRule('controller', PregReplace::class);
$rules = $this->inflector->getRules('controller');
$this->assertEquals(1, count($rules));
$this->inflector->addFilterRule('controller', [Alpha::class, StringToLower::class]);
$this->inflector->addFilterRule('controller', [TestAsset\Alpha::class, StringToLower::class]);
$rules = $this->inflector->getRules('controller');
$this->assertEquals(3, count($rules));
$this->_context = StringToLower::class;
$this->inflector->setStaticRuleReference('context', $this->_context);
$this->inflector->addFilterRule('controller', [Alpha::class, StringToLower::class]);
$this->inflector->addFilterRule('controller', [TestAsset\Alpha::class, StringToLower::class]);
$rules = $this->inflector->getRules('controller');
$this->assertEquals(5, count($rules));
}
Expand Down Expand Up @@ -468,7 +455,7 @@ public function testPassingArrayToSetConfigSetsStateAndRules()
/**
* @group ZF-8997
*/
public function testPassingZendConfigObjectToConstructorSetsStateAndRules()
public function testPassingConfigObjectToConstructorSetsStateAndRules()
{
$config = $this->getConfig();
$inflector = new InflectorFilter($config);
Expand All @@ -478,7 +465,7 @@ public function testPassingZendConfigObjectToConstructorSetsStateAndRules()
/**
* @group ZF-8997
*/
public function testPassingZendConfigObjectToSetConfigSetsStateAndRules()
public function testPassingConfigObjectToSetConfigSetsStateAndRules()
{
$config = $this->getConfig();
$inflector = new InflectorFilter();
Expand Down
Loading

0 comments on commit 10a9d1e

Please sign in to comment.