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

Commit

Permalink
Merge branch 'hotfix/zf2-512'
Browse files Browse the repository at this point in the history
  • Loading branch information
weierophinney committed Sep 20, 2012
2 parents a2da824 + 5de983b commit 49921e6
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
15 changes: 13 additions & 2 deletions src/FilterChain.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,11 +228,22 @@ public function filter($value)

/**
* Clone filters
*
* @return void
*/
public function __clone()
{
$this->filters = clone $this->filters;
}

/**
* Prepare filter chain for serialization
*
* Plugin manager (property 'plugins') cannot
* be serialized. On wakeup the property remains unset
* and next invokation to getPluginManager() sets
* the default plugin manager instance (FilterPluginManager).
*/
public function __sleep()
{
return array('filters');
}
}
15 changes: 15 additions & 0 deletions test/FilterChainTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,21 @@ public function testClone()

$this->assertCount(0, $clone);
}

public function testCanSerializeFilterChain()
{
$chain = new FilterChain();
$chain->attach(new LowerCase())
->attach(new StripUpperCase());
$serialized = serialize($chain);

$unserialized = unserialize($serialized);
$this->assertInstanceOf('Zend\Filter\FilterChain', $unserialized);
$this->assertEquals(2, count($unserialized));
$value = 'AbC';
$valueExpected = 'abc';
$this->assertEquals($valueExpected, $unserialized->filter($value));
}
}


Expand Down

0 comments on commit 49921e6

Please sign in to comment.