Hi All,
On this page:
http://zf2.readthedocs.org/en/latest/user-guide/forms-and-actions.html
Its defines a filter for a form field:
...
$inputFilter->add(array(
'name' => 'id',
'required' => true,
'filters' => array(
array('name' => 'Int'),
),
));
...
The problem is with the required = true attribute, it makes the
testAddActionRedirectsAfterValidPost() test method fail, when going through
the unit testing tutorial (
http://zf2.readthedocs.org/en/latest/tutorials/unittesting.html).
Method shown here:
public function testAddActionRedirectsAfterValidPost()
{
$albumTableMock = $this->getMockBuilder('Album\Model\AlbumTable')
->disableOriginalConstructor()
->getMock();
$albumTableMock->expects($this->once())
->method('saveAlbum')
->will($this->returnValue(null));
$serviceManager = $this->getApplicationServiceLocator();
$serviceManager->setAllowOverride(true);
$serviceManager->setService('Album\Model\AlbumTable', $albumTableMock);
$postData = array(
'title' => 'Led Zeppelin III',
'artist' => 'Led Zeppelin',
);
$this->dispatch('/album/add', 'POST', $postData);
$this->assertResponseStatusCode(302);
$this->assertRedirectTo('/album');
}
I think there are a few ways to sort this I just don't know the best way?
I'm happy to submit a PR but wanted to get everyones thoughts.
Thanks
Daniel