Ah, ok. Now I see what you mean. I looked at it and it seems that you have to
provide a valid hash taken from the session. This would be a way, but in my
opinion tests should not contain more information as a user has with a
browser. When I write a form this form should work the same way in the
browser as in the PHPUnit_TestCase. Don't you think? 

Well, may be I'm totally wrong here. Let's see what the 1.6 final release
will bring. ;-) 
Thank you!


 

Matthew Weier O'Phinney-3 wrote:
> 
> -- Milchbazi <[EMAIL PROTECTED]> wrote
> (on Monday, 04 August 2008, 08:32 AM -0700):
>> thanks for your answer. But I don't actually try to test the hashed
>> element.
>> I just wanna test a form containing it. But whenever a form contains a
>> hash
>> element, I'm unable to process the form. For example the login form:
> 
> I recommended looking at the Hash element tests as they may give you an
> idea of how to write tests against forms that contain a Hash element
> that will work with the controller test cases.
> 
> I'll see if I can find a solution, but you'll likely need to wait until
> after the 1.6 final release.
> 
>>         $form = new Zend_Form(array(
>>             'action'   => '/login',
>>             'method'   => 'post',
>>             'name'      => 'loginForm',
>>             'elements' => array(
>>                 'username' => array('text', array(
>>                     'validators' => array(
>>                         'alnum',
>>                         array('regex', false, array('/^[a-z]/i')),
>>                         array('stringLength', false, array(6, 20))
>>                     ),
>>                     'required' => true,
>>                     'label' => 'Username',
>>                     'filters'  => array('StringToLower'),
>>                  )),
>>                 'password' => array('password', array(
>>                     'validators' => array(
>>                         array('stringLength', false, array(6))
>>                     ),
>>                     'required' => true,
>>                     'label' => 'Password',
>>                 )),
>>                 #'hash' => 'hash',
>>                 'submit' => 'submit',
>>                 )
>>             ));
>> 
>> 
>> 
>>     function testLogin()
>>     {
>>         $this->dispatch('/');
>>         $this->request
>>              ->setMethod('POST')
>>              ->setPost(array(
>>                  'username' => 'username',
>>                  'password' => 'password'
>>              ));
>>         $this->dispatch('/login');
>>         $this->assertModule('ucp');
>>         $this->assertController('auth');
>>         $this->assertAction('login');
>>      $this->assertRedirectTo('/');
>>         $this->dispatch('/');
>>         $this->assertTrue(Zend_Auth::getInstance()->hasIdentity());
>>         $this->assertEquals((int) User::get('userId'), 1);
>>         $this->resetResponse();
>>         $this->request->setPost(array());
>>     }
>> 
>> As soon as I disable the hash element it processes fine. Any ideas?
>> 
>> By the way: Thanks for the great work on ZF - it's really awesome!
>> 
>> 
>> -- 
>> View this message in context:
>> http://www.nabble.com/Zend_Test_PHPUnit-and-hashed-form-elements-tp18796568p18813545.html
>> Sent from the Zend Framework mailing list archive at Nabble.com.
>> 
> 
> -- 
> Matthew Weier O'Phinney
> Software Architect       | [EMAIL PROTECTED]
> Zend Framework           | http://framework.zend.com/
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Zend_Test_PHPUnit-and-hashed-form-elements-tp18796568p18815186.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to