Return to Snippet

Revision: 23328
at February 4, 2010 08:36 by cburyta


Initial Code
// First, place this in your functional bootstrap file
// (optional, but helps keep things organized)

sfConfig::set('FUNC_ADMIN_USER', 'admin');
sfConfig::set('FUNC_ADMIN_PASS', 'admin');

// In the functional test, this line logs in a user using vars from the bootstrap file
// It first logs in a user, then checks that the user has access to the page we are testing

$browser->

  // go to login page
  get('/appointments')->

  // make sure we did not get access
  with('response')->begin()->
    isStatusCode(401)->
  end()->

  // log in
  with('form')->begin()->
    click('sign in', array(
      'signin' => array(
        'username' => sfConfig::get('FUNC_ADMIN_USER'),
        'password' => sfConfig::get('FUNC_ADMIN_PASS'))))->
  end()->
  
  // try again to access the appointment page (should have been block the first time
  get('/appointments')->

  // make sure we have access now
  with('response')->begin()->
    isStatusCode(200)->
  end()
;

Initial URL


Initial Description
This is a basic example from a Symfony 1.4 project on how to simulate a user login. It involves just starting the test with a click() action on the default page.

Initial Title
User Login Symfony 1.4 Functional Test

Initial Tags


Initial Language
PHP