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

Commit

Permalink
Merge branch 'feature/i18n-filters-upd' of https://github.com/denixpo…
Browse files Browse the repository at this point in the history
…rt/zf2 into feature/i18n-filters
  • Loading branch information
Showing 1 changed file with 34 additions and 28 deletions.
62 changes: 34 additions & 28 deletions test/Transfer/Adapter/AbstractTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@

namespace ZendTest\File\Transfer\Adapter;

use Zend\File,
Zend\Filter,
Zend\Filter\Word,
Zend\Loader,
Zend\Validator,
Zend\Validator\File as FileValidator;
use Zend\File;
use Zend\Filter;
use Zend\Filter\Word;
use Zend\Loader;
use Zend\Validator;
use Zend\Validator\File as FileValidator;

/**
* Test class for Zend\File\Transfer\Adapter\AbstractAdapter
Expand Down Expand Up @@ -63,7 +63,8 @@ public function tearDown()

public function testAdapterShouldThrowExceptionWhenRetrievingPluginLoaderOfInvalidType()
{
$this->setExpectedException('Zend\File\Transfer\Exception\InvalidArgumentException', 'Invalid type "BOGUS" provided to getPluginLoader');
$this->setExpectedException('Zend\File\Transfer\Exception\InvalidArgumentException',
'Invalid type "BOGUS" provided to getPluginLoader');
$this->adapter->getPluginLoader('bogus');
}

Expand All @@ -84,7 +85,8 @@ public function testAddingInvalidPluginLoaderTypeToAdapterShouldRaiseException()
{
$loader = new Loader\PrefixPathLoader();

$this->setExpectedException('Zend\File\Transfer\Exception\InvalidArgumentException', 'Invalid type "BOGUS" provided to setPluginLoader');
$this->setExpectedException('Zend\File\Transfer\Exception\InvalidArgumentException',
'Invalid type "BOGUS" provided to setPluginLoader');
$this->adapter->setPluginLoader($loader, 'bogus');
}

Expand All @@ -110,7 +112,8 @@ public function testPassingNoTypeWhenAddingPrefixPathToAdapterShouldGeneratePath

public function testPassingInvalidTypeWhenAddingPrefixPathToAdapterShouldThrowException()
{
$this->setExpectedException('Zend\File\Transfer\Exception\InvalidArgumentException', 'Invalid type "BOGUS" provided to getPluginLoader');
$this->setExpectedException('Zend\File\Transfer\Exception\InvalidArgumentException',
'Invalid type "BOGUS" provided to getPluginLoader');
$this->adapter->addPrefixPath('Foo', 'Foo', 'bogus');
}

Expand Down Expand Up @@ -176,7 +179,10 @@ public function testAdapterShouldAllowAddingMultipleValidatorsAtOnceUsingBothIns
$validators = array(
'count' => array('min' => 1, 'max' => 1),
'Exists' => 'C:\temp',
array('validator' => 'Upload', 'options' => array(realpath(__FILE__))),
array(
'validator' => 'Upload',
'options' => array(realpath(__FILE__))
),
new FileValidator\Extension('jpg'),
);
$this->adapter->addValidators($validators);
Expand All @@ -197,16 +203,16 @@ public function testAdapterShouldAllowAddingMultipleValidatorsAtOnceUsingBothIns

public function testGetValidatorShouldReturnNullWhenNoMatchingIdentifierExists()
{
$this->assertNull($this->adapter->getValidator('Alpha'));
$this->assertNull($this->adapter->getValidator('Between'));
}

public function testAdapterShouldAllowPullingValidatorsByFile()
{
$this->adapter->addValidator('Alpha', false, false, 'foo');
$this->adapter->addValidator('Between', false, false, 'foo');
$validators = $this->adapter->getValidators('foo');
$this->assertEquals(1, count($validators));
$validator = array_shift($validators);
$this->assertTrue($validator instanceof Validator\Alpha);
$this->assertTrue($validator instanceof Validator\Between);
}

public function testCallingSetValidatorsOnAdapterShouldOverwriteExistingValidators()
Expand Down Expand Up @@ -266,9 +272,9 @@ public function testRemovingNonexistentValidatorShouldDoNothing()
{
$this->testAdapterShouldAllowAddingMultipleValidatorsAtOnceUsingBothInstancesAndPluginLoader();
$validators = $this->adapter->getValidators();
$this->assertFalse($this->adapter->hasValidator('Alpha'));
$this->adapter->removeValidator('Alpha');
$this->assertFalse($this->adapter->hasValidator('Alpha'));
$this->assertFalse($this->adapter->hasValidator('Between'));
$this->adapter->removeValidator('Between');
$this->assertFalse($this->adapter->hasValidator('Between'));
$test = $this->adapter->getValidators();
$this->assertSame($validators, $test);
}
Expand Down Expand Up @@ -376,8 +382,8 @@ public function testAdapterShouldAllowAddingMultipleFiltersAtOnceUsingBothInstan
$filters = array(
'Word\SeparatorToCamelCase' => array('separator' => ' '),
array(
'filter' => 'Alpha',
'allow_white_space' => true
'filter' => 'Boolean',
'casting' => true
),
new Filter\BaseName(),
);
Expand All @@ -388,32 +394,32 @@ public function testAdapterShouldAllowAddingMultipleFiltersAtOnceUsingBothInstan
$count = array_shift($test);
$this->assertTrue($count instanceof Word\SeparatorToCamelCase);
$size = array_shift($test);
$this->assertTrue($size instanceof Filter\Alpha);
$this->assertTrue($size instanceof Filter\Boolean);
$ext = array_shift($test);
$orig = array_pop($filters);
$this->assertSame($orig, $ext);
}

public function testGetFilterShouldReturnNullWhenNoMatchingIdentifierExists()
{
$this->assertNull($this->adapter->getFilter('Alpha'));
$this->assertNull($this->adapter->getFilter('Boolean'));
}

public function testAdapterShouldAllowPullingFiltersByFile()
{
$this->adapter->addFilter('Alpha', false, 'foo');
$this->adapter->addFilter('Boolean', 1, 'foo');
$filters = $this->adapter->getFilters('foo');
$this->assertEquals(1, count($filters));
$filter = array_shift($filters);
$this->assertTrue($filter instanceof Filter\Alpha);
$this->assertTrue($filter instanceof Filter\Boolean);
}

public function testCallingSetFiltersOnAdapterShouldOverwriteExistingFilters()
{
$this->testAdapterShouldAllowAddingMultipleFiltersAtOnceUsingBothInstancesAndPluginLoader();
$filters = array(
new Filter\StringToUpper(),
new Filter\Alpha(),
new Filter\Boolean(),
);
$this->adapter->setFilters($filters);
$test = $this->adapter->getFilters();
Expand All @@ -430,8 +436,8 @@ public function testAdapterShouldAllowRetrievingFilterInstancesByClassName()
public function testAdapterShouldAllowRetrievingFilterInstancesByPluginName()
{
$this->testAdapterShouldAllowAddingMultipleFiltersAtOnceUsingBothInstancesAndPluginLoader();
$count = $this->adapter->getFilter('Alpha');
$this->assertTrue($count instanceof Filter\Alpha);
$count = $this->adapter->getFilter('Boolean');
$this->assertTrue($count instanceof Filter\Boolean);
}

public function testAdapterShouldAllowRetrievingAllFiltersAtOnce()
Expand All @@ -456,9 +462,9 @@ public function testAdapterShouldAllowRemovingFilterInstancesByClassName()
public function testAdapterShouldAllowRemovingFilterInstancesByPluginName()
{
$this->testAdapterShouldAllowAddingMultipleFiltersAtOnceUsingBothInstancesAndPluginLoader();
$this->assertTrue($this->adapter->hasFilter('Alpha'));
$this->adapter->removeFilter('Alpha');
$this->assertFalse($this->adapter->hasFilter('Alpha'));
$this->assertTrue($this->adapter->hasFilter('Boolean'));
$this->adapter->removeFilter('Boolean');
$this->assertFalse($this->adapter->hasFilter('Boolean'));
}

public function testRemovingNonexistentFilterShouldDoNothing()
Expand Down

0 comments on commit 71d7aeb

Please sign in to comment.