Skip to content
Browse files

Merge branch 'master' of git://github.com/zendframework/zf2

  • Loading branch information...
2 parents cf35376 + 897ef52 commit 8aea678b2268e9b177b8e2569918fa95c8c4c4f5 @sgehrig sgehrig committed Feb 3, 2011
View
16 library/Zend/Filter/FilterChain.php
@@ -84,7 +84,7 @@ public function setOptions($options)
$callback = isset($spec['callback']) ? $spec['callback'] : false;
$priority = isset($spec['priority']) ? $spec['priority'] : static::DEFAULT_PRIORITY;
if ($callback) {
- $this->connect($callback, $priority);
+ $this->attach($callback, $priority);
}
}
break;
@@ -94,7 +94,7 @@ public function setOptions($options)
$options = isset($spec['options']) ? $spec['options'] : array();
$priority = isset($spec['priority']) ? $spec['priority'] : static::DEFAULT_PRIORITY;
if ($name) {
- $this->connectByName($name, $options, $priority);
+ $this->attachByName($name, $options, $priority);
}
}
break;
@@ -144,13 +144,13 @@ public function broker($name = null, $options = array())
}
/**
- * Connect a filter to the chain
+ * Attach a filter to the chain
*
* @param callback|Filter $callback A Filter implementation or valid PHP callback
* @param int $priority Priority at which to enqueue filter; defaults to 1000 (higher executes earlier)
* @return FilterChain
*/
- public function connect($callback, $priority = self::DEFAULT_PRIORITY)
+ public function attach($callback, $priority = self::DEFAULT_PRIORITY)
{
if (!is_callable($callback)) {
if (!$callback instanceof Filter) {
@@ -166,17 +166,17 @@ public function connect($callback, $priority = self::DEFAULT_PRIORITY)
}
/**
- * Connect a filter to the chain using a short name
+ * Attach a filter to the chain using a short name
*
- * Retrieves the filter from the attached plugin broker, and then calls connect()
+ * Retrieves the filter from the attached plugin broker, and then calls attach()
* with the retrieved instance.
*
* @param string $name
* @param mixed $options
* @param int $priority Priority at which to enqueue filter; defaults to 1000 (higher executes earlier)
* @return FilterChain
*/
- public function connectByName($name, $options = array(), $priority = self::DEFAULT_PRIORITY)
+ public function attachByName($name, $options = array(), $priority = self::DEFAULT_PRIORITY)
{
if (!is_array($options)) {
$options = (array) $options;
@@ -186,7 +186,7 @@ public function connectByName($name, $options = array(), $priority = self::DEFAU
}
}
$filter = $this->broker($name, $options);
- return $this->connect($filter, $priority);
+ return $this->attach($filter, $priority);
}
/**
View
2 library/Zend/Filter/InputFilter.php
@@ -605,7 +605,7 @@ protected function _filter()
if (is_string($filter) || is_array($filter)) {
$filter = $this->_getFilter($filter);
}
- $filterRule[self::FILTER_CHAIN]->addFilter($filter);
+ $filterRule[self::FILTER_CHAIN]->attach($filter);
}
}
View
16 tests/Zend/Filter/FilterChainTest.php
@@ -44,8 +44,8 @@ public function testEmptyFilterChainReturnsOriginalValue()
public function testFiltersAreExecutedInFifoOrder()
{
$chain = new FilterChain();
- $chain->connect(new LowerCase())
- ->connect(new StripUpperCase());
+ $chain->attach(new LowerCase())
+ ->attach(new StripUpperCase());
$value = 'AbC';
$valueExpected = 'abc';
$this->assertEquals($valueExpected, $chain->filter($value));
@@ -54,8 +54,8 @@ public function testFiltersAreExecutedInFifoOrder()
public function testFiltersAreExecutedAccordingToPriority()
{
$chain = new FilterChain();
- $chain->connect(new StripUpperCase())
- ->connect(new LowerCase, 100);
+ $chain->attach(new StripUpperCase())
+ ->attach(new LowerCase, 100);
$value = 'AbC';
$valueExpected = 'b';
$this->assertEquals($valueExpected, $chain->filter($value));
@@ -64,7 +64,7 @@ public function testFiltersAreExecutedAccordingToPriority()
public function testAllowsConnectingArbitraryCallbacks()
{
$chain = new FilterChain();
- $chain->connect(function($value) {
+ $chain->attach(function($value) {
return strtolower($value);
});
$value = 'AbC';
@@ -74,9 +74,9 @@ public function testAllowsConnectingArbitraryCallbacks()
public function testAllowsConnectingViaClassShortName()
{
$chain = new FilterChain();
- $chain->connectByName('string_trim', array('encoding' => 'utf-8'), 100)
- ->connectByName('strip_tags')
- ->connectByName('string_to_lower', array('encoding' => 'utf-8'), 900);
+ $chain->attachByName('string_trim', array('encoding' => 'utf-8'), 100)
+ ->attachByName('strip_tags')
+ ->attachByName('string_to_lower', array('encoding' => 'utf-8'), 900);
$value = '<a name="foo"> ABC </a>';
$valueExpected = 'abc';
$this->assertEquals($valueExpected, $chain->filter($value));
View
92 tests/Zend/Filter/InputTest.php
@@ -149,7 +149,7 @@ public function testFilterMultiValue()
$this->assertTrue($input->hasValid(), 'Expected hasValid() to return true');
$f1 = $input->field1;
- $this->assertType('array', $f1);
+ $this->assertInternalType('array', $f1);
$this->assertEquals(array('foo', 'bar', 'baz'), $f1);
}
@@ -188,15 +188,15 @@ public function testValidatorSingleInvalid()
$this->assertFalse($input->hasValid(), 'Expected hasValid() to return false');
$messages = $input->getMessages();
- $this->assertType('array', $messages);
+ $this->assertInternalType('array', $messages);
$this->assertEquals(array('month'), array_keys($messages));
- $this->assertType('array', $messages['month']);
+ $this->assertInternalType('array', $messages['month']);
$this->assertEquals("'6abc ' must contain only digits", current($messages['month']));
$errors = $input->getErrors();
- $this->assertType('array', $errors);
+ $this->assertInternalType('array', $errors);
$this->assertEquals(array('month'), array_keys($errors));
- $this->assertType('array', $errors['month']);
+ $this->assertInternalType('array', $errors['month']);
$this->assertEquals("notDigits", $errors['month'][0]);
}
@@ -248,7 +248,7 @@ public function testValidatorDeclareByArray()
$this->assertEquals('6', $month);
$messages = $input->getMessages();
- $this->assertType('array', $messages);
+ $this->assertInternalType('array', $messages);
$this->assertEquals(array('month2'), array_keys($messages));
$this->assertEquals("'13' is not between '1' and '12', inclusively", current($messages['month2']));
}
@@ -274,10 +274,10 @@ public function testValidatorChain()
$this->assertTrue($input->hasValid(), 'Expected hasValid() to return true');
$messages = $input->getMessages();
- $this->assertType('array', $messages);
+ $this->assertInternalType('array', $messages);
$this->assertEquals(array('field2', 'field3'), array_keys($messages));
- $this->assertType('array', $messages['field2']);
- $this->assertType('array', $messages['field3']);
+ $this->assertInternalType('array', $messages['field2']);
+ $this->assertInternalType('array', $messages['field3']);
$this->assertEquals("'abc123' must contain only digits",
current($messages['field2']));
$this->assertEquals("'150' is not between '1' and '100', inclusively",
@@ -307,10 +307,10 @@ public function testValidatorInvalidFieldInMultipleRules()
$this->assertFalse($input->hasValid(), 'Expected hasValid() to return false');
$messages = $input->getMessages();
- $this->assertType('array', $messages);
+ $this->assertInternalType('array', $messages);
$this->assertEquals(array('field2a', 'field2b'), array_keys($messages));
- $this->assertType('array', $messages['field2a']);
- $this->assertType('array', $messages['field2b']);
+ $this->assertInternalType('array', $messages['field2a']);
+ $this->assertInternalType('array', $messages['field2b']);
$this->assertEquals("'abc123' must contain only digits",
current($messages['field2a']));
$this->assertEquals("'abc123' is not between '1' and '100', inclusively",
@@ -356,7 +356,7 @@ public function testValidatorMultiValue()
$this->assertTrue($input->hasValid(), 'Expected hasValid() to return true');
$messages = $input->getMessages();
- $this->assertType('array', $messages);
+ $this->assertInternalType('array', $messages);
$this->assertEquals(array('field2'), array_keys($messages));
$this->assertEquals("'123' contains non alphabetic characters",
current($messages['field2']));
@@ -392,7 +392,7 @@ public function testValidatorMultiField()
$this->assertTrue($input->hasValid(), 'Expected hasValid() to return true');
$messages = $input->getMessages();
- $this->assertType('array', $messages);
+ $this->assertInternalType('array', $messages);
$this->assertEquals(array('rule2'), array_keys($messages));
$this->assertEquals("Not all strings in the argument are equal",
current($messages['rule2']));
@@ -438,7 +438,7 @@ public function testValidatorMultiFieldAllowEmptyProcessing()
$this->assertTrue($input->hasValid(), 'Expected hasValid() to return true');
$messages = $input->getMessages();
- $this->assertType('array', $messages);
+ $this->assertInternalType('array', $messages);
$this->assertEquals(array('rule2', 'rule3'), array_keys($messages));
$this->assertEquals(array('isEmpty' => "You must give a non-empty value for field 'password3'"),
$messages['rule2']);
@@ -472,7 +472,7 @@ public function testValidatorBreakChain()
$this->assertFalse($input->hasValid(), 'Expected hasValid() to return false');
$messages = $input->getMessages();
- $this->assertType('array', $messages);
+ $this->assertInternalType('array', $messages);
$this->assertEquals(array('field1', 'field2'), array_keys($messages));
$this->assertEquals(
$messageUserDefined,
@@ -512,7 +512,7 @@ public function testValidatorAllowEmpty()
$this->assertNull($input->field1);
$this->assertNotNull($input->field2);
$messages = $input->getMessages();
- $this->assertType('array', $messages);
+ $this->assertInternalType('array', $messages);
$this->assertEquals(array('field1'), array_keys($messages));
$this->assertEquals("You must give a non-empty value for field 'field1'", current($messages['field1']));
}
@@ -540,7 +540,7 @@ public function testValidatorAllowEmptyWithOtherValidatersProcessing()
$this->assertFalse($input->hasValid(), 'Expected hasValid() to return true');
$messages = $input->getMessages();
- $this->assertType('array', $messages);
+ $this->assertInternalType('array', $messages);
$this->assertEquals(array('field1'), array_keys($messages));
$this->assertEquals("You must give a non-empty value for field 'field1'", current($messages['field1']));
}
@@ -609,7 +609,7 @@ public function testValidatorAllowEmptyNoValidatorChain()
$this->assertTrue($input->hasValid(), 'Expected hasValid() to return true');
$messages = $input->getMessages();
- $this->assertType('array', $messages);
+ $this->assertInternalType('array', $messages);
$this->assertEquals(array('nick'), array_keys($messages));
$this->assertEquals(1, count($messages['nick']));
}
@@ -639,9 +639,9 @@ public function testValidatorAllowEmptySetNotEmptyMessage()
$this->assertNull($input->field1);
$messages = $input->getMessages();
- $this->assertType('array', $messages);
+ $this->assertInternalType('array', $messages);
$this->assertEquals(array('field1Rule'), array_keys($messages));
- $this->assertType('array', $messages['field1Rule']);
+ $this->assertInternalType('array', $messages['field1Rule']);
$this->assertEquals("You cannot give an empty value for field 'field1', according to rule 'field1Rule'", current($messages['field1Rule']));
}
@@ -666,7 +666,7 @@ public function testValidatorDefault()
$this->assertTrue($input->hasValid(), 'Expected hasValid() to return true');
$missing = $input->getMissing();
- $this->assertType('array', $missing);
+ $this->assertInternalType('array', $missing);
// make sure field5 and field7 are not counted as missing
$this->assertEquals(array('field1', 'field3'), array_keys($missing));
@@ -699,7 +699,7 @@ public function testValidatorMissingDefaults()
$this->assertFalse($input->hasValid(), 'Expected hasValid() to return false');
$missing = $input->getMissing();
- $this->assertType('array', $missing);
+ $this->assertInternalType('array', $missing);
$this->assertEquals(array('rule1'), array_keys($missing));
$this->assertEquals(array("Field 'field2' is required by rule 'rule1', but the field is missing"), $missing['rule1']);
}
@@ -755,9 +755,9 @@ public function testValidatorNotAllowEmpty()
$this->assertTrue($input->hasValid(), 'Expected hasValid() to return true');
$messages = $input->getMessages();
- $this->assertType('array', $messages);
+ $this->assertInternalType('array', $messages);
$this->assertEquals(array('field2', 'field3'), array_keys($messages));
- $this->assertType('array', $messages['field2']);
+ $this->assertInternalType('array', $messages['field2']);
$this->assertEquals("You must give a non-empty value for field 'field2'", current($messages['field2']));
}
@@ -779,7 +779,7 @@ public function testValidatorMessagesSingle()
$this->assertFalse($input->hasValid(), 'Expected hasValid() to return false');
$messages = $input->getMessages();
- $this->assertType('array', $messages);
+ $this->assertInternalType('array', $messages);
$this->assertEquals(array('month'), array_keys($messages));
$this->assertEquals(1, count($messages['month']));
$this->assertEquals($digitsMesg, current($messages['month']));
@@ -808,7 +808,7 @@ public function testValidatorMessagesMultiple()
$this->assertFalse($input->hasValid(), 'Expected hasValid() to return false');
$messages = $input->getMessages();
- $this->assertType('array', $messages);
+ $this->assertInternalType('array', $messages);
$this->assertEquals(array('month'), array_keys($messages));
$this->assertEquals(2, count($messages['month']));
$this->assertEquals($digitsMesg, $messages['month']['notDigits']);
@@ -838,7 +838,7 @@ public function testValidatorMessagesFieldsMultiple()
$this->assertFalse($input->hasValid(), 'Expected hasValid() to return false');
$messages = $input->getMessages();
- $this->assertType('array', $messages);
+ $this->assertInternalType('array', $messages);
$this->assertEquals(array('field1'), array_keys($messages));
$this->assertEquals(3, count($messages['field1']));
$this->assertEquals($digitsMesg, $messages['field1']['notDigits']);
@@ -866,7 +866,7 @@ public function testValidatorMessagesIntIndex()
$this->assertFalse($input->hasValid(), 'Expected hasValid() to return false');
$messages = $input->getMessages();
- $this->assertType('array', $messages);
+ $this->assertInternalType('array', $messages);
$this->assertEquals(array('month'), array_keys($messages));
$this->assertEquals(2, count($messages['month']));
$this->assertEquals("'13abc' must contain only digits", current($messages['month']));
@@ -893,7 +893,7 @@ public function testValidatorMessagesSingleWithKeys()
$this->assertFalse($input->hasValid(), 'Expected hasValid() to return false');
$messages = $input->getMessages();
- $this->assertType('array', $messages);
+ $this->assertInternalType('array', $messages);
$this->assertEquals(array('month'), array_keys($messages));
$this->assertEquals(1, count($messages['month']));
}
@@ -921,7 +921,7 @@ public function testValidatorMessagesMultipleWithKeys()
$this->assertFalse($input->hasValid(), 'Expected hasValid() to return false');
$messages = $input->getMessages();
- $this->assertType('array', $messages);
+ $this->assertInternalType('array', $messages);
$this->assertEquals(array('month'), array_keys($messages));
$this->assertEquals(2, count($messages['month']));
// $this->assertEquals($digitsMesg, $messages['month'][0]);
@@ -951,7 +951,7 @@ public function testValidatorMessagesMixedWithKeys()
$this->assertFalse($input->hasValid(), 'Expected hasValid() to return false');
$messages = $input->getMessages();
- $this->assertType('array', $messages);
+ $this->assertInternalType('array', $messages);
$this->assertEquals(array('month'), array_keys($messages));
$this->assertEquals(2, count($messages['month']));
// $this->assertEquals($digitsMesg, $messages['month'][0]);
@@ -1009,7 +1009,7 @@ public function testValidatorGetMissing()
$this->assertFalse($input->hasValid(), 'Expected hasValid() to return false');
$missing = $input->getMissing();
- $this->assertType('array', $missing);
+ $this->assertInternalType('array', $missing);
$this->assertEquals(array('month'), array_keys($missing));
$this->assertEquals("Field 'month' is required by rule 'month', but the field is missing", $missing['month'][0]);
}
@@ -1035,7 +1035,7 @@ public function testValidatorSetMissingMessage()
$this->assertFalse($input->hasValid(), 'Expected hasValid() to return false');
$missing = $input->getMissing();
- $this->assertType('array', $missing);
+ $this->assertInternalType('array', $missing);
$this->assertEquals(array('monthRule'), array_keys($missing));
$this->assertEquals("I looked for month but I did not find it; it is required by rule monthRule", $missing['monthRule'][0]);
}
@@ -1072,7 +1072,7 @@ public function testValidatorGetUnknown()
$this->assertFalse($input->hasValid(), 'Expected hasValid() to return false');
$unknown = $input->getUnknown();
- $this->assertType('array', $unknown);
+ $this->assertInternalType('array', $unknown);
$this->assertThat($unknown, $this->arrayHasKey('unknown'));
}
@@ -1096,11 +1096,11 @@ public function testValidatorGetInvalid()
$invalid = $input->getInvalid();
$missing = $input->getMissing();
- $this->assertType('array', $messages);
+ $this->assertInternalType('array', $messages);
$this->assertEquals(array('month', 'field2'), array_keys($messages));
- $this->assertType('array', $invalid);
+ $this->assertInternalType('array', $invalid);
$this->assertEquals(array('month'), array_keys($invalid));
- $this->assertType('array', $missing);
+ $this->assertInternalType('array', $missing);
$this->assertEquals(array('field2'), array_keys($missing));
$this->assertEquals(array_merge($invalid, $missing), $messages);
}
@@ -1143,11 +1143,11 @@ public function testGetPluginBroker()
$input = new InputFilter(null, null);
$broker = $input->getPluginBroker(InputFilter::VALIDATOR);
- $this->assertType('Zend\Validator\ValidatorBroker', $broker,
+ $this->assertInstanceOf('Zend\Validator\ValidatorBroker', $broker,
'Expected object of type Zend\Validator\ValidatorBroker, got ' , get_class($broker));
$broker = $input->getPluginBroker(InputFilter::FILTER);
- $this->assertType('Zend\Filter\FilterBroker', $broker,
+ $this->assertInstanceOf('Zend\Filter\FilterBroker', $broker,
'Expected object of type Zend\Filter\FilterBroker, got ' , get_class($broker));
$this->setExpectedException('Zend\Filter\Exception', 'Invalid type');
@@ -1274,7 +1274,7 @@ public function testOptionBreakChain()
$this->assertFalse($input->hasValid(), 'Expected hasValid() to return false');
$messages = $input->getMessages();
- $this->assertType('array', $messages);
+ $this->assertInternalType('array', $messages);
$this->assertEquals(array('field1'), array_keys($messages));
$this->assertEquals(1, count($messages['field1']), 'Expected rule for field1 to break 1 validator');
$this->assertEquals("'150' is not between '1' and '100', inclusively",
@@ -1327,7 +1327,7 @@ public function testBrokerOptions()
$this->assertEquals('123', (string) $input->field3);
$messages = $input->getMessages();
- $this->assertType('array', $messages);
+ $this->assertInternalType('array', $messages);
$this->assertThat($messages, $this->arrayHasKey('field1'));
$this->assertEquals("'abc' must contain only digits", current($messages['field1']));
}
@@ -1353,7 +1353,7 @@ public function testOptionPresence()
$this->assertTrue($input->hasValid(), 'Expected hasValid() to return true');
$missing = $input->getMissing();
- $this->assertType('array', $missing);
+ $this->assertInternalType('array', $missing);
$this->assertEquals(array('field2'), array_keys($missing));
$this->assertEquals("Field 'field2' is required by rule 'field2', but the field is missing", $missing['field2'][0]);
}
@@ -1418,7 +1418,7 @@ public function testGetEscapedMultiValue()
$this->assertTrue($input->hasValid(), 'Expected hasValid() to return true');
$multi = $input->getEscaped('multiSelect');
- $this->assertType('array', $multi);
+ $this->assertInternalType('array', $multi);
$this->assertEquals(3, count($multi));
$this->assertEquals(array('C&amp;H', 'B&amp;O', 'AT&amp;T'), $multi);
}
@@ -1738,7 +1738,7 @@ public function testTranslateNotEmptyMessages()
$this->assertTrue($input->hasMissing(), 'Expected hasMissing() to return true');
$missing = $input->getMissing();
- $this->assertType('array', $missing);
+ $this->assertInternalType('array', $missing);
$this->assertEquals(array('rule1'), array_keys($missing));
$this->assertEquals(array("Still missing"), $missing['rule1']);
}
@@ -1768,7 +1768,7 @@ public function testTranslateNotEmptyMessagesByUsingRegistry()
$this->assertFalse($input->hasValid(), 'Expected hasValid() to return false');
$missing = $input->getMissing();
- $this->assertType('array', $missing);
+ $this->assertInternalType('array', $missing);
$this->assertEquals(array('rule1'), array_keys($missing));
$this->assertEquals(array("Still missing"), $missing['rule1']);
}

0 comments on commit 8aea678

Please sign in to comment.
Something went wrong with that request. Please try again.