Priti
Priti

Reputation: 11

Functional Testcases for Form using Symfony

I write Simple code for contqact Form,which contain fields name, email and message. I want to write test cases for it to check user enter fields value are match with the expected value or not. But i m not getting user enter value while I execute 'contactTest.php' file using command "./symfony test:functional frontend contact" Code:

enter code here  
<?php
include('/home/APP/test/bootstrap/functional.php');
$browser = new sfTestFunctional(new sfBrowser());
$browser->
    get('/Contact/thankyou')->
        with('request')->begin()->
        isParameter('module', 'Contact')->
        isParameter('action', 'thankyou')->
        end();
$browser->
get('/Contact/index')->
    click('Submit', array(
    'name'      => 'Test',
    'email'        => 'not.an.email',
    'message'   => 'message'
    ))->

isRedirected()->
followRedirect()->
with('response')->checkElement('#content ul li','Testa');
get('/Contact/thankyou', array('name' => 'Test'));
?>

Please help me to write testcase for checking user enter value in the form and expected value. And also suggest how to run & test?

Upvotes: 1

Views: 359

Answers (1)

Pierre
Pierre

Reputation: 26

It looks to me that you forgot to provide your form object. Can you share your form template?

You probably want something like this :

get('/Contact/index')->
click('Submit', array(
    contact => array(
        'name'      => 'Test',
        'email'        => 'not.an.email',
        'message'   => 'message'
    )
))->

Upvotes: 1

Related Questions