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/2927' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 0 deletions.
48 changes: 48 additions & 0 deletions src/InputFilterAwareTrait.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_InputFilter
*/

namespace Zend\InputFilter;

use Zend\InputFilter\InputFilterInterface;

/**
* @category Zend
* @package Zend_InputFilter
*/
trait InputFilterAwareTrait
{
/**
* @var InputFilterInterface
*/
protected $inputFilter = null;

/**
* Set input filter
*
* @param InputFilterInterface $inputFilter
* @return mixed
*/
public function setInputFilter(InputFilterInterface $inputFilter)
{
$this->inputFilter = $inputFilter;

return $this;
}

/**
* Retrieve input filter
*
* @return InputFilterInterface
*/
public function getInputFilter()
{
return $this->inputFilter;
}
}
46 changes: 46 additions & 0 deletions test/InputFilterAwareTraitTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2012 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
* @package Zend_InputFilter
*/

namespace ZendTest\InputFilter;

use \PHPUnit_Framework_TestCase as TestCase;
use \Zend\InputFilter\InputFilter;

/**
* @requires PHP 5.4
*/
class InputFilterAwareTraitTest extends TestCase
{
public function testSetInputFilter()
{
$object = $this->getObjectForTrait('\Zend\InputFilter\InputFilterAwareTrait');

$this->assertAttributeEquals(null, 'inputFilter', $object);

$inputFilter = new InputFilter;

$object->setInputFilter($inputFilter);

$this->assertAttributeEquals($inputFilter, 'inputFilter', $object);
}

public function testGetInputFilter()
{
$object = $this->getObjectForTrait('\Zend\InputFilter\InputFilterAwareTrait');

$this->assertNull($object->getInputFilter());

$inputFilter = new InputFilter;

$object->setInputFilter($inputFilter);

$this->assertEquals($inputFilter, $object->getInputFilter());
}
}

0 comments on commit 5ef112f

Please sign in to comment.