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

Commit

Permalink
[ZF2-512][#2276] Added unit tests
Browse files Browse the repository at this point in the history
- Test serialization/deserialization of filter chains and validator
  chains
  • Loading branch information
weierophinney committed Sep 20, 2012
1 parent 5ed5ee3 commit e3ba6ea
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tests/ZendTest/Filter/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
12 changes: 12 additions & 0 deletions tests/ZendTest/Validator/ValidatorChainTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,4 +273,16 @@ public function testCanAttachMultipleValidatorsOfTheSameTypeAsDiscreteInstances(
}
$this->assertTrue($found);
}


public function testCanSerializeValidatorChain()
{
$this->populateValidatorChain();
$serialized = serialize($this->validator);

$unserialized = unserialize($serialized);
$this->assertInstanceOf('Zend\Validator\ValidatorChain', $unserialized);
$this->assertEquals(2, count($unserialized));
$this->assertFalse($unserialized->isValid(''));
}
}

0 comments on commit e3ba6ea

Please sign in to comment.