Errors: _csrf_token [Required.] lors d'un test
Bonjour,
Si j'arrive à tester la création d'un objet j'ai systématiquement cette erreur lors de l'édition.
J'ai simplifié au max mon projet et rien à faire.
mon schéma:
Code:
1 2 3 4 5 6 7 8 9
| country:
columns:
name:
type: string(100)
notnull: true
unique: true
code:
type: string(3)
unique: true |
j'ai une application dans laquelle j'ai un module admin lié a cette table.
Mon test Fonctionnelle de création:
Code:
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
| $browser->info('3 - Post a country')->
info(' 3.1 - Submit a Country')->
get('/country/new')->
with('request')->begin()->
isParameter('module', 'country')->
isParameter('action', 'new')->
end()->
click('Save', array('country' => array(
'name' => 'Turkey',
'code' => 'TUR',
)))->
with('request')->begin()->
isParameter('module', 'country')->
isParameter('action', 'create')->
end()->
with('form')->begin()->
hasErrors(false)->
end()->
with('response')->isRedirected()->
followRedirect()->
with('request')->begin()->
isParameter('module', 'country')->
isParameter('action', 'edit')->
end()->
with('doctrine')->begin()->
check('country', array(
'name' => 'turkey',
'code' => 'TUR',
))->
end()
; |
fonctionne parfaitement.
Mon test d'édition:
Code:
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
|
$france= Doctrine_Core::getTable('country')->findOneByName('France');
$browser->info('4 - edit a country')
->call('/country/'.$france->getId().'/edit', 'GET', array())
->with('request')->begin()
->isParameter('module', 'country')
->isParameter('action', 'edit')
->end()
->with('response')->begin()
->isStatusCode(200)
->end()
->call('/country/'.$france->getId(), 'PUT', array(
'country' => array(
'id' => $france->getId(),
'name' => 'FRANCE',
'code' => 'FR'
),
'sf_format' => 'html',
'id' => $france->getId(),
))
->with('form')->begin()->
hasErrors(false)->
debug()->
end()
->with('request')->begin()
->isParameter('module', 'country')
->isParameter('action', 'update')
->end()
->with('response')->begin()
->isRedirected(1)
->isStatusCode(302)
->end()
->followRedirect()
->with('request')->begin()
->isParameter('module', 'country')
->isParameter('action', 'edit')
->end()
->with('response')->begin()
->isStatusCode(200)
->end()
; |
je me retrouve avec le résultat suivant:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| > 4 - edit a country
# get /country/1/edit
ok 16 - request parameter module is country
ok 17 - request parameter action is edit
ok 18 - status code is 200
# put /country/1
not ok 19 - the submitted form is valid.
# Failed test (.\lib\vendor\symfony\lib\test\sfTesterForm.class.php at line 95)
# got: true
# expected: false
Form debug
Submitted values: array ( 'id' => '1', 'name' => 'FRANCE', 'code' => 'FR',)
Errors: _csrf_token [Required.] |
bien entendu l'édition en dev fonctionne parfaitement