Example #1
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 #2
0
<?php

$b = b();
$b->vars('abc', 'aaa');
$b->do_get(url('index::group_aaa'));
meq('{"result":{"abc":"aaa"}}', $b->body());
$b->vars('abc', 'bbb');
$b->do_get(url('index::group_bbb'));
meq('{"result":{"abc":"bbb"}}', $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->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 #5
0
<?php

$b = b();
$b->do_get(url('index::form_obj'));
meq('ABC', $b->body());
meq(10, $b->body());
meq(999, $b->body());
$b->do_get(url('index::form_obj') . '?value=XYZ');
mneq('ABC', $b->body());
meq('XYZ', $b->body());
meq(10, $b->body());
meq(999, $b->body());
Example #6
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 #7
0
<?php

/**
 * login要求のaction
 */
$b = b();
// loginにリダイレクトされる
$b->do_get(url('login3::aaa'));
eq(401, $b->status());
eq(url('login3::login'), $b->url());
eq('{"error":[{"message":"Unauthorized","type":"UnauthorizedException"}]}', $b->body());
// ログインしたらaaaに戻る
$b->vars('user', 'tokushima');
$b->vars('password', 'hogehoge');
$b->do_post(url('login3::login'));
eq(url('login3::aaa'), $b->url());
eq(200, $b->status());
// ログイン済みならリダイレクトされない
$b->do_get(url('login3::aaa'));
eq(url('login3::aaa'), $b->url());
eq(200, $b->status());
meq('{"result":{"abc":123}}', $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 = b();
$b->vars('abc', 'aaa');
$b->do_get(url('index::group_aaa_xml'));
eq(200, $b->status());
meq('<result><abc>aaa</abc></result>', $b->body());
$b->vars('abc', 'bbb');
$b->do_get(url('index::group_bbb_xml'));
eq(200, $b->status());
meq('<result><abc>bbb</abc></result>', $b->body());
$b->vars('abc', 'bbb');
$b->do_get(url('index::group_eee_xml'));
eq(200, $b->status());
eq('<error><message type="LogicException">raise test</message></error>', $b->body());
// json output
$b = b();
$b->header('Accept', 'application/json');
$b->vars('abc', 'aaa');
$b->do_get(url('index::group_aaa_xml'));
eq(200, $b->status());
meq('{"result":{"abc":"aaa"}}', $b->body());
$b->header('Accept', 'application/json');
$b->vars('abc', 'bbb');
$b->do_get(url('index::group_eee_xml'));
eq(200, $b->status());
eq('{"error":[{"message":"raise test","type":"LogicException"}]}', $b->body());
Example #10
0
<?php

$b = b();
$b->do_get(url('index::requestflow_vars_template'));
eq(200, $b->status());
meq('<html>', $b->body());
meq('AAA123456BBB', $b->body());
$b->header('accept', 'application/debug');
$b->do_get(url('index::requestflow_vars_template'));
eq(200, $b->status());
eq('{"result":{"abc":123,"def":456}}', $b->body());
Example #11
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 #12
0
<?php

$b = new \ebi\Browser();
$b->do_get(url('index::form1'));
$b->vars('id1', 'abc');
\ebi\HtmlForm::submit($b);
meq('ID1=abc', $b->body());
$b->vars('id2', 'def');
\ebi\HtmlForm::submit($b, 'next_form');
meq('ID2=def', $b->body());
$b->vars('id3', 'ghi');
\ebi\HtmlForm::submit($b);
meq('ID3=ghi', $b->body());
$b->do_get(url('index::form_select'));
meq('<select name="data_id"><option value="10">AAA</option><option value="20" selected="selected">BBB</option><option value="30">CCC</option></select>', $b->body());
$b->do_get(url('index::form_select_obj'));
meq('<select name="data_id"><option value="10">AAA</option>
<option value="20" selected="selected">BBB</option>
<option value="30">CCC</option>
</select>', $b->body());
Example #13
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 #14
0
<?php

$b = b();
$b->do_get(url('index::template_parent'));
eq(200, $b->status());
meq('Parent', $b->body());
meq('default_child', $b->body());
$b->do_get(url('index::template_child'));
eq(200, $b->status());
meq('Parent', $b->body());
mneq('default_child', $b->body());
meq('new_child', $b->body());
meq('default_grandchild', $b->body());
$b->do_get(url('index::template_grandchild'));
eq(200, $b->status());
meq('Parent', $b->body());
mneq('default_child', $b->body());
meq('new_child', $b->body());
mneq('default_grandchild', $b->body());
meq('new_grandchild', $b->body());
$b->do_get(url('index::template_grandchild_super'));
eq(200, $b->status());
mneq('Parent', $b->body());
meq('Super', $b->body());
mneq('default_super_child', $b->body());
meq('new_child', $b->body());
mneq('default_grandchild', $b->body());
meq('new_grandchild', $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 #16
0
<?php

$mail = new \ebi\Mail();
$mail->message("メッセージ");
eq("メッセージ", $mail->get('message'));
meq('B%a%C%;!<%8', $mail->manuscript());
$mail = new \ebi\Mail();
$mail->message("メッセージ");
$mail->attach('hoge.txt', 'ほげ');
eq("メッセージ", $mail->get('message'));
meq('B%a%C%;!<%8', $mail->manuscript());
meq('44G744GS', $mail->manuscript());
$mail = new \ebi\Mail();
$mail->message("メッセージ");
$mail->html('<html><body>ふご</body></html>');
eq("メッセージ", $mail->get('message'));
meq('B%a%C%;!<%8', $mail->manuscript());
meq('B$U$4', $mail->manuscript());
$mail = new \ebi\Mail();
$mail->message("メッセージ");
$mail->attach('hoge.txt', 'ほげ');
$mail->html('<html><body>ふご</body></html>');
eq("メッセージ", $mail->get('message'));
meq('B%a%C%;!<%8', $mail->manuscript());
meq('B$U$4', $mail->manuscript());
meq('44G744GS', $mail->manuscript());
Example #17
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());
Example #18
0
<?php

include __DIR__ . '/mix_entry.php';
$b = new \testman\Browser();
$b->do_get(url('test_index::noop'));
eq(200, $b->status());
meq('<init_var>INIT</init_var>', $b->body());
Example #19
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());
}
Example #20
0
<?php

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

$mail = new \ebi\Mail();
$mail->subject("改行は\r\n削除される");
eq("改行は削除される", $mail->get('subject'));
meq('Subject: =?ISO-2022-JP?B?GyRCMn45VCRPOm89fCQ1JGwkaxsoQg==?=', $mail->manuscript());
<?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 #23
0
<?php

$vars = array('abc' => 'ABC');
$mail = new \org\rhaco\net\mail\Mail();
$mail->to("*****@*****.**");
$mail->send_template('send.xml', $vars);
$xml = \org\rhaco\Dt::find_mail('*****@*****.**');
eq('ボディーテストABC' . PHP_EOL, $xml->message());
eq('テストサブジェクト', $xml->subject());
$vars = array('abc' => 'ABC');
$mail = new \org\rhaco\net\mail\Mail();
$mail->to("*****@*****.**");
$mail->send_template('send_html.xml', $vars);
$xml = \org\rhaco\Dt::find_mail('*****@*****.**');
eq('ボディーテストABC' . PHP_EOL, $xml->message());
eq('テストサブジェクト', $xml->subject());
meq('Content-Type: text/html;', $xml->manuscript());
meq('<p class="abc">ピーボディー</p>', mb_convert_encoding($xml->manuscript(), 'UTF8', 'JIS'));
meq('send_html.css', mb_convert_encoding($xml->manuscript(), 'UTF8', 'JIS'));
Example #24
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::module_throw_exception'));
eq(403, $b->status());
meq('<message group="" type="LogicException">flow handle begin exception</message>', $b->body());
Example #26
0
<?php

$b = b();
$b->do_get(url('login1::notype'));
eq(401, $b->status());
eq(url('login1::login'), $b->url());
eq('{"error":[{"message":"Unauthorized","type":"UnauthorizedException"}]}', $b->body());
// ログインするとlogged_in_afterに従いリダイレクトする
$b->vars('user', 'tokushima');
$b->vars('password', 'hogehoge');
$b->do_post(url('login1::login'));
eq(200, $b->status());
eq(url('login1::aaa'), $b->url());
// ログインしてればリダイレクトしない
$b->do_get(url('login1::notype'));
eq(url('login1::notype'), $b->url());
eq(200, $b->status());
meq('{"result":{"abc":123}}', $b->body());
// ログアウト
$b->do_post(url('login1::logout'));
eq(200, $b->status());
eq(url('login1::logout'), $b->url());
eq([], $b->json('result'));
// ログアウトしたのでまたログインへ
$b->do_get(url('login1::notype'));
eq(401, $b->status());
eq(url('login1::login'), $b->url());
meq('{"error":[{"message":"Unauthorized","type":"UnauthorizedException"}]}', $b->body());
Example #27
0
<html>
<body>
<form method="post">
<input type="text" name="user_name" />
<input type="password" name="password" />
<input type="submit" />
</form>
</body>
</html>
HTML;
$b = b();
$b->do_get(url('login_html::login'));
eq(401, $b->status());
eq(url('login_html::login'), $b->url());
eq($login_html, $b->body());
$b->vars('user', 'tokushima');
$b->vars('password', 'hogehoge');
$b->do_post(url('login_html::login'));
eq(200, $b->status());
eq(url('login_html::aaa'), $b->url());
eq(200, $b->status());
meq('{"result":{"abc":123}}', $b->body());
$b->do_post(url('login_html::logout'));
eq(200, $b->status());
eq(url('login_html::logout'), $b->url());
eq([], $b->json('result'));
$b->do_get(url('login_html::aaa'));
eq(401, $b->status());
eq(url('login_html::login'), $b->url());
meq($login_html, $b->body());
Example #28
0
<?php

$b = b();
$b->do_get(url('index::raise_template'));
eq(200, $b->status());
meq('Error: raise test', $b->body());
mneq('rt:invalid', $b->body());
$b->do_get(url('index::raise_template_parent'));
eq(200, $b->status());
meq('Error: raise test', $b->body());
mneq('rt:invalid', $b->body());
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 = b();
$b->do_get(url('index::map_url'));
meq(url('index::template_abc'), $b->body());
mneq(url('index::abc'), $b);