$b->get('http://www.symfony-project.com/trac/wiki/sfUJSPlugin'); $t->like($b->getResponseText(), '/learn more about the unobtrusive approach/', 'follows 302 redirect after a GET'); $b = new myTestWebBrowser(array(), $adapter); $b->call($askeet_params['url'] . '/index.php/login', 'POST', array('nickname' => $askeet_params['login'], 'password' => $askeet_params['password'])); //$t->like($b->getResponseText(), '/url='.preg_quote($askeet_params['url'], '/').'\/index\.php/', 'does NOT follow a 302 redirect after a POST'); $t->like($b->getResponseText(), '/featured questions/', 'follows 302 redirect after POST ****** DESPITE THE HTTP SPEC ******'); $t->is($b->getRequestMethod(), 'GET', 'request method is changed to GET after POST for 302 redirect ***** DESPITE THE HTTP SPEC *****'); $t->todo('request method is changed to GET after POST for 303 redirect'); /***********/ /* Cookies */ /***********/ $t->diag('Cookies'); if ($adapter == 'sfCurlAdapter') { $b = new sfWebBrowser(array(), $adapter, array('cookies' => true, 'cookies_file' => $cookies_file, 'cookies_dir' => $cookies_dir)); $b->call($askeet_params['url'] . '/login', 'POST', array('nickname' => $askeet_params['login'], 'password' => $askeet_params['password'])); $t->like($b->getResponseBody(), '/' . $askeet_params['login'] . ' profile/', 'Cookies can be added to the request'); rmdir($cookies_dir); rmdir(dirname(__FILE__) . '/../data'); } else { $t->todo('Cookies can be added to the request (sfCurlAdapter only for now)'); } /****************/ /* File Uploads */ /****************/ $t->diag('File uploads'); if ($adapter == 'sfCurlAdapter') { $b->post($dump_headers_url, array('test_file' => realpath(__FILE__))); $t->like($b->getResponseText(), '/\\[test_file\\]/', 'The request can upload a file'); } else { $t->todo('The request can upload a file (sfCurlAdapter only for now)'); }
$t->is($b->getResponseText(), '', 'restart() reinitializes the response'); $t->diag('redirects'); $b = new sfWebBrowser(array(), $adapter); $b->get('http://www.symfony-project.com/trac/wiki/sfUJSPlugin'); $t->like($b->getResponseText(), '/learn more about the unobtrusive approach/', 'follows 302 redirect after a GET'); $b = new myTestWebBrowser(array(), $adapter); $b->call($askeet_params['url'] . '/index.php/login', 'POST', array('nickname' => $askeet_params['login'], 'password' => $askeet_params['password'])); //$t->like($b->getResponseText(), '/url='.preg_quote($askeet_params['url'], '/').'\/index\.php/', 'does NOT follow a 302 redirect after a POST'); $t->like($b->getResponseText(), '/featured questions/', 'follows 302 redirect after POST ****** DESPITE THE HTTP SPEC ******'); $t->is($b->getRequestMethod(), 'GET', 'request method is changed to GET after POST for 302 redirect ***** DESPITE THE HTTP SPEC *****'); $t->todo('request method is changed to GET after POST for 303 redirect'); if ($adapter == 'sfCurlAdapter') { $t->diag('cookies'); $b = new sfWebBrowser(array(), $adapter, array('cookies' => true, 'cookies_file' => $cookies_file, 'cookies_dir' => $cookies_dir)); $b->call($askeet_params['url'] . '/login', 'POST', array('nickname' => $askeet_params['login'], 'password' => $askeet_params['password'])); $t->like($b->getResponseBody(), '/' . $askeet_params['login'] . ' profile/', 'Understands cookies'); rmdir($cookies_dir); rmdir(dirname(__FILE__) . '/../data'); $t->diag('file uploads'); $b->post($dump_headers_url, array('test_file' => realpath(__FILE__))); $t->like($b->getResponseText(), '/\\[test_file\\]/', 'uploads a file'); } else { $t->todo('Understands cookies'); $t->todo('Uploads a file'); } $t->diag('make XML exchanges to test Content-Type'); $url = 'http://www.abundanttech.com/WebServices/Population/population.asmx'; $headers = array('Soapaction' => 'http://www.abundanttech.com/WebServices/Population/getWorldPopulation', 'Content-Type' => 'text/xml'); $requestBody = '<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"><soap:Body><getWorldPopulation xmlns="http://www.abundanttech.com/WebServices/Population" /></soap:Body></soap:Envelope>'; $b = new sfWebBrowser(array(), $adapter); $b->post($url, $requestBody, $headers);