"""Translated from t/php/regression.t -- need_php.

Faithful translation: single GET_BODY compared against a literal expected body.
The expected output is long/repetitive; preserved verbatim from the Perl heredoc.
"""

from apache_pytest import need_php

EXPECTED = 'PHP Regression Test\n\n<html>\n<head>\n\n*** Testing assignments and variable aliasing: ***<br>\nThis should read "blah": blah<br>\nThis should read "this is nifty": this is nifty<br>\n*************************************************<br>\n\n*** Testing integer operators ***<br>\nCorrect result - 8:  8<br>\nCorrect result - 8:  8<br>\nCorrect result - 2:  2<br>\nCorrect result - -2:  -2<br>\nCorrect result - 15:  15<br>\nCorrect result - 15:  15<br>\nCorrect result - 2:  2<br>\nCorrect result - 3:  3<br>\n*********************************<br>\n\n*** Testing real operators ***<br>\nCorrect result - 8:  8<br>\nCorrect result - 8:  8<br>\nCorrect result - 2:  2<br>\nCorrect result - -2:  -2<br>\nCorrect result - 15:  15<br>\nCorrect result - 15:  15<br>\nCorrect result - 2:  2<br>\nCorrect result - 3:  3<br>\n*********************************<br>\n\n*** Testing if/elseif/else control ***<br>\n\nThis  works<br>\nthis_still_works<br>\nshould_print<br>\n\n\n*** Seriously nested if\'s test ***<br>\n** spelling correction by kluzz **\nOnly two lines of text should follow:<br>\nthis should be displayed. should be:  $i=1, $j=0.  is:  $i=1, $j=0<br>\nthis is supposed to be displayed. should be:  $i=2, $j=4.  is:  $i=2, $j=4<br>\n3 loop iterations should follow:<br>\n2 4<br>\n3 4<br>\n4 4<br>\n**********************************<br>\n\n*** C-style else-if\'s ***<br>\nThis should be displayed<br>\n*************************<br>\n\n*** WHILE tests ***<br>\n0 is smaller than 20<br>\n1 is smaller than 20<br>\n2 is smaller than 20<br>\n3 is smaller than 20<br>\n4 is smaller than 20<br>\n5 is smaller than 20<br>\n6 is smaller than 20<br>\n7 is smaller than 20<br>\n8 is smaller than 20<br>\n9 is smaller than 20<br>\n10 is smaller than 20<br>\n11 is smaller than 20<br>\n12 is smaller than 20<br>\n13 is smaller than 20<br>\n14 is smaller than 20<br>\n15 is smaller than 20<br>\n16 is smaller than 20<br>\n17 is smaller than 20<br>\n18 is smaller than 20<br>\n19 is smaller than 20<br>\n20 equals 20<br>\n21 is greater than 20<br>\n22 is greater than 20<br>\n23 is greater than 20<br>\n24 is greater than 20<br>\n25 is greater than 20<br>\n26 is greater than 20<br>\n27 is greater than 20<br>\n28 is greater than 20<br>\n29 is greater than 20<br>\n30 is greater than 20<br>\n31 is greater than 20<br>\n32 is greater than 20<br>\n33 is greater than 20<br>\n34 is greater than 20<br>\n35 is greater than 20<br>\n36 is greater than 20<br>\n37 is greater than 20<br>\n38 is greater than 20<br>\n39 is greater than 20<br>\n*******************<br>\n\n\n*** Nested WHILEs ***<br>\nEach array variable should be equal to the sum of its indices:<br>\n${test00}[0] = 0<br>\n${test00}[1] = 1<br>\n${test00}[2] = 2<br>\n${test01}[0] = 1<br>\n${test01}[1] = 2<br>\n${test01}[2] = 3<br>\n${test02}[0] = 2<br>\n${test02}[1] = 3<br>\n${test02}[2] = 4<br>\n${test10}[0] = 1<br>\n${test10}[1] = 2<br>\n${test10}[2] = 3<br>\n${test11}[0] = 2<br>\n${test11}[1] = 3<br>\n${test11}[2] = 4<br>\n${test12}[0] = 3<br>\n${test12}[1] = 4<br>\n${test12}[2] = 5<br>\n${test20}[0] = 2<br>\n${test20}[1] = 3<br>\n${test20}[2] = 4<br>\n${test21}[0] = 3<br>\n${test21}[1] = 4<br>\n${test21}[2] = 5<br>\n${test22}[0] = 4<br>\n${test22}[1] = 5<br>\n${test22}[2] = 6<br>\n*********************<br>\n\n*** hash test... ***<br>\ncommented out...\n**************************<br>\n\n*** Hash resizing test ***<br>\nba<br>\nbaa<br>\nbaaa<br>\nbaaaa<br>\nbaaaaa<br>\nbaaaaaa<br>\nbaaaaaaa<br>\nbaaaaaaaa<br>\nbaaaaaaaaa<br>\nbaaaaaaaaaa<br>\nba<br>\n10<br>\nbaa<br>\n9<br>\nbaaa<br>\n8<br>\nbaaaa<br>\n7<br>\nbaaaaa<br>\n6<br>\nbaaaaaa<br>\n5<br>\nbaaaaaaa<br>\n4<br>\nbaaaaaaaa<br>\n3<br>\nbaaaaaaaaa<br>\n2<br>\nbaaaaaaaaaa<br>\n1<br>\n**************************<br>\n\n\n*** break/continue test ***<br>\n$i should go from 0 to 2<br>\n$j should go from 3 to 4, and $q should go from 3 to 4<br>\n  $j=3<br>\n    $q=3<br>\n    $q=4<br>\n  $j=4<br>\n    $q=3<br>\n    $q=4<br>\n$j should go from 0 to 2<br>\n  $j=0<br>\n  $j=1<br>\n  $j=2<br>\n$k should go from 0 to 2<br>\n    $k=0<br>\n    $k=1<br>\n    $k=2<br>\n$i=0<br>\n$j should go from 3 to 4, and $q should go from 3 to 4<br>\n  $j=3<br>\n    $q=3<br>\n    $q=4<br>\n  $j=4<br>\n    $q=3<br>\n    $q=4<br>\n$j should go from 0 to 2<br>\n  $j=0<br>\n  $j=1<br>\n  $j=2<br>\n$k should go from 0 to 2<br>\n    $k=0<br>\n    $k=1<br>\n    $k=2<br>\n$i=1<br>\n$j should go from 3 to 4, and $q should go from 3 to 4<br>\n  $j=3<br>\n    $q=3<br>\n    $q=4<br>\n  $j=4<br>\n    $q=3<br>\n    $q=4<br>\n$j should go from 0 to 2<br>\n  $j=0<br>\n  $j=1<br>\n  $j=2<br>\n$k should go from 0 to 2<br>\n    $k=0<br>\n    $k=1<br>\n    $k=2<br>\n$i=2<br>\n***********************<br>\n\n*** Nested file include test ***<br>\n<html>\nThis is Finish.phtml.  This file is supposed to be included\nfrom regression_test.phtml.  This is normal HTML.\nand this is PHP code, 2+2=4\n</html>\n********************************<br>\n\nTests completed.<br>\nLimor Ullmann is now Limor Baruch :I\n\n'


@need_php()
def test_regression(http):
    result = http.GET_BODY("/php/regression.php")
    assert result == EXPECTED
