acceptance_test.php 63KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653
  1. <?php
  2. // $Id: acceptance_test.php 1808 2008-09-11 19:18:02Z pp11 $
  3. require_once(dirname(__FILE__) . '/../autorun.php');
  4. require_once(dirname(__FILE__) . '/../compatibility.php');
  5. require_once(dirname(__FILE__) . '/../browser.php');
  6. require_once(dirname(__FILE__) . '/../web_tester.php');
  7. require_once(dirname(__FILE__) . '/../unit_tester.php');
  8. class SimpleTestAcceptanceTest extends WebTestCase {
  9. static function samples() {
  10. return 'http://www.lastcraft.com/test/';
  11. }
  12. }
  13. class TestOfLiveBrowser extends UnitTestCase {
  14. function samples() {
  15. return SimpleTestAcceptanceTest::samples();
  16. }
  17. function testGet() {
  18. $browser = new SimpleBrowser();
  19. $browser->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
  20. $this->assertTrue($browser->get($this->samples() . 'network_confirm.php'));
  21. $this->assertPattern('/target for the SimpleTest/', $browser->getContent());
  22. $this->assertPattern('/Request method.*?<dd>GET<\/dd>/', $browser->getContent());
  23. $this->assertEqual($browser->getTitle(), 'Simple test target file');
  24. $this->assertEqual($browser->getResponseCode(), 200);
  25. $this->assertEqual($browser->getMimeType(), 'text/html');
  26. }
  27. function testPost() {
  28. $browser = new SimpleBrowser();
  29. $browser->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
  30. $this->assertTrue($browser->post($this->samples() . 'network_confirm.php'));
  31. $this->assertPattern('/target for the SimpleTest/', $browser->getContent());
  32. $this->assertPattern('/Request method.*?<dd>POST<\/dd>/', $browser->getContent());
  33. }
  34. function testAbsoluteLinkFollowing() {
  35. $browser = new SimpleBrowser();
  36. $browser->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
  37. $browser->get($this->samples() . 'link_confirm.php');
  38. $this->assertTrue($browser->clickLink('Absolute'));
  39. $this->assertPattern('/target for the SimpleTest/', $browser->getContent());
  40. }
  41. function testRelativeEncodedeLinkFollowing() {
  42. $browser = new SimpleBrowser();
  43. $browser->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
  44. $browser->get($this->samples() . 'link_confirm.php');
  45. $this->assertTrue($browser->clickLink("m�rc�l kiek'eboe"));
  46. $this->assertPattern('/target for the SimpleTest/', $browser->getContent());
  47. }
  48. function testRelativeLinkFollowing() {
  49. $browser = new SimpleBrowser();
  50. $browser->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
  51. $browser->get($this->samples() . 'link_confirm.php');
  52. $this->assertTrue($browser->clickLink('Relative'));
  53. $this->assertPattern('/target for the SimpleTest/', $browser->getContent());
  54. }
  55. function testUnifiedClickLinkClicking() {
  56. $browser = new SimpleBrowser();
  57. $browser->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
  58. $browser->get($this->samples() . 'link_confirm.php');
  59. $this->assertTrue($browser->click('Relative'));
  60. $this->assertPattern('/target for the SimpleTest/', $browser->getContent());
  61. }
  62. function testIdLinkFollowing() {
  63. $browser = new SimpleBrowser();
  64. $browser->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
  65. $browser->get($this->samples() . 'link_confirm.php');
  66. $this->assertTrue($browser->clickLinkById(1));
  67. $this->assertPattern('/target for the SimpleTest/', $browser->getContent());
  68. }
  69. function testCookieReading() {
  70. $browser = new SimpleBrowser();
  71. $browser->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
  72. $browser->get($this->samples() . 'set_cookies.php');
  73. $this->assertEqual($browser->getCurrentCookieValue('session_cookie'), 'A');
  74. $this->assertEqual($browser->getCurrentCookieValue('short_cookie'), 'B');
  75. $this->assertEqual($browser->getCurrentCookieValue('day_cookie'), 'C');
  76. }
  77. function testSimpleSubmit() {
  78. $browser = new SimpleBrowser();
  79. $browser->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
  80. $browser->get($this->samples() . 'form.html');
  81. $this->assertTrue($browser->clickSubmit('Go!'));
  82. $this->assertPattern('/Request method.*?<dd>POST<\/dd>/', $browser->getContent());
  83. $this->assertPattern('/go=\[Go!\]/', $browser->getContent());
  84. }
  85. function testUnifiedClickCanSubmit() {
  86. $browser = new SimpleBrowser();
  87. $browser->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
  88. $browser->get($this->samples() . 'form.html');
  89. $this->assertTrue($browser->click('Go!'));
  90. $this->assertPattern('/go=\[Go!\]/', $browser->getContent());
  91. }
  92. }
  93. class TestOfLocalFileBrowser extends UnitTestCase {
  94. function samples() {
  95. return 'file://'.dirname(__FILE__).'/site/';
  96. }
  97. function testGet() {
  98. $browser = new SimpleBrowser();
  99. $browser->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
  100. $this->assertTrue($browser->get($this->samples() . 'file.html'));
  101. $this->assertPattern('/Link to SimpleTest/', $browser->getContent());
  102. $this->assertEqual($browser->getTitle(), 'Link to SimpleTest');
  103. $this->assertFalse($browser->getResponseCode());
  104. $this->assertEqual($browser->getMimeType(), '');
  105. }
  106. }
  107. class TestRadioFields extends SimpleTestAcceptanceTest {
  108. function testSetFieldAsInteger() {
  109. $this->get($this->samples() . 'form_with_radio_buttons.html');
  110. $this->assertTrue($this->setField('tested_field', 2));
  111. $this->clickSubmitByName('send');
  112. $this->assertEqual($this->getUrl(), $this->samples() . 'form_with_radio_buttons.html?tested_field=2&send=click+me');
  113. }
  114. function testSetFieldAsString() {
  115. $this->get($this->samples() . 'form_with_radio_buttons.html');
  116. $this->assertTrue($this->setField('tested_field', '2'));
  117. $this->clickSubmitByName('send');
  118. $this->assertEqual($this->getUrl(), $this->samples() . 'form_with_radio_buttons.html?tested_field=2&send=click+me');
  119. }
  120. }
  121. class TestOfLiveFetching extends SimpleTestAcceptanceTest {
  122. function setUp() {
  123. $this->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
  124. }
  125. function testFormWithArrayBasedInputs() {
  126. $this->get($this->samples() . 'form_with_array_based_inputs.php');
  127. $this->setField('value[]', '3', '1');
  128. $this->setField('value[]', '4', '2');
  129. $this->clickSubmit('Go');
  130. $this->assertPattern('/QUERY_STRING : value%5B%5D=3&value%5B%5D=4&submit=Go/');
  131. }
  132. function testFormWithQuotedValues() {
  133. $this->get($this->samples() . 'form_with_quoted_values.php');
  134. $this->assertField('a', 'default');
  135. $this->assertFieldById('text_field', 'default');
  136. $this->clickSubmit('Go');
  137. $this->assertPattern('/a=default&submit=Go/');
  138. }
  139. function testGet() {
  140. $this->assertTrue($this->get($this->samples() . 'network_confirm.php'));
  141. $this->assertEqual($this->getUrl(), $this->samples() . 'network_confirm.php');
  142. $this->assertText('target for the SimpleTest');
  143. $this->assertPattern('/Request method.*?<dd>GET<\/dd>/');
  144. $this->assertTitle('Simple test target file');
  145. $this->assertTitle(new PatternExpectation('/target file/'));
  146. $this->assertResponse(200);
  147. $this->assertMime('text/html');
  148. $this->assertHeader('connection', 'close');
  149. $this->assertHeader('connection', new PatternExpectation('/los/'));
  150. }
  151. function testSlowGet() {
  152. $this->assertTrue($this->get($this->samples() . 'slow_page.php'));
  153. }
  154. function testTimedOutGet() {
  155. $this->setConnectionTimeout(1);
  156. $this->ignoreErrors();
  157. $this->assertFalse($this->get($this->samples() . 'slow_page.php'));
  158. }
  159. function testPost() {
  160. $this->assertTrue($this->post($this->samples() . 'network_confirm.php'));
  161. $this->assertText('target for the SimpleTest');
  162. $this->assertPattern('/Request method.*?<dd>POST<\/dd>/');
  163. }
  164. function testGetWithData() {
  165. $this->get($this->samples() . 'network_confirm.php', array("a" => "aaa"));
  166. $this->assertPattern('/Request method.*?<dd>GET<\/dd>/');
  167. $this->assertText('a=[aaa]');
  168. }
  169. function testPostWithData() {
  170. $this->post($this->samples() . 'network_confirm.php', array("a" => "aaa"));
  171. $this->assertPattern('/Request method.*?<dd>POST<\/dd>/');
  172. $this->assertText('a=[aaa]');
  173. }
  174. function testPostWithRecursiveData() {
  175. $this->post($this->samples() . 'network_confirm.php', array("a" => "aaa"));
  176. $this->assertPattern('/Request method.*?<dd>POST<\/dd>/');
  177. $this->assertText('a=[aaa]');
  178. $this->post($this->samples() . 'network_confirm.php', array("a[aa]" => "aaa"));
  179. $this->assertPattern('/Request method.*?<dd>POST<\/dd>/');
  180. $this->assertText('a=[aa=[aaa]]');
  181. $this->post($this->samples() . 'network_confirm.php', array("a[aa][aaa]" => "aaaa"));
  182. $this->assertPattern('/Request method.*?<dd>POST<\/dd>/');
  183. $this->assertText('a=[aa=[aaa=[aaaa]]]');
  184. $this->post($this->samples() . 'network_confirm.php', array("a" => array("aa" => "aaa")));
  185. $this->assertPattern('/Request method.*?<dd>POST<\/dd>/');
  186. $this->assertText('a=[aa=[aaa]]');
  187. $this->post($this->samples() . 'network_confirm.php', array("a" => array("aa" => array("aaa" => "aaaa"))));
  188. $this->assertPattern('/Request method.*?<dd>POST<\/dd>/');
  189. $this->assertText('a=[aa=[aaa=[aaaa]]]');
  190. }
  191. function testRelativeGet() {
  192. $this->get($this->samples() . 'link_confirm.php');
  193. $this->assertTrue($this->get('network_confirm.php'));
  194. $this->assertText('target for the SimpleTest');
  195. }
  196. function testRelativePost() {
  197. $this->post($this->samples() . 'link_confirm.php');
  198. $this->assertTrue($this->post('network_confirm.php'));
  199. $this->assertText('target for the SimpleTest');
  200. }
  201. }
  202. class TestOfLinkFollowing extends SimpleTestAcceptanceTest {
  203. function setUp() {
  204. $this->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
  205. }
  206. function testLinkAssertions() {
  207. $this->get($this->samples() . 'link_confirm.php');
  208. $this->assertLink('Absolute', $this->samples() . 'network_confirm.php');
  209. $this->assertLink('Absolute', new PatternExpectation('/confirm/'));
  210. $this->assertClickable('Absolute');
  211. }
  212. function testAbsoluteLinkFollowing() {
  213. $this->get($this->samples() . 'link_confirm.php');
  214. $this->assertTrue($this->clickLink('Absolute'));
  215. $this->assertText('target for the SimpleTest');
  216. }
  217. function testRelativeLinkFollowing() {
  218. $this->get($this->samples() . 'link_confirm.php');
  219. $this->assertTrue($this->clickLink('Relative'));
  220. $this->assertText('target for the SimpleTest');
  221. }
  222. function testLinkIdFollowing() {
  223. $this->get($this->samples() . 'link_confirm.php');
  224. $this->assertLinkById(1);
  225. $this->assertTrue($this->clickLinkById(1));
  226. $this->assertText('target for the SimpleTest');
  227. }
  228. function testAbsoluteUrlBehavesAbsolutely() {
  229. $this->get($this->samples() . 'link_confirm.php');
  230. $this->get('http://www.lastcraft.com');
  231. $this->assertText('No guarantee of quality is given or even intended');
  232. }
  233. function testRelativeUrlRespectsBaseTag() {
  234. $this->get($this->samples() . 'base_tag/base_link.html');
  235. $this->click('Back to test pages');
  236. $this->assertTitle('Simple test target file');
  237. }
  238. }
  239. class TestOfLivePageLinkingWithMinimalLinks extends SimpleTestAcceptanceTest {
  240. function setUp() {
  241. $this->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
  242. }
  243. function testClickToExplicitelyNamedSelfReturns() {
  244. $this->get($this->samples() . 'front_controller_style/a_page.php');
  245. $this->assertEqual($this->getUrl(), $this->samples() . 'front_controller_style/a_page.php');
  246. $this->assertTitle('Simple test page with links');
  247. $this->assertLink('Self');
  248. $this->clickLink('Self');
  249. $this->assertTitle('Simple test page with links');
  250. }
  251. function testClickToMissingPageReturnsToSamePage() {
  252. $this->get($this->samples() . 'front_controller_style/a_page.php');
  253. $this->clickLink('No page');
  254. $this->assertTitle('Simple test page with links');
  255. $this->assertText('[action=no_page]');
  256. }
  257. function testClickToBareActionReturnsToSamePage() {
  258. $this->get($this->samples() . 'front_controller_style/a_page.php');
  259. $this->clickLink('Bare action');
  260. $this->assertTitle('Simple test page with links');
  261. $this->assertText('[action=]');
  262. }
  263. function testClickToSingleQuestionMarkReturnsToSamePage() {
  264. $this->get($this->samples() . 'front_controller_style/a_page.php');
  265. $this->clickLink('Empty query');
  266. $this->assertTitle('Simple test page with links');
  267. }
  268. function testClickToEmptyStringReturnsToSamePage() {
  269. $this->get($this->samples() . 'front_controller_style/a_page.php');
  270. $this->clickLink('Empty link');
  271. $this->assertTitle('Simple test page with links');
  272. }
  273. function testClickToSingleDotGoesToCurrentDirectory() {
  274. $this->get($this->samples() . 'front_controller_style/a_page.php');
  275. $this->clickLink('Current directory');
  276. $this->assertTitle(
  277. 'Simple test front controller',
  278. '%s -> index.php needs to be set as a default web server home page');
  279. }
  280. function testClickBackADirectoryLevel() {
  281. $this->get($this->samples() . 'front_controller_style/');
  282. $this->clickLink('Down one');
  283. $this->assertPattern('|Index of .*?/test|i');
  284. }
  285. }
  286. class TestOfLiveFrontControllerEmulation extends SimpleTestAcceptanceTest {
  287. function setUp() {
  288. $this->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
  289. }
  290. function testJumpToNamedPage() {
  291. $this->get($this->samples() . 'front_controller_style/');
  292. $this->assertText('Simple test front controller');
  293. $this->clickLink('Index');
  294. $this->assertResponse(200);
  295. $this->assertText('[action=index]');
  296. }
  297. function testJumpToUnnamedPage() {
  298. $this->get($this->samples() . 'front_controller_style/');
  299. $this->clickLink('No page');
  300. $this->assertResponse(200);
  301. $this->assertText('Simple test front controller');
  302. $this->assertText('[action=no_page]');
  303. }
  304. function testJumpToUnnamedPageWithBareParameter() {
  305. $this->get($this->samples() . 'front_controller_style/');
  306. $this->clickLink('Bare action');
  307. $this->assertResponse(200);
  308. $this->assertText('Simple test front controller');
  309. $this->assertText('[action=]');
  310. }
  311. function testJumpToUnnamedPageWithEmptyQuery() {
  312. $this->get($this->samples() . 'front_controller_style/');
  313. $this->clickLink('Empty query');
  314. $this->assertResponse(200);
  315. $this->assertPattern('/Simple test front controller/');
  316. $this->assertPattern('/raw get data.*?\[\].*?get data/si');
  317. }
  318. function testJumpToUnnamedPageWithEmptyLink() {
  319. $this->get($this->samples() . 'front_controller_style/');
  320. $this->clickLink('Empty link');
  321. $this->assertResponse(200);
  322. $this->assertPattern('/Simple test front controller/');
  323. $this->assertPattern('/raw get data.*?\[\].*?get data/si');
  324. }
  325. function testJumpBackADirectoryLevel() {
  326. $this->get($this->samples() . 'front_controller_style/');
  327. $this->clickLink('Down one');
  328. $this->assertPattern('|Index of .*?/test|');
  329. }
  330. function testSubmitToNamedPage() {
  331. $this->get($this->samples() . 'front_controller_style/');
  332. $this->assertText('Simple test front controller');
  333. $this->clickSubmit('Index');
  334. $this->assertResponse(200);
  335. $this->assertText('[action=Index]');
  336. }
  337. function testSubmitToSameDirectory() {
  338. $this->get($this->samples() . 'front_controller_style/index.php');
  339. $this->clickSubmit('Same directory');
  340. $this->assertResponse(200);
  341. $this->assertText('[action=Same+directory]');
  342. }
  343. function testSubmitToEmptyAction() {
  344. $this->get($this->samples() . 'front_controller_style/index.php');
  345. $this->clickSubmit('Empty action');
  346. $this->assertResponse(200);
  347. $this->assertText('[action=Empty+action]');
  348. }
  349. function testSubmitToNoAction() {
  350. $this->get($this->samples() . 'front_controller_style/index.php');
  351. $this->clickSubmit('No action');
  352. $this->assertResponse(200);
  353. $this->assertText('[action=No+action]');
  354. }
  355. function testSubmitBackADirectoryLevel() {
  356. $this->get($this->samples() . 'front_controller_style/');
  357. $this->clickSubmit('Down one');
  358. $this->assertPattern('|Index of .*?/test|');
  359. }
  360. function testSubmitToNamedPageWithMixedPostAndGet() {
  361. $this->get($this->samples() . 'front_controller_style/?a=A');
  362. $this->assertText('Simple test front controller');
  363. $this->clickSubmit('Index post');
  364. $this->assertText('action=[Index post]');
  365. $this->assertNoText('[a=A]');
  366. }
  367. function testSubmitToSameDirectoryMixedPostAndGet() {
  368. $this->get($this->samples() . 'front_controller_style/index.php?a=A');
  369. $this->clickSubmit('Same directory post');
  370. $this->assertText('action=[Same directory post]');
  371. $this->assertNoText('[a=A]');
  372. }
  373. function testSubmitToEmptyActionMixedPostAndGet() {
  374. $this->get($this->samples() . 'front_controller_style/index.php?a=A');
  375. $this->clickSubmit('Empty action post');
  376. $this->assertText('action=[Empty action post]');
  377. $this->assertText('[a=A]');
  378. }
  379. function testSubmitToNoActionMixedPostAndGet() {
  380. $this->get($this->samples() . 'front_controller_style/index.php?a=A');
  381. $this->clickSubmit('No action post');
  382. $this->assertText('action=[No action post]');
  383. $this->assertText('[a=A]');
  384. }
  385. }
  386. class TestOfLiveHeaders extends SimpleTestAcceptanceTest {
  387. function setUp() {
  388. $this->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
  389. }
  390. function testConfirmingHeaderExistence() {
  391. $this->get('http://www.lastcraft.com/');
  392. $this->assertHeader('content-type');
  393. $this->assertHeader('content-type', 'text/html');
  394. $this->assertHeader('content-type', new PatternExpectation('/HTML/i'));
  395. $this->assertNoHeader('WWW-Authenticate');
  396. }
  397. }
  398. class TestOfLiveRedirects extends SimpleTestAcceptanceTest {
  399. function setUp() {
  400. $this->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
  401. }
  402. function testNoRedirects() {
  403. $this->setMaximumRedirects(0);
  404. $this->get($this->samples() . 'redirect.php');
  405. $this->assertTitle('Redirection test');
  406. }
  407. function testRedirects() {
  408. $this->setMaximumRedirects(1);
  409. $this->get($this->samples() . 'redirect.php');
  410. $this->assertTitle('Simple test target file');
  411. }
  412. function testRedirectLosesGetData() {
  413. $this->get($this->samples() . 'redirect.php', array('a' => 'aaa'));
  414. $this->assertNoText('a=[aaa]');
  415. }
  416. function testRedirectKeepsExtraRequestDataOfItsOwn() {
  417. $this->get($this->samples() . 'redirect.php');
  418. $this->assertText('r=[rrr]');
  419. }
  420. function testRedirectLosesPostData() {
  421. $this->post($this->samples() . 'redirect.php', array('a' => 'aaa'));
  422. $this->assertTitle('Simple test target file');
  423. $this->assertNoText('a=[aaa]');
  424. }
  425. function testRedirectWithBaseUrlChange() {
  426. $this->get($this->samples() . 'base_change_redirect.php');
  427. $this->assertTitle('Simple test target file in folder');
  428. $this->get($this->samples() . 'path/base_change_redirect.php');
  429. $this->assertTitle('Simple test target file');
  430. }
  431. function testRedirectWithDoubleBaseUrlChange() {
  432. $this->get($this->samples() . 'double_base_change_redirect.php');
  433. $this->assertTitle('Simple test target file');
  434. }
  435. }
  436. class TestOfLiveCookies extends SimpleTestAcceptanceTest {
  437. function setUp() {
  438. $this->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
  439. }
  440. function here() {
  441. return new SimpleUrl($this->samples());
  442. }
  443. function thisHost() {
  444. $here = $this->here();
  445. return $here->getHost();
  446. }
  447. function thisPath() {
  448. $here = $this->here();
  449. return $here->getPath();
  450. }
  451. function testCookieSettingAndAssertions() {
  452. $this->setCookie('a', 'Test cookie a');
  453. $this->setCookie('b', 'Test cookie b', $this->thisHost());
  454. $this->setCookie('c', 'Test cookie c', $this->thisHost(), $this->thisPath());
  455. $this->get($this->samples() . 'network_confirm.php');
  456. $this->assertText('Test cookie a');
  457. $this->assertText('Test cookie b');
  458. $this->assertText('Test cookie c');
  459. $this->assertCookie('a');
  460. $this->assertCookie('b', 'Test cookie b');
  461. $this->assertTrue($this->getCookie('c') == 'Test cookie c');
  462. }
  463. function testNoCookieSetWhenCookiesDisabled() {
  464. $this->setCookie('a', 'Test cookie a');
  465. $this->ignoreCookies();
  466. $this->get($this->samples() . 'network_confirm.php');
  467. $this->assertNoText('Test cookie a');
  468. }
  469. function testCookieReading() {
  470. $this->get($this->samples() . 'set_cookies.php');
  471. $this->assertCookie('session_cookie', 'A');
  472. $this->assertCookie('short_cookie', 'B');
  473. $this->assertCookie('day_cookie', 'C');
  474. }
  475. function testNoCookie() {
  476. $this->assertNoCookie('aRandomCookie');
  477. }
  478. function testNoCookieReadingWhenCookiesDisabled() {
  479. $this->ignoreCookies();
  480. $this->get($this->samples() . 'set_cookies.php');
  481. $this->assertNoCookie('session_cookie');
  482. $this->assertNoCookie('short_cookie');
  483. $this->assertNoCookie('day_cookie');
  484. }
  485. function testCookiePatternAssertions() {
  486. $this->get($this->samples() . 'set_cookies.php');
  487. $this->assertCookie('session_cookie', new PatternExpectation('/a/i'));
  488. }
  489. function testTemporaryCookieExpiry() {
  490. $this->get($this->samples() . 'set_cookies.php');
  491. $this->restart();
  492. $this->assertNoCookie('session_cookie');
  493. $this->assertCookie('day_cookie', 'C');
  494. }
  495. function testTimedCookieExpiryWith100SecondMargin() {
  496. $this->get($this->samples() . 'set_cookies.php');
  497. $this->ageCookies(3600);
  498. $this->restart(time() + 100);
  499. $this->assertNoCookie('session_cookie');
  500. $this->assertNoCookie('hour_cookie');
  501. $this->assertCookie('day_cookie', 'C');
  502. }
  503. function testNoClockOverDriftBy100Seconds() {
  504. $this->get($this->samples() . 'set_cookies.php');
  505. $this->restart(time() + 200);
  506. $this->assertNoCookie(
  507. 'short_cookie',
  508. '%s -> Please check your computer clock setting if you are not using NTP');
  509. }
  510. function testNoClockUnderDriftBy100Seconds() {
  511. $this->get($this->samples() . 'set_cookies.php');
  512. $this->restart(time() + 0);
  513. $this->assertCookie(
  514. 'short_cookie',
  515. 'B',
  516. '%s -> Please check your computer clock setting if you are not using NTP');
  517. }
  518. function testCookiePath() {
  519. $this->get($this->samples() . 'set_cookies.php');
  520. $this->assertNoCookie('path_cookie', 'D');
  521. $this->get('./path/show_cookies.php');
  522. $this->assertPattern('/path_cookie/');
  523. $this->assertCookie('path_cookie', 'D');
  524. }
  525. }
  526. class LiveTestOfForms extends SimpleTestAcceptanceTest {
  527. function setUp() {
  528. $this->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
  529. }
  530. function testSimpleSubmit() {
  531. $this->get($this->samples() . 'form.html');
  532. $this->assertTrue($this->clickSubmit('Go!'));
  533. $this->assertPattern('/Request method.*?<dd>POST<\/dd>/');
  534. $this->assertText('go=[Go!]');
  535. }
  536. function testDefaultFormValues() {
  537. $this->get($this->samples() . 'form.html');
  538. $this->assertFieldByName('a', '');
  539. $this->assertFieldByName('b', 'Default text');
  540. $this->assertFieldByName('c', '');
  541. $this->assertFieldByName('d', 'd1');
  542. $this->assertFieldByName('e', false);
  543. $this->assertFieldByName('f', 'on');
  544. $this->assertFieldByName('g', 'g3');
  545. $this->assertFieldByName('h', 2);
  546. $this->assertFieldByName('go', 'Go!');
  547. $this->assertClickable('Go!');
  548. $this->assertSubmit('Go!');
  549. $this->assertTrue($this->clickSubmit('Go!'));
  550. $this->assertText('go=[Go!]');
  551. $this->assertText('a=[]');
  552. $this->assertText('b=[Default text]');
  553. $this->assertText('c=[]');
  554. $this->assertText('d=[d1]');
  555. $this->assertNoText('e=[');
  556. $this->assertText('f=[on]');
  557. $this->assertText('g=[g3]');
  558. }
  559. function testFormSubmissionByButtonLabel() {
  560. $this->get($this->samples() . 'form.html');
  561. $this->setFieldByName('a', 'aaa');
  562. $this->setFieldByName('b', 'bbb');
  563. $this->setFieldByName('c', 'ccc');
  564. $this->setFieldByName('d', 'D2');
  565. $this->setFieldByName('e', 'on');
  566. $this->setFieldByName('f', false);
  567. $this->setFieldByName('g', 'g2');
  568. $this->setFieldByName('h', 1);
  569. $this->assertTrue($this->clickSubmit('Go!'));
  570. $this->assertText('a=[aaa]');
  571. $this->assertText('b=[bbb]');
  572. $this->assertText('c=[ccc]');
  573. $this->assertText('d=[d2]');
  574. $this->assertText('e=[on]');
  575. $this->assertNoText('f=[');
  576. $this->assertText('g=[g2]');
  577. }
  578. function testAdditionalFormValues() {
  579. $this->get($this->samples() . 'form.html');
  580. $this->assertTrue($this->clickSubmit('Go!', array('add' => 'A')));
  581. $this->assertText('go=[Go!]');
  582. $this->assertText('add=[A]');
  583. }
  584. function testFormSubmissionByName() {
  585. $this->get($this->samples() . 'form.html');
  586. $this->setFieldByName('a', 'A');
  587. $this->assertTrue($this->clickSubmitByName('go'));
  588. $this->assertText('a=[A]');
  589. }
  590. function testFormSubmissionByNameAndAdditionalParameters() {
  591. $this->get($this->samples() . 'form.html');
  592. $this->assertTrue($this->clickSubmitByName('go', array('add' => 'A')));
  593. $this->assertText('go=[Go!]');
  594. $this->assertText('add=[A]');
  595. }
  596. function testFormSubmissionBySubmitButtonLabeledSubmit() {
  597. $this->get($this->samples() . 'form.html');
  598. $this->assertTrue($this->clickSubmitByName('test'));
  599. $this->assertText('test=[Submit]');
  600. }
  601. function testFormSubmissionWithIds() {
  602. $this->get($this->samples() . 'form.html');
  603. $this->assertFieldById(1, '');
  604. $this->assertFieldById(2, 'Default text');
  605. $this->assertFieldById(3, '');
  606. $this->assertFieldById(4, 'd1');
  607. $this->assertFieldById(5, false);
  608. $this->assertFieldById(6, 'on');
  609. $this->assertFieldById(8, 'g3');
  610. $this->assertFieldById(11, 2);
  611. $this->setFieldById(1, 'aaa');
  612. $this->setFieldById(2, 'bbb');
  613. $this->setFieldById(3, 'ccc');
  614. $this->setFieldById(4, 'D2');
  615. $this->setFieldById(5, 'on');
  616. $this->setFieldById(6, false);
  617. $this->setFieldById(8, 'g2');
  618. $this->setFieldById(11, 'H1');
  619. $this->assertTrue($this->clickSubmitById(99));
  620. $this->assertText('a=[aaa]');
  621. $this->assertText('b=[bbb]');
  622. $this->assertText('c=[ccc]');
  623. $this->assertText('d=[d2]');
  624. $this->assertText('e=[on]');
  625. $this->assertNoText('f=[');
  626. $this->assertText('g=[g2]');
  627. $this->assertText('h=[1]');
  628. $this->assertText('go=[Go!]');
  629. }
  630. function testFormSubmissionWithLabels() {
  631. $this->get($this->samples() . 'form.html');
  632. $this->assertField('Text A', '');
  633. $this->assertField('Text B', 'Default text');
  634. $this->assertField('Text area C', '');
  635. $this->assertField('Selection D', 'd1');
  636. $this->assertField('Checkbox E', false);
  637. $this->assertField('Checkbox F', 'on');
  638. $this->assertField('3', 'g3');
  639. $this->assertField('Selection H', 2);
  640. $this->setField('Text A', 'aaa');
  641. $this->setField('Text B', 'bbb');
  642. $this->setField('Text area C', 'ccc');
  643. $this->setField('Selection D', 'D2');
  644. $this->setField('Checkbox E', 'on');
  645. $this->setField('Checkbox F', false);
  646. $this->setField('2', 'g2');
  647. $this->setField('Selection H', 'H1');
  648. $this->clickSubmit('Go!');
  649. $this->assertText('a=[aaa]');
  650. $this->assertText('b=[bbb]');
  651. $this->assertText('c=[ccc]');
  652. $this->assertText('d=[d2]');
  653. $this->assertText('e=[on]');
  654. $this->assertNoText('f=[');
  655. $this->assertText('g=[g2]');
  656. $this->assertText('h=[1]');
  657. $this->assertText('go=[Go!]');
  658. }
  659. function testSettingCheckboxWithBooleanTrueSetsUnderlyingValue() {
  660. $this->get($this->samples() . 'form.html');
  661. $this->setField('Checkbox E', true);
  662. $this->assertField('Checkbox E', 'on');
  663. $this->clickSubmit('Go!');
  664. $this->assertText('e=[on]');
  665. }
  666. function testFormSubmissionWithMixedPostAndGet() {
  667. $this->get($this->samples() . 'form_with_mixed_post_and_get.html');
  668. $this->setField('Text A', 'Hello');
  669. $this->assertTrue($this->clickSubmit('Go!'));
  670. $this->assertText('a=[Hello]');
  671. $this->assertText('x=[X]');
  672. $this->assertText('y=[Y]');
  673. }
  674. function testFormSubmissionWithMixedPostAndEncodedGet() {
  675. $this->get($this->samples() . 'form_with_mixed_post_and_get.html');
  676. $this->setField('Text B', 'Hello');
  677. $this->assertTrue($this->clickSubmit('Go encoded!'));
  678. $this->assertText('b=[Hello]');
  679. $this->assertText('x=[X]');
  680. $this->assertText('y=[Y]');
  681. }
  682. function testFormSubmissionWithoutAction() {
  683. $this->get($this->samples() . 'form_without_action.php?test=test');
  684. $this->assertText('_GET : [test]');
  685. $this->assertTrue($this->clickSubmit('Submit Post With Empty Action'));
  686. $this->assertText('_GET : [test]');
  687. $this->assertText('_POST : [test]');
  688. }
  689. function testImageSubmissionByLabel() {
  690. $this->get($this->samples() . 'form.html');
  691. $this->assertImage('Image go!');
  692. $this->assertTrue($this->clickImage('Image go!', 10, 12));
  693. $this->assertText('go_x=[10]');
  694. $this->assertText('go_y=[12]');
  695. }
  696. function testImageSubmissionByLabelWithAdditionalParameters() {
  697. $this->get($this->samples() . 'form.html');
  698. $this->assertTrue($this->clickImage('Image go!', 10, 12, array('add' => 'A')));
  699. $this->assertText('add=[A]');
  700. }
  701. function testImageSubmissionByName() {
  702. $this->get($this->samples() . 'form.html');
  703. $this->assertTrue($this->clickImageByName('go', 10, 12));
  704. $this->assertText('go_x=[10]');
  705. $this->assertText('go_y=[12]');
  706. }
  707. function testImageSubmissionById() {
  708. $this->get($this->samples() . 'form.html');
  709. $this->assertTrue($this->clickImageById(97, 10, 12));
  710. $this->assertText('go_x=[10]');
  711. $this->assertText('go_y=[12]');
  712. }
  713. function testButtonSubmissionByLabel() {
  714. $this->get($this->samples() . 'form.html');
  715. $this->assertTrue($this->clickSubmit('Button go!', 10, 12));
  716. $this->assertPattern('/go=\[ButtonGo\]/s');
  717. }
  718. function testNamelessSubmitSendsNoValue() {
  719. $this->get($this->samples() . 'form_with_unnamed_submit.html');
  720. $this->click('Go!');
  721. $this->assertNoText('Go!');
  722. $this->assertNoText('submit');
  723. }
  724. function testNamelessImageSendsXAndYValues() {
  725. $this->get($this->samples() . 'form_with_unnamed_submit.html');
  726. $this->clickImage('Image go!', 4, 5);
  727. $this->assertNoText('ImageGo');
  728. $this->assertText('x=[4]');
  729. $this->assertText('y=[5]');
  730. }
  731. function testNamelessButtonSendsNoValue() {
  732. $this->get($this->samples() . 'form_with_unnamed_submit.html');
  733. $this->click('Button Go!');
  734. $this->assertNoText('ButtonGo');
  735. }
  736. function testSelfSubmit() {
  737. $this->get($this->samples() . 'self_form.php');
  738. $this->assertNoText('[Submitted]');
  739. $this->assertNoText('[Wrong form]');
  740. $this->assertTrue($this->clickSubmit());
  741. $this->assertText('[Submitted]');
  742. $this->assertNoText('[Wrong form]');
  743. $this->assertTitle('Test of form self submission');
  744. }
  745. function testSelfSubmitWithParameters() {
  746. $this->get($this->samples() . 'self_form.php');
  747. $this->setFieldByName('visible', 'Resent');
  748. $this->assertTrue($this->clickSubmit());
  749. $this->assertText('[Resent]');
  750. }
  751. function testSettingOfBlankOption() {
  752. $this->get($this->samples() . 'form.html');
  753. $this->assertTrue($this->setFieldByName('d', ''));
  754. $this->clickSubmit('Go!');
  755. $this->assertText('d=[]');
  756. }
  757. function testAssertingFieldValueWithPattern() {
  758. $this->get($this->samples() . 'form.html');
  759. $this->setField('c', 'A very long string');
  760. $this->assertField('c', new PatternExpectation('/very long/'));
  761. }
  762. function testSendingMultipartFormDataEncodedForm() {
  763. $this->get($this->samples() . 'form_data_encoded_form.html');
  764. $this->assertField('Text A', '');
  765. $this->assertField('Text B', 'Default text');
  766. $this->assertField('Text area C', '');
  767. $this->assertField('Selection D', 'd1');
  768. $this->assertField('Checkbox E', false);
  769. $this->assertField('Checkbox F', 'on');
  770. $this->assertField('3', 'g3');
  771. $this->assertField('Selection H', 2);
  772. $this->setField('Text A', 'aaa');
  773. $this->setField('Text B', 'bbb');
  774. $this->setField('Text area C', 'ccc');
  775. $this->setField('Selection D', 'D2');
  776. $this->setField('Checkbox E', 'on');
  777. $this->setField('Checkbox F', false);
  778. $this->setField('2', 'g2');
  779. $this->setField('Selection H', 'H1');
  780. $this->assertTrue($this->clickSubmit('Go!'));
  781. $this->assertText('a=[aaa]');
  782. $this->assertText('b=[bbb]');
  783. $this->assertText('c=[ccc]');
  784. $this->assertText('d=[d2]');
  785. $this->assertText('e=[on]');
  786. $this->assertNoText('f=[');
  787. $this->assertText('g=[g2]');
  788. $this->assertText('h=[1]');
  789. $this->assertText('go=[Go!]');
  790. }
  791. function testSettingVariousBlanksInFields() {
  792. $this->get($this->samples() . 'form_with_false_defaults.html');
  793. $this->assertField('Text A', '');
  794. $this->setField('Text A', '0');
  795. $this->assertField('Text A', '0');
  796. $this->assertField('Text area B', '');
  797. $this->setField('Text area B', '0');
  798. $this->assertField('Text area B', '0');
  799. $this->assertField('Text area C', " ");
  800. $this->assertField('Selection D', '');
  801. $this->setField('Selection D', 'D2');
  802. $this->assertField('Selection D', 'D2');
  803. $this->setField('Selection D', 'D3');
  804. $this->assertField('Selection D', '0');
  805. $this->setField('Selection D', 'D4');
  806. $this->assertField('Selection D', '?');
  807. $this->assertField('Checkbox E', '');
  808. $this->assertField('Checkbox F', 'on');
  809. $this->assertField('Checkbox G', '0');
  810. $this->assertField('Checkbox H', '?');
  811. $this->assertFieldByName('i', 'on');
  812. $this->setFieldByName('i', '');
  813. $this->assertFieldByName('i', '');
  814. $this->setFieldByName('i', '0');
  815. $this->assertFieldByName('i', '0');
  816. $this->setFieldByName('i', '?');
  817. $this->assertFieldByName('i', '?');
  818. }
  819. function testSubmissionOfBlankFields() {
  820. $this->get($this->samples() . 'form_with_false_defaults.html');
  821. $this->setField('Text A', '');
  822. $this->setField('Text area B', '');
  823. $this->setFieldByName('i', '');
  824. $this->click('Go!');
  825. $this->assertText('a=[]');
  826. $this->assertText('b=[]');
  827. $this->assertPattern('/c=\[ \]/');
  828. $this->assertText('d=[]');
  829. $this->assertText('e=[]');
  830. $this->assertText('i=[]');
  831. }
  832. function testSubmissionOfEmptyValues() {
  833. $this->get($this->samples() . 'form_with_false_defaults.html');
  834. $this->setField('Selection D', 'D2');
  835. $this->click('Go!');
  836. $this->assertText('a=[]');
  837. $this->assertText('b=[]');
  838. $this->assertText('d=[D2]');
  839. $this->assertText('f=[on]');
  840. $this->assertText('i=[on]');
  841. }
  842. function testSubmissionOfZeroes() {
  843. $this->get($this->samples() . 'form_with_false_defaults.html');
  844. $this->setField('Text A', '0');
  845. $this->setField('Text area B', '0');
  846. $this->setField('Selection D', 'D3');
  847. $this->setFieldByName('i', '0');
  848. $this->click('Go!');
  849. $this->assertText('a=[0]');
  850. $this->assertText('b=[0]');
  851. $this->assertText('d=[0]');
  852. $this->assertText('g=[0]');
  853. $this->assertText('i=[0]');
  854. }
  855. function testSubmissionOfQuestionMarks() {
  856. $this->get($this->samples() . 'form_with_false_defaults.html');
  857. $this->setField('Text A', '?');
  858. $this->setField('Text area B', '?');
  859. $this->setField('Selection D', 'D4');
  860. $this->setFieldByName('i', '?');
  861. $this->click('Go!');
  862. $this->assertText('a=[?]');
  863. $this->assertText('b=[?]');
  864. $this->assertText('d=[?]');
  865. $this->assertText('h=[?]');
  866. $this->assertText('i=[?]');
  867. }
  868. function testSubmissionOfHtmlEncodedValues() {
  869. $this->get($this->samples() . 'form_with_tricky_defaults.html');
  870. $this->assertField('Text A', '&\'"<>');
  871. $this->assertField('Text B', '"');
  872. $this->assertField('Text area C', '&\'"<>');
  873. $this->assertField('Selection D', "'");
  874. $this->assertField('Checkbox E', '&\'"<>');
  875. $this->assertField('Checkbox F', false);
  876. $this->assertFieldByname('i', "'");
  877. $this->click('Go!');
  878. $this->assertText('a=[&\'"<>, "]');
  879. $this->assertText('c=[&\'"<>]');
  880. $this->assertText("d=[']");
  881. $this->assertText('e=[&\'"<>]');
  882. $this->assertText("i=[']");
  883. }
  884. function testFormActionRespectsBaseTag() {
  885. $this->get($this->samples() . 'base_tag/form.html');
  886. $this->assertTrue($this->clickSubmit('Go!'));
  887. $this->assertText('go=[Go!]');
  888. $this->assertText('a=[]');
  889. }
  890. }
  891. class TestOfLiveMultiValueWidgets extends SimpleTestAcceptanceTest {
  892. function setUp() {
  893. $this->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
  894. }
  895. function testDefaultFormValueSubmission() {
  896. $this->get($this->samples() . 'multiple_widget_form.html');
  897. $this->assertFieldByName('a', array('a2', 'a3'));
  898. $this->assertFieldByName('b', array('b2', 'b3'));
  899. $this->assertFieldByName('c[]', array('c2', 'c3'));
  900. $this->assertFieldByName('d', array('2', '3'));
  901. $this->assertFieldByName('e', array('2', '3'));
  902. $this->assertTrue($this->clickSubmit('Go!'));
  903. $this->assertText('a=[a2, a3]');
  904. $this->assertText('b=[b2, b3]');
  905. $this->assertText('c=[c2, c3]');
  906. $this->assertText('d=[2, 3]');
  907. $this->assertText('e=[2, 3]');
  908. }
  909. function testSubmittingMultipleValues() {
  910. $this->get($this->samples() . 'multiple_widget_form.html');
  911. $this->setFieldByName('a', array('a1', 'a4'));
  912. $this->assertFieldByName('a', array('a1', 'a4'));
  913. $this->assertFieldByName('a', array('a4', 'a1'));
  914. $this->setFieldByName('b', array('b1', 'b4'));
  915. $this->assertFieldByName('b', array('b1', 'b4'));
  916. $this->setFieldByName('c[]', array('c1', 'c4'));
  917. $this->assertField('c[]', array('c1', 'c4'));
  918. $this->setFieldByName('d', array('1', '4'));
  919. $this->assertField('d', array('1', '4'));
  920. $this->setFieldByName('e', array('e1', 'e4'));
  921. $this->assertField('e', array('1', '4'));
  922. $this->assertTrue($this->clickSubmit('Go!'));
  923. $this->assertText('a=[a1, a4]');
  924. $this->assertText('b=[b1, b4]');
  925. $this->assertText('c=[c1, c4]');
  926. $this->assertText('d=[1, 4]');
  927. $this->assertText('e=[1, 4]');
  928. }
  929. function testSettingByOptionValue() {
  930. $this->get($this->samples() . 'multiple_widget_form.html');
  931. $this->setFieldByName('d', array('1', '4'));
  932. $this->assertField('d', array('1', '4'));
  933. $this->assertTrue($this->clickSubmit('Go!'));
  934. $this->assertText('d=[1, 4]');
  935. }
  936. function testSubmittingMultipleValuesByLabel() {
  937. $this->get($this->samples() . 'multiple_widget_form.html');
  938. $this->setField('Multiple selection A', array('a1', 'a4'));
  939. $this->assertField('Multiple selection A', array('a1', 'a4'));
  940. $this->assertField('Multiple selection A', array('a4', 'a1'));
  941. $this->setField('multiple selection C', array('c1', 'c4'));
  942. $this->assertField('multiple selection C', array('c1', 'c4'));
  943. $this->assertTrue($this->clickSubmit('Go!'));
  944. $this->assertText('a=[a1, a4]');
  945. $this->assertText('c=[c1, c4]');
  946. }
  947. function testSavantStyleHiddenFieldDefaults() {
  948. $this->get($this->samples() . 'savant_style_form.html');
  949. $this->assertFieldByName('a', array('a0'));
  950. $this->assertFieldByName('b', array('b0'));
  951. $this->assertTrue($this->clickSubmit('Go!'));
  952. $this->assertText('a=[a0]');
  953. $this->assertText('b=[b0]');
  954. }
  955. function testSavantStyleHiddenDefaultsAreOverridden() {
  956. $this->get($this->samples() . 'savant_style_form.html');
  957. $this->assertTrue($this->setFieldByName('a', array('a1')));
  958. $this->assertTrue($this->setFieldByName('b', 'b1'));
  959. $this->assertTrue($this->clickSubmit('Go!'));
  960. $this->assertText('a=[a1]');
  961. $this->assertText('b=[b1]');
  962. }
  963. function testSavantStyleFormSettingById() {
  964. $this->get($this->samples() . 'savant_style_form.html');
  965. $this->assertFieldById(1, array('a0'));
  966. $this->assertFieldById(4, array('b0'));
  967. $this->assertTrue($this->setFieldById(2, 'a1'));
  968. $this->assertTrue($this->setFieldById(5, 'b1'));
  969. $this->assertTrue($this->clickSubmitById(99));
  970. $this->assertText('a=[a1]');
  971. $this->assertText('b=[b1]');
  972. }
  973. }
  974. class TestOfFileUploads extends SimpleTestAcceptanceTest {
  975. function setUp() {
  976. $this->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
  977. }
  978. function testSingleFileUpload() {
  979. $this->get($this->samples() . 'upload_form.html');
  980. $this->assertTrue($this->setField('Content:',
  981. dirname(__FILE__) . '/support/upload_sample.txt'));
  982. $this->assertField('Content:', dirname(__FILE__) . '/support/upload_sample.txt');
  983. $this->click('Go!');
  984. $this->assertText('Sample for testing file upload');
  985. }
  986. function testMultipleFileUpload() {
  987. $this->get($this->samples() . 'upload_form.html');
  988. $this->assertTrue($this->setField('Content:',
  989. dirname(__FILE__) . '/support/upload_sample.txt'));
  990. $this->assertTrue($this->setField('Supplemental:',
  991. dirname(__FILE__) . '/support/supplementary_upload_sample.txt'));
  992. $this->assertField('Supplemental:',
  993. dirname(__FILE__) . '/support/supplementary_upload_sample.txt');
  994. $this->click('Go!');
  995. $this->assertText('Sample for testing file upload');
  996. $this->assertText('Some more text content');
  997. }
  998. function testBinaryFileUpload() {
  999. $this->get($this->samples() . 'upload_form.html');
  1000. $this->assertTrue($this->setField('Content:',
  1001. dirname(__FILE__) . '/support/latin1_sample'));
  1002. $this->click('Go!');
  1003. $this->assertText(
  1004. implode('', file(dirname(__FILE__) . '/support/latin1_sample')));
  1005. }
  1006. }
  1007. class TestOfLiveHistoryNavigation extends SimpleTestAcceptanceTest {
  1008. function setUp() {
  1009. $this->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
  1010. }
  1011. function testRetry() {
  1012. $this->get($this->samples() . 'cookie_based_counter.php');
  1013. $this->assertPattern('/count: 1/i');
  1014. $this->retry();
  1015. $this->assertPattern('/count: 2/i');
  1016. $this->retry();
  1017. $this->assertPattern('/count: 3/i');
  1018. }
  1019. function testOfBackButton() {
  1020. $this->get($this->samples() . '1.html');
  1021. $this->clickLink('2');
  1022. $this->assertTitle('2');
  1023. $this->assertTrue($this->back());
  1024. $this->assertTitle('1');
  1025. $this->assertTrue($this->forward());
  1026. $this->assertTitle('2');
  1027. $this->assertFalse($this->forward());
  1028. }
  1029. function testGetRetryResubmitsData() {
  1030. $this->assertTrue($this->get(
  1031. $this->samples() . 'network_confirm.php?a=aaa'));
  1032. $this->assertPattern('/Request method.*?<dd>GET<\/dd>/');
  1033. $this->assertText('a=[aaa]');
  1034. $this->retry();
  1035. $this->assertPattern('/Request method.*?<dd>GET<\/dd>/');
  1036. $this->assertText('a=[aaa]');
  1037. }
  1038. function testGetRetryResubmitsExtraData() {
  1039. $this->assertTrue($this->get(
  1040. $this->samples() . 'network_confirm.php',
  1041. array('a' => 'aaa')));
  1042. $this->assertPattern('/Request method.*?<dd>GET<\/dd>/');
  1043. $this->assertText('a=[aaa]');
  1044. $this->retry();
  1045. $this->assertPattern('/Request method.*?<dd>GET<\/dd>/');
  1046. $this->assertText('a=[aaa]');
  1047. }
  1048. function testPostRetryResubmitsData() {
  1049. $this->assertTrue($this->post(
  1050. $this->samples() . 'network_confirm.php',
  1051. array('a' => 'aaa')));
  1052. $this->assertPattern('/Request method.*?<dd>POST<\/dd>/');
  1053. $this->assertText('a=[aaa]');
  1054. $this->retry();
  1055. $this->assertPattern('/Request method.*?<dd>POST<\/dd>/');
  1056. $this->assertText('a=[aaa]');
  1057. }
  1058. function testGetRetryResubmitsRepeatedData() {
  1059. $this->assertTrue($this->get(
  1060. $this->samples() . 'network_confirm.php?a=1&a=2'));
  1061. $this->assertPattern('/Request method.*?<dd>GET<\/dd>/');
  1062. $this->assertText('a=[1, 2]');
  1063. $this->retry();
  1064. $this->assertPattern('/Request method.*?<dd>GET<\/dd>/');
  1065. $this->assertText('a=[1, 2]');
  1066. }
  1067. }
  1068. class TestOfLiveAuthentication extends SimpleTestAcceptanceTest {
  1069. function setUp() {
  1070. $this->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
  1071. }
  1072. function testChallengeFromProtectedPage() {
  1073. $this->get($this->samples() . 'protected/');
  1074. $this->assertResponse(401);
  1075. $this->assertAuthentication('Basic');
  1076. $this->assertRealm('SimpleTest basic authentication');
  1077. $this->assertRealm(new PatternExpectation('/simpletest/i'));
  1078. $this->authenticate('test', 'secret');
  1079. $this->assertResponse(200);
  1080. $this->retry();
  1081. $this->assertResponse(200);
  1082. }
  1083. function testTrailingSlashImpliedWithinRealm() {
  1084. $this->get($this->samples() . 'protected/');
  1085. $this->authenticate('test', 'secret');
  1086. $this->assertResponse(200);
  1087. $this->get($this->samples() . 'protected');
  1088. $this->assertResponse(200);
  1089. }
  1090. function testTrailingSlashImpliedSettingRealm() {
  1091. $this->get($this->samples() . 'protected');
  1092. $this->authenticate('test', 'secret');
  1093. $this->assertResponse(200);
  1094. $this->get($this->samples() . 'protected/');
  1095. $this->assertResponse(200);
  1096. }
  1097. function testEncodedAuthenticationFetchesPage() {
  1098. $this->get('http://test:secret@www.lastcraft.com/test/protected/');
  1099. $this->assertResponse(200);
  1100. }
  1101. function testEncodedAuthenticationFetchesPageAfterTrailingSlashRedirect() {
  1102. $this->get('http://test:secret@www.lastcraft.com/test/protected');
  1103. $this->assertResponse(200);
  1104. }
  1105. function testRealmExtendsToWholeDirectory() {
  1106. $this->get($this->samples() . 'protected/1.html');
  1107. $this->authenticate('test', 'secret');
  1108. $this->clickLink('2');
  1109. $this->assertResponse(200);
  1110. $this->clickLink('3');
  1111. $this->assertResponse(200);
  1112. }
  1113. function testRedirectKeepsAuthentication() {
  1114. $this->get($this->samples() . 'protected/local_redirect.php');
  1115. $this->authenticate('test', 'secret');
  1116. $this->assertTitle('Simple test target file');
  1117. }
  1118. function testRedirectKeepsEncodedAuthentication() {
  1119. $this->get('http://test:secret@www.lastcraft.com/test/protected/local_redirect.php');
  1120. $this->assertResponse(200);
  1121. $this->assertTitle('Simple test target file');
  1122. }
  1123. function testSessionRestartLosesAuthentication() {
  1124. $this->get($this->samples() . 'protected/');
  1125. $this->authenticate('test', 'secret');
  1126. $this->assertResponse(200);
  1127. $this->restart();
  1128. $this->get($this->samples() . 'protected/');
  1129. $this->assertResponse(401);
  1130. }
  1131. }
  1132. class TestOfLoadingFrames extends SimpleTestAcceptanceTest {
  1133. function setUp() {
  1134. $this->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
  1135. }
  1136. function testNoFramesContentWhenFramesDisabled() {
  1137. $this->ignoreFrames();
  1138. $this->get($this->samples() . 'one_page_frameset.html');
  1139. $this->assertTitle('Frameset for testing of SimpleTest');
  1140. $this->assertText('This content is for no frames only');
  1141. }
  1142. function testPatternMatchCanReadTheOnlyFrame() {
  1143. $this->get($this->samples() . 'one_page_frameset.html');
  1144. $this->assertText('A target for the SimpleTest test suite');
  1145. $this->assertNoText('This content is for no frames only');
  1146. }
  1147. function testMessyFramesetResponsesByName() {
  1148. $this->assertTrue($this->get(
  1149. $this->samples() . 'messy_frameset.html'));
  1150. $this->assertTitle('Frameset for testing of SimpleTest');
  1151. $this->assertTrue($this->setFrameFocus('Front controller'));
  1152. $this->assertResponse(200);
  1153. $this->assertText('Simple test front controller');
  1154. $this->assertTrue($this->setFrameFocus('One'));
  1155. $this->assertResponse(200);
  1156. $this->assertLink('2');
  1157. $this->assertTrue($this->setFrameFocus('Frame links'));
  1158. $this->assertResponse(200);
  1159. $this->assertLink('Set one to 2');
  1160. $this->assertTrue($this->setFrameFocus('Counter'));
  1161. $this->assertResponse(200);
  1162. $this->assertText('Count: 1');
  1163. $this->assertTrue($this->setFrameFocus('Redirected'));
  1164. $this->assertResponse(200);
  1165. $this->assertText('r=rrr');
  1166. $this->assertTrue($this->setFrameFocus('Protected'));
  1167. $this->assertResponse(401);
  1168. $this->assertTrue($this->setFrameFocus('Protected redirect'));
  1169. $this->assertResponse(401);
  1170. $this->assertTrue($this->setFrameFocusByIndex(1));
  1171. $this->assertResponse(200);
  1172. $this->assertText('Simple test front controller');
  1173. $this->assertTrue($this->setFrameFocusByIndex(2));
  1174. $this->assertResponse(200);
  1175. $this->assertLink('2');
  1176. $this->assertTrue($this->setFrameFocusByIndex(3));
  1177. $this->assertResponse(200);
  1178. $this->assertLink('Set one to 2');
  1179. $this->assertTrue($this->setFrameFocusByIndex(4));
  1180. $this->assertResponse(200);
  1181. $this->assertText('Count: 1');
  1182. $this->assertTrue($this->setFrameFocusByIndex(5));
  1183. $this->assertResponse(200);
  1184. $this->assertText('r=rrr');
  1185. $this->assertTrue($this->setFrameFocusByIndex(6));
  1186. $this->assertResponse(401);
  1187. $this->assertTrue($this->setFrameFocusByIndex(7));
  1188. }
  1189. function testReloadingFramesetPage() {
  1190. $this->get($this->samples() . 'messy_frameset.html');
  1191. $this->assertText('Count: 1');
  1192. $this->retry();
  1193. $this->assertText('Count: 2');
  1194. $this->retry();
  1195. $this->assertText('Count: 3');
  1196. }
  1197. function testReloadingSingleFrameWithCookieCounter() {
  1198. $this->get($this->samples() . 'counting_frameset.html');
  1199. $this->setFrameFocus('a');
  1200. $this->assertText('Count: 1');
  1201. $this->setFrameFocus('b');
  1202. $this->assertText('Count: 2');
  1203. $this->setFrameFocus('a');
  1204. $this->retry();
  1205. $this->assertText('Count: 3');
  1206. $this->retry();
  1207. $this->assertText('Count: 4');
  1208. $this->setFrameFocus('b');
  1209. $this->assertText('Count: 2');
  1210. }
  1211. function testReloadingFrameWhenUnfocusedReloadsWholeFrameset() {
  1212. $this->get($this->samples() . 'counting_frameset.html');
  1213. $this->setFrameFocus('a');
  1214. $this->assertText('Count: 1');
  1215. $this->setFrameFocus('b');
  1216. $this->assertText('Count: 2');
  1217. $this->clearFrameFocus('a');
  1218. $this->retry();
  1219. $this->assertTitle('Frameset for testing of SimpleTest');
  1220. $this->setFrameFocus('a');
  1221. $this->assertText('Count: 3');
  1222. $this->setFrameFocus('b');
  1223. $this->assertText('Count: 4');
  1224. }
  1225. function testClickingNormalLinkReplacesJustThatFrame() {
  1226. $this->get($this->samples() . 'messy_frameset.html');
  1227. $this->clickLink('2');
  1228. $this->assertLink('3');
  1229. $this->assertText('Simple test front controller');
  1230. }
  1231. function testJumpToNamedPageReplacesJustThatFrame() {
  1232. $this->get($this->samples() . 'messy_frameset.html');
  1233. $this->assertPattern('/Simple test front controller/');
  1234. $this->clickLink('Index');
  1235. $this->assertResponse(200);
  1236. $this->assertText('[action=index]');
  1237. $this->assertText('Count: 1');
  1238. }
  1239. function testJumpToUnnamedPageReplacesJustThatFrame() {
  1240. $this->get($this->samples() . 'messy_frameset.html');
  1241. $this->clickLink('No page');
  1242. $this->assertResponse(200);
  1243. $this->assertText('Simple test front controller');
  1244. $this->assertText('[action=no_page]');
  1245. $this->assertText('Count: 1');
  1246. }
  1247. function testJumpToUnnamedPageWithBareParameterReplacesJustThatFrame() {
  1248. $this->get($this->samples() . 'messy_frameset.html');
  1249. $this->clickLink('Bare action');
  1250. $this->assertResponse(200);
  1251. $this->assertText('Simple test front controller');
  1252. $this->assertText('[action=]');
  1253. $this->assertText('Count: 1');
  1254. }
  1255. function testJumpToUnnamedPageWithEmptyQueryReplacesJustThatFrame() {
  1256. $this->get($this->samples() . 'messy_frameset.html');
  1257. $this->clickLink('Empty query');
  1258. $this->assertResponse(200);
  1259. $this->assertPattern('/Simple test front controller/');
  1260. $this->assertPattern('/raw get data.*?\[\].*?get data/si');
  1261. $this->assertPattern('/Count: 1/');
  1262. }
  1263. function testJumpToUnnamedPageWithEmptyLinkReplacesJustThatFrame() {
  1264. $this->get($this->samples() . 'messy_frameset.html');
  1265. $this->clickLink('Empty link');
  1266. $this->assertResponse(200);
  1267. $this->assertPattern('/Simple test front controller/');
  1268. $this->assertPattern('/raw get data.*?\[\].*?get data/si');
  1269. $this->assertPattern('/Count: 1/');
  1270. }
  1271. function testJumpBackADirectoryLevelReplacesJustThatFrame() {
  1272. $this->get($this->samples() . 'messy_frameset.html');
  1273. $this->clickLink('Down one');
  1274. $this->assertPattern('/index of .*\/test/i');
  1275. $this->assertPattern('/Count: 1/');
  1276. }
  1277. function testSubmitToNamedPageReplacesJustThatFrame() {
  1278. $this->get($this->samples() . 'messy_frameset.html');
  1279. $this->assertPattern('/Simple test front controller/');
  1280. $this->clickSubmit('Index');
  1281. $this->assertResponse(200);
  1282. $this->assertText('[action=Index]');
  1283. $this->assertText('Count: 1');
  1284. }
  1285. function testSubmitToSameDirectoryReplacesJustThatFrame() {
  1286. $this->get($this->samples() . 'messy_frameset.html');
  1287. $this->clickSubmit('Same directory');
  1288. $this->assertResponse(200);
  1289. $this->assertText('[action=Same+directory]');
  1290. $this->assertText('Count: 1');
  1291. }
  1292. function testSubmitToEmptyActionReplacesJustThatFrame() {
  1293. $this->get($this->samples() . 'messy_frameset.html');
  1294. $this->clickSubmit('Empty action');
  1295. $this->assertResponse(200);
  1296. $this->assertText('[action=Empty+action]');
  1297. $this->assertText('Count: 1');
  1298. }
  1299. function testSubmitToNoActionReplacesJustThatFrame() {
  1300. $this->get($this->samples() . 'messy_frameset.html');
  1301. $this->clickSubmit('No action');
  1302. $this->assertResponse(200);
  1303. $this->assertText('[action=No+action]');
  1304. $this->assertText('Count: 1');
  1305. }
  1306. function testSubmitBackADirectoryLevelReplacesJustThatFrame() {
  1307. $this->get($this->samples() . 'messy_frameset.html');
  1308. $this->clickSubmit('Down one');
  1309. $this->assertPattern('/index of .*\/test/i');
  1310. $this->assertPattern('/Count: 1/');
  1311. }
  1312. function testTopLinkExitsFrameset() {
  1313. $this->get($this->samples() . 'messy_frameset.html');
  1314. $this->clickLink('Exit the frameset');
  1315. $this->assertTitle('Simple test target file');
  1316. }
  1317. function testLinkInOnePageCanLoadAnother() {
  1318. $this->get($this->samples() . 'messy_frameset.html');
  1319. $this->assertNoLink('3');
  1320. $this->clickLink('Set one to 2');
  1321. $this->assertLink('3');
  1322. $this->assertNoLink('2');
  1323. $this->assertTitle('Frameset for testing of SimpleTest');
  1324. }
  1325. function testFrameWithRelativeLinksRespectsBaseTagForThatPage() {
  1326. $this->get($this->samples() . 'base_tag/frameset.html');
  1327. $this->click('Back to test pages');
  1328. $this->assertTitle('Frameset for testing of SimpleTest');
  1329. $this->assertText('A target for the SimpleTest test suite');
  1330. }
  1331. function testRelativeLinkInFrameIsNotAffectedByFramesetBaseTag() {
  1332. $this->get($this->samples() . 'base_tag/frameset_with_base_tag.html');
  1333. $this->assertText('This is page 1');
  1334. $this->click('To page 2');
  1335. $this->assertTitle('Frameset for testing of SimpleTest');
  1336. $this->assertText('This is page 2');
  1337. }
  1338. }
  1339. class TestOfFrameAuthentication extends SimpleTestAcceptanceTest {
  1340. function setUp() {
  1341. $this->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
  1342. }
  1343. function testUnauthenticatedFrameSendsChallenge() {
  1344. $this->get($this->samples() . 'protected/');
  1345. $this->setFrameFocus('Protected');
  1346. $this->assertAuthentication('Basic');
  1347. $this->assertRealm('SimpleTest basic authentication');
  1348. $this->assertResponse(401);
  1349. }
  1350. function testCanReadFrameFromAlreadyAuthenticatedRealm() {
  1351. $this->get($this->samples() . 'protected/');
  1352. $this->authenticate('test', 'secret');
  1353. $this->get($this->samples() . 'messy_frameset.html');
  1354. $this->setFrameFocus('Protected');
  1355. $this->assertResponse(200);
  1356. $this->assertText('A target for the SimpleTest test suite');
  1357. }
  1358. function testCanAuthenticateFrame() {
  1359. $this->get($this->samples() . 'messy_frameset.html');
  1360. $this->setFrameFocus('Protected');
  1361. $this->authenticate('test', 'secret');
  1362. $this->assertResponse(200);
  1363. $this->assertText('A target for the SimpleTest test suite');
  1364. $this->clearFrameFocus();
  1365. $this->assertText('Count: 1');
  1366. }
  1367. function testCanAuthenticateRedirectedFrame() {
  1368. $this->get($this->samples() . 'messy_frameset.html');
  1369. $this->setFrameFocus('Protected redirect');
  1370. $this->assertResponse(401);
  1371. $this->authenticate('test', 'secret');
  1372. $this->assertResponse(200);
  1373. $this->assertText('A target for the SimpleTest test suite');
  1374. $this->clearFrameFocus();
  1375. $this->assertText('Count: 1');
  1376. }
  1377. }
  1378. class TestOfNestedFrames extends SimpleTestAcceptanceTest {
  1379. function setUp() {
  1380. $this->addHeader('User-Agent: SimpleTest ' . SimpleTest::getVersion());
  1381. }
  1382. function testCanNavigateToSpecificContent() {
  1383. $this->get($this->samples() . 'nested_frameset.html');
  1384. $this->assertTitle('Nested frameset for testing of SimpleTest');
  1385. $this->assertPattern('/This is frame A/');
  1386. $this->assertPattern('/This is frame B/');
  1387. $this->assertPattern('/Simple test front controller/');
  1388. $this->assertLink('2');
  1389. $this->assertLink('Set one to 2');
  1390. $this->assertPattern('/Count: 1/');
  1391. $this->assertPattern('/r=rrr/');
  1392. $this->setFrameFocus('pair');
  1393. $this->assertPattern('/This is frame A/');
  1394. $this->assertPattern('/This is frame B/');
  1395. $this->assertNoPattern('/Simple test front controller/');
  1396. $this->assertNoLink('2');
  1397. $this->setFrameFocus('aaa');
  1398. $this->assertPattern('/This is frame A/');
  1399. $this->assertNoPattern('/This is frame B/');
  1400. $this->clearFrameFocus();
  1401. $this->assertResponse(200);
  1402. $this->setFrameFocus('messy');
  1403. $this->assertResponse(200);
  1404. $this->setFrameFocus('Front controller');
  1405. $this->assertResponse(200);
  1406. $this->assertPattern('/Simple test front controller/');
  1407. $this->assertNoLink('2');
  1408. }
  1409. function testReloadingFramesetPage() {
  1410. $this->get($this->samples() . 'nested_frameset.html');
  1411. $this->assertPattern('/Count: 1/');
  1412. $this->retry();
  1413. $this->assertPattern('/Count: 2/');
  1414. $this->retry();
  1415. $this->assertPattern('/Count: 3/');
  1416. }
  1417. function testRetryingNestedPageOnlyRetriesThatSet() {
  1418. $this->get($this->samples() . 'nested_frameset.html');
  1419. $this->assertPattern('/Count: 1/');
  1420. $this->setFrameFocus('messy');
  1421. $this->retry();
  1422. $this->assertPattern('/Count: 2/');
  1423. $this->setFrameFocus('Counter');
  1424. $this->retry();
  1425. $this->assertPattern('/Count: 3/');
  1426. $this->clearFrameFocus();
  1427. $this->setFrameFocus('messy');
  1428. $this->setFrameFocus('Front controller');
  1429. $this->retry();
  1430. $this->clearFrameFocus();
  1431. $this->assertPattern('/Count: 3/');
  1432. }
  1433. function testAuthenticatingNestedPage() {
  1434. $this->get($this->samples() . 'nested_frameset.html');
  1435. $this->setFrameFocus('messy');
  1436. $this->setFrameFocus('Protected');
  1437. $this->assertAuthentication('Basic');
  1438. $this->assertRealm('SimpleTest basic authentication');
  1439. $this->assertResponse(401);
  1440. $this->authenticate('test', 'secret');
  1441. $this->assertResponse(200);
  1442. $this->assertPattern('/A target for the SimpleTest test suite/');
  1443. }
  1444. }
  1445. ?>