Example #1
0
<?php

$b = new \testman\Browser();
$b->do_get(url('test_index::redirect_by_map_method_a'));
eq(200, $b->status());
eq('REDIRECT_A', $b->body());
$b->do_get(url('test_index::redirect_by_map_method_b'));
eq(200, $b->status());
eq('REDIRECT_B', $b->body());
$b->do_get(url('test_index::redirect_by_map_method_c'));
eq(200, $b->status());
eq('REDIRECT_C', $b->body());
<?php

$b = new \testman\Browser();
$b->do_get(url('test_index::module_throw_exception'));
eq(403, $b->status());
meq('<message group="" type="LogicException">flow handle begin exception</message>', $b->body());
Example #3
0
<body>
\t<a href="http://rhaco.org"></a>
\t<a href="http://localhost/rhaco3/test_index/"></a>
\t<a href="https://localhost/rhaco3/test_index/secure"></a>
\t<a href="https://localhost/rhaco3/test_login/secure"></a>
\t<img src="http://localhost/images/abc.jpg" />
\t<img src="http://localhost/rhaco3/resources/media/images/def.jpg" />
\t<img src="http://localhost/rhaco3/resources/media/images/def.jpg" />
</body>
</html>
PRE;
} else {
    $pre = <<<PRE
<html>
<body>
\t<a href="http://rhaco.org"></a>
\t<a href="http://localhost:8000/test_index.php/"></a>
\t<a href="https://localhost:8000/test_index.php/secure"></a>
\t<a href="https://localhost:8000/test_login.php/secure"></a>
\t<img src="http://localhost/images/abc.jpg" />
\t<img src="http://localhost:8000/resources/media/images/def.jpg" />
\t<img src="http://localhost:8000/resources/media/images/def.jpg" />
</body>
</html>
PRE;
}
meq('https://', url('test_login::secure'));
$b = new \testman\Browser();
$b->do_get(url('test_index::to_secure'));
eq(200, $b->status());
eq($pre, $b->body());
Example #4
0
<?php

$b = new \testman\Browser();
$b->do_get(url('test_index::index'));
eq(200, $b->status());
meq('INDEX', $b->body());
meq('hogehoge_xml_var', $b->body());
meq('A1A2A3', $b->body());
meq('	hogehoge_xml_var_value', $b->body());
meq('[AAA]', $b->body());
meq('[BBB]', $b->body());
meq('AAA', $b->body());
meq('BBB', $b->body());
meq('CCC', $b->body());
meq('resources/media', $b->body());
Example #5
0
<?php

$b = new \testman\Browser();
$b->vars('user_name', 'hogeuser');
$b->vars('password', 'hogehoge');
$b->do_post(url('test_login::login'));
eq(200, $b->status());
meq('<user_name>hogeuser</user_name>', $b->body());
$b->do_post(url('test_login::aaa'));
eq(200, $b->status());
meq('<user><nickname>hogeuser</nickname><code>1234</code></user>', $b->body());
$b->do_post(url('test_login::logout'));
eq(200, $b->status());
meq('<login>false</login>', $b->body());
$b->do_post(url('test_login::aaa'));
eq(401, $b->status());
meq('<message group="do_login" type="LogicException">Unauthorized</message>', $b->body());
Example #6
0
<?php

$b = new \testman\Browser();
$b->do_get(url('test_index::template_super_a'));
eq('abcd', $b->body());
$b->do_get(url('test_index::template_super_b'));
eq('xc', $b->body());
Example #7
0
<?php

$b = new \testman\Browser();
$b->do_get(url('test_index::helper_range'));
meq('A1234A', $b->body());
meq('B12345B', $b->body());
meq('C12345678C', $b->body());
<?php

$b = new \testman\Browser();
$b->do_get(url('test_index::sample_flow_exception_package_throw_xml'));
eq(403, $b->status());
meq('<message group="" type="SampleException">sample error</message>', $b->body());
Example #9
0
<?php

$b = new \testman\Browser();
$b->do_get(url('test_index::module_request_flow'));
eq(200, $b->status());
meq('INDEX', $b->body());
meq('BEFORE_FLOW_HANDLE', $b->body());
meq('AFTER_FLOW_HANDLE', $b->body());
meq('INIT_TEMPLATE', $b->body());
meq('BEFORE_TEMPLATE', $b->body());
meq('AFTER_TEMPLATE', $b->body());
meq('BEFORE_EXEC_TEMPLATE', $b->body());
meq('AFTER_EXEC_TEMPLATE', $b->body());
meq('BEFORE_FLOW_PRINT_TEMPLATE', $b->body());
Example #10
0
<?php

$b = new \testman\Browser();
$b->do_post(url('test_index::dao/insert'));
$b->do_post(url('test_index::dao/get'));
meq('<string>abcdefg</string><text />', $b->body());
eq(200, $b->status());
meq('<string>abcdefg</string><text />', $b->body());
$b = new \testman\Browser();
$b->do_post(url('test_index::dao/update'));
$b->do_post(url('test_index::dao/get'));
meq('<string>abcdefg</string><text>xyz</text>', $b->body());
$b = new \testman\Browser();
$b->do_post(url('test_index::dao/delete'));
$b = new \testman\Browser();
$b->do_post(url('test_index::dao/insert'));
$b->do_post(url('test_index::dao/get'));
meq('<string>abcdefg</string><text />', $b->body());
$b = new \testman\Browser();
$b->do_post(url('test_index::dao/update'));
$b->do_post(url('test_index::dao/get'));
meq('<string>abcdefg</string><text>xyz</text>', $b->body());
$b = new \testman\Browser();
$b->do_post(url('test_index::dao/delete'));
eq('<result />', $b->body());
Example #11
0
<?php

$b = new \testman\Browser();
$b->do_get(url('test_index::notemplate'));
eq(200, $b->status());
eq('<result><abc>ABC</abc><newtag><hoge>HOGE</hoge></newtag></result>', $b->body());
Example #12
0
<?php

$b = new \testman\Browser();
$b->do_get(url('test_index::under_var'));
eq(200, $b->status());
meq('hogehoge', $b->body());
meq('ABC', $b->body());
meq('INIT', $b->body());
Example #13
0
<?php

$b = new \testman\Browser();
$b->do_get(url('test_index::csrf'));
eq(200, $b->status());
meq('<result>', $b->body());
$b->do_post(url('test_index::csrf'));
eq(403, $b->status());
meq('<error>', $b->body());
$b->do_get(url('test_index::csrf'));
eq(200, $b->status());
meq('<result>', $b->body());
$no = null;
if (\org\rhaco\Xml::set($xml, $b->body(), 'csrftoken')) {
    $no = $xml->value();
}
neq(null, $no);
$b->vars('csrftoken', $no);
$b->do_post(url('test_index::csrf'));
eq(200, $b->status());
meq('<result>', $b->body());
$b->do_get(url('test_index::csrf_template'));
eq(200, $b->status());
meq('<form><input type="hidden" name="csrftoken"', $b->body());
meq('<form method="post"><input type="hidden" name="csrftoken"', $b->body());
meq('<form method="get"><input type="hidden" name="csrftoken"', $b->body());
meq(sprintf('<form action="%s"><input type="hidden" name="csrftoken"', url('test_index::csrf')), $b->body());
meq('<form action="http://localhost"><input type="text" name="aaa" /></form>', $b->body());
Example #14
0
<?php

$b = new \testman\Browser();
$b->do_get(url('test_index::after'));
eq(200, $b->status());
eq(url('test_index::after_to'), $b->url());
$b->do_get(url('test_index::after_arg1'));
eq(200, $b->status());
eq(url('test_index::after_to_arg1', 'ABC'), $b->url());
$b->do_get(url('test_index::after_arg2'));
eq(200, $b->status());
eq(url('test_index::after_to_arg2', 'ABC', 'DEF'), $b->url());
$b->do_get(url('test_index::post_after'));
eq(200, $b->status());
eq(url('test_index::post_after'), $b->url());
$b->do_post(url('test_index::post_after'));
eq(200, $b->status());
eq(url('test_index::post_after_to'), $b->url());
$b->do_post(url('test_index::post_after_arg1'));
eq(200, $b->status());
eq(url('test_index::post_after_to_arg1', 'ABC'), $b->url());
$b->do_post(url('test_index::post_after_arg2'));
eq(200, $b->status());
eq(url('test_index::post_after_to_arg2', 'ABC', 'DEF'), $b->url());
Example #15
0
<?php

$b = new \testman\Browser();
$b->do_get(url('test_index::noop'));
eq(200, $b->status());
eq('<result><init_var>INIT</init_var></result>', $b->body());
Example #16
0
<?php

$b = new \testman\Browser();
$b->do_get(url('test_index::sample_flow_exception_throw'));
eq('ERROR', $b->body());
$b->do_get(url('test_login::aaa'));
eq(401, $b->status());
eq(url('test_login::login'), $b->url());
meq('<message group="do_login" type="LogicException">Unauthorized</message>', $b->body());
<?php

$b = new \testman\Browser();
$b->do_get(url('test_index::module_add_exceptions'));
eq(200, $b->status());
meq('INDEX', $b->body());
meq('BEFORE_FLOW', $b->body());
meq('AFTER_FLOW', $b->body());
meq('INIT_TEMPLATE', $b->body());
meq('BEFORE_TEMPLATE', $b->body());
meq('AFTER_TEMPLATE', $b->body());
meq('BEFORE_FLOW_PRINT_TEMPLATE', $b->body());
Example #18
0
<?php

$b = new \testman\Browser();
$b->vars('user_name', 'aaaa');
$b->vars('password', 'bbbb');
$b->do_get(url('test_login::login'));
eq(401, $b->status());
meq('<message group="do_login" type="LogicException">Unauthorized</message>', $b->body());
Example #19
0
<?php

$b = new \testman\Browser();
$b->do_post(url('test_login::login'));
eq(401, $b->status());
meq('<message group="do_login" type="LogicException">Unauthorized</message>', $b->body());
Example #20
0
<?php

$b = new \testman\Browser();
$b->do_get(url('test_index::module_raise'));
eq(403, $b->status());
mneq('INDEX', $b->body());
meq('BEFORE_FLOW_HANDLE', $b->body());
meq('[EXCEPTION]', $b->body());
meq('INIT_TEMPLATE', $b->body());
meq('BEFORE_TEMPLATE', $b->body());
meq('AFTER_TEMPLATE', $b->body());
meq('BEFORE_FLOW_PRINT_TEMPLATE', $b->body());
Example #21
0
<?php

$b = new \testman\Browser();
$b->vars('value1', 'abcd');
$b->do_post(url('test_index::upload_value'));
if (!\org\rhaco\Xml::set($xml, $b->body(), 'result')) {
    throw new \LogicException('no result');
}
eq('abcd', $xml->f('get_data1.value()'));
$b->file_vars('upfile1', __FILE__);
$b->do_post(url('test_index::upload_file'));
\org\rhaco\Xml::set($xml, $b->body(), 'result');
eq(basename(__FILE__), $xml->f('original_name1.value()'));
eq(filesize(__FILE__), (int) $xml->f('size1.value()'));
eq('true', $xml->f('mv1.value()'));
eq(filesize(__FILE__), (int) $xml->f('mv_size1.value()'));
eq(file_get_contents(__FILE__), $xml->f('data1.value()'));
$b->vars('value1', 'abcd');
$b->file_vars('upfile1', __FILE__);
$b->vars('value2', 'efg');
$b->file_vars('upfile2', __FILE__);
$b->do_post(url('test_index::upload_multi'));
\org\rhaco\Xml::set($xml, $b->body(), 'result');
eq(basename(__FILE__), $xml->f('original_name1.value()'));
eq(filesize(__FILE__), (int) $xml->f('size1.value()'));
eq('true', $xml->f('mv1.value()'));
eq(filesize(__FILE__), (int) $xml->f('mv_size1.value()'));
eq(file_get_contents(__FILE__), $xml->f('data1.value()'));
eq(basename(__FILE__), $xml->f('original_name2.value()'));
eq(filesize(__FILE__), (int) $xml->f('size2.value()'));
eq('true', $xml->f('mv2.value()'));
Example #22
0
<?php

$b = new \testman\Browser();
$b->do_get(url('test_index::rt_exceptions'));
meq('hoge', $b->body());
Example #23
0
<?php

$b = new \testman\Browser();
$b->do_get(url('test_index::map_url'));
if (\org\rhaco\Conf::appmode() == 'mamp') {
    meq('test_index/noop', $b->body());
    meq('test_login/aaa', $b->body());
} else {
    meq('test_index.php/noop', $b->body());
    meq('test_login.php/aaa', $b->body());
}
<?php

$b = new \testman\Browser();
$b->do_get(url('test_index::sample_flow_exception_throw_xml'));
eq(403, $b->status());
meq('<message group="" type="LogicException">error</message></error>', $b->body());
Example #25
0
<?php

$b = new \testman\Browser();
$b->do_get(url('test_index::get_session'));
eq('<result><abc /></result>', $b->body());
$b->vars('abc', 'hoge');
$b->do_get(url('test_index::set_session'));
$b->do_get(url('test_index::get_session'));
eq('<result><abc>hoge</abc></result>', $b->body());
$b = new \testman\Browser();
$b->do_get(url('test_index::get_session'));
eq('<result><abc /></result>', $b->body());
$b->vars('abc', 'hoge');
$b->vars('redirect', url('test_index::get_session'));
$b->do_get(url('test_index::set_session'));
eq('<result><abc>hoge</abc></result>', $b->body());
eq(url('test_index::get_session'), $b->url());
$b = new \testman\Browser();
$b->do_get(url('test_index::get_session'));
eq('<result><abc /></result>', $b->body());
$b->vars('abc', 'hoge');
$b->vars('redirect', url('test_index::plain_noop'));
$b->do_get(url('test_index::set_session'));
$b->do_get(url('test_index::get_session'));
eq('<result><abc>hoge</abc></result>', $b->body());
Example #26
0
<?php

$b = new \testman\Browser();
$b->do_get(url('test_index::method_not_allowed'));
eq(405, $b->status());
meq('<message group="" type="LogicException">Method Not Allowed</message>', $b->body());
<?php

$b = new \testman\Browser();
$b->do_get(url('test_index::sample_flow_exception_throw'));
eq('ERROR', $b->body());
Example #28
0
<?php

$b = new \testman\Browser();
$b->do_get(url('test_index::raise'));
eq(403, $b->status());
Example #29
0
<?php

$b = new \testman\Browser();
$b->do_get(url('test_index::html_filter'));
meq('PPPPP', $b->body());
meq('&lt;tag&gt;QQQ&lt;/tag&gt;', $b->body());
meq('<input type="text" name="aaa" value="hogehoge" />', $b->body());
meq('<input type="text" name="ttt" value="&lt;tag&gt;ttt&lt;/tag&gt;" />', $b->body());
meq('<input type="checkbox" name="bbb[]" value="hoge" checked="checked" />hoge', $b->body());
meq('<input type="checkbox" name="bbb[]" value="fuga" />fuga', $b->body());
meq('<input type="checkbox" name="eee[]" value="true" checked="checked" />foo', $b->body());
meq('<input type="checkbox" name="fff[]" value="false" checked="checked" />foo', $b->body());
meq('<input type="submit" />', $b->body());
meq('<textarea name="aaa">hogehoge</textarea>', $b->body());
meq('<textarea name="ttt">&lt;tag&gt;ttt&lt;/tag&gt;</textarea>', $b->body());
meq('<option value="456" selected="selected">456</option>', $b->body());
meq('<option value="789" selected="selected">789</option>', $b->body());
meq('<select name="XYZ"><option value="A">456</option><option value="B" selected="selected">789</option><option value="C">010</option></select>', $b->body());
Example #30
0
<?php

$b = new \testman\Browser();
$b->do_get(url('test_index::module_order'));
eq(200, $b->status());
eq('345678910', $b->body());