Hej,
Aby móc przetestować jakaś funkcjonalność, która jest ukryta za formularzem logowania musisz po prostu najpierw się zalogować, czyli wysłać odpowiedni request z danymi do logowania:
[url
="./Pobierz-Plik-183233.html"]pobierz
[/url
], [url
="Plaintext-183233.html"]plaintext
[/url
] [list
=1
][*] $browser->click('Zaloguj', [url
="http://www.php.net/array"]array[/url
]('login' => [url
="http://www.php.net/array"]array[/url
]([*] 'username' => 'admin',[*] 'password' => 'admin'[*] )));[*][/list
][PHP
] [url
="./Pobierz-Plik-183233.html"]pobierz
[/url
], [url
="Plaintext-183233.html"]plaintext
[/url
]
Najlepiej utworzyć sobie odpowiednią metodę do tego np.:
[PHP
] [url
="./Pobierz-Plik-183234.html"]pobierz
[/url
], [url
="Plaintext-183234.html"]plaintext
[/url
] [list
=1
][*] class myTestBrowser
extends sfTestBrowser
[*] {[*] public function login
()[*] {[*] $this->click('Zaloguj', [url
="http://www.php.net/array"]array[/url
]('login' => [url
="http://www.php.net/array"]array[/url
]([*] 'username' => 'admin',[*] 'password' => 'admin'[*] )));[*] }[*] }[*][/list
][PHP
] [url
="./Pobierz-Plik-183234.html"]pobierz
[/url
], [url
="Plaintext-183234.html"]plaintext
[/url
]
Oczywiście trzeba wcześniej zadbać o dodanie użytkownika testowego przed rozpoczęciem testów.
Mam nadzieję, że nic nie pokręciłem...
Pozdrawiam.<!--QuoteEnd--></div><!--QuoteEEnd-->
teraz wyskakuje: " The DOM is not accessible because the browser response content type is not HTML. "
mam taki kod w pliku testowym:
[php]
include(dirname(__FILE__).'/../../bootstrap/functional.php');
$browser = new sfTestFunctional(new sfBrowser());
$browser->
get('/')->
click('zaloguj', array('signin' => array('username' => 'username', 'password' => 'password)))-> with('request')->begin()->
isParameter('module', 'index')->
isParameter('action', 'index')->
end()->
with('response')->begin()->
isStatusCode(200)->
checkElement('body', '!/This is a temporary page/')->
end()
;
a wynik tego jest taki:
# get /
# get /login
not ok 1 - request parameter module is index
# Failed test (/usr/share/php5/PEAR/symfony/test/sfTesterRequest.class.php at line 48)
# got: 'sfGuardAuth'
# expected: 'index'
not ok 2 - request parameter action is index
# Failed test (/usr/share/php5/PEAR/symfony/test/sfTesterRequest.class.php at line 48)
# got: 'signin'
# expected: 'index'
not ok 3 - status code is 200
# Failed test (/usr/share/php5/PEAR/symfony/test/sfTesterResponse.class.php at line 257)
# got: 401
# expected: 200
ok 4 - response selector body does not match regex /This is a temporary page/
1..4
Looks like you failed 3 tests of 4.
Naprawde nie wiem jak przekazac to do tego formularza..