1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
|
<?php
include(dirname(__FILE__).'/../../bootstrap/functional.php');
$browser = new sfTestFunctional(new sfBrowser());
$test = $browser->test();
$conn = Doctrine::getConnectionByTableName('your_model');
$conn->beginTransaction();
$browser
->call('/', 'GET', array())
->with('request')->begin()
->isParameter('module', 'static')
->isParameter('action', 'index')
->end()
->with('response')->begin()
->isStatusCode(200)
->end()
;
$browser
->call('/guard/login', 'GET', array())
->with('request')->begin()
->isParameter('module', 'sfGuardAuth')
->isParameter('action', 'signin')
->end()
->with('response')->begin()
->isStatusCode(401)
->end()
;
$browser
->call('/guard/login', 'POST', array (
'signin' =>
array (
'username' => 'admin',
'password' => 'admin',
),
))
/* ->get('/guard/login')
->click('alt or value of submit here', array (
'signin' =>
array (
'username' => 'admin',
'password' => 'admin',
),
)) */
->with('request')->begin()
->isParameter('module', 'sfGuardAuth')
->isParameter('action', 'signin')
->end()
;
$browser
->with('response')->begin()
->isRedirected(1)
->isStatusCode(302)
->end()
->followRedirect()
;
$browser
->with('request')->begin()
->isParameter('module', 'static')
->isParameter('action', 'index')
->end()
->with('response')->begin()
->isStatusCode(200)
->end()
;
$conn->rollback(); |
Partager