コード例 #1
0
ファイル: file.php プロジェクト: sniemela/limonade
function test_file_mime_type()
{
    $mimes = mime_type();
    assert_true(is_array($mimes));
    assert_not_empty($mimes);
    assert_empty(mime_type(''));
    assert_equal(mime_type('txt'), 'text/plain');
    assert_equal(mime_type('TXT'), 'text/plain');
    assert_equal(mime_type('jpg'), 'image/jpeg');
    assert_equal(mime_type('JPG'), 'image/jpeg');
}
コード例 #2
0
ファイル: router.php プロジェクト: robotmay/limonade
function test_router_route()
{
    assert_empty(route());
    $r = route("get", "/index", "my_func");
    assert_length_of($r, 1);
    assert_length_of($r[0], 5);
    assert_equal($r[0]["method"], "GET");
    assert_equal($r[0]["pattern"], "#^/index(?:/*?)?\$#i");
    assert_empty($r[0]["names"]);
    assert_equal($r[0]["function"], "my_func");
    assert_empty($r[0]["options"]);
    $r = route("put", "/blog/:id", "my_update_func");
    assert_length_of($r, 2);
    assert_length_of($r[1], 5);
    assert_equal($r[1]["method"], "PUT");
    assert_match($r[1]["pattern"], "/blog/102");
    assert_length_of($r[1]["names"], 1);
    assert_equal($r[1]["names"][0], "id");
    assert_equal($r[1]["function"], "my_update_func");
    assert_empty($r[1]["options"]);
    $r = route("post", "/blog/:id", "my_post_func", array('params' => array('extra' => 10)));
    assert_length_of($r[2], 5);
    assert_equal($r[2]["method"], "POST");
    assert_match($r[2]["pattern"], "/blog/102");
    assert_length_of($r[2]["names"], 1);
    assert_equal($r[2]["names"][0], "id");
    assert_equal($r[2]["function"], "my_post_func");
    assert_not_empty($r[2]["options"]);
    assert_not_empty($r[2]["options"]['params']);
    assert_equal($r[2]["options"]['params']['extra'], 10);
    $r = route("get", "/blog/:id", "my_get_func", array('params' => array('id' => 10)));
    assert_match($r[2]["pattern"], "/blog/102");
}
コード例 #3
0
ファイル: main.php プロジェクト: reith2004/limonade
   function test_main_require_once_dir()
   {
     $root = dirname(dirname(__FILE__));
     
     ob_start();
     assert_empty(require_once_dir($root));
     $files = require_once_dir($root, "AUTHORS");
     assert_empty(ob_get_contents());
     ob_clean();
     
     assert_length_of($files, 1);
     assert_match('/AUTHORS$/', $files[0]);
     
     ob_start();
     $files = require_once_dir($root, "CHANGES", false);
     assert_not_empty(ob_get_contents());
     ob_clean();
    
     $lib = $root.'/lib';
     // pb because it loads abstract.php that conflict with tests that use abstracts
     // $limonade = $lib.'/limonade';
     // 
     // $files = require_once_dir($limonade);
     // assert_not_empty($files);
     
     $tests_lib = $root.'/tests/data/lib0';
     $libs = array('a', 'b', 'c');
     foreach($libs as $lib) assert_false(defined('TEST_LIB_'.strtoupper($lib)));

     $files = require_once_dir($tests_lib);
     assert_not_empty($files);
     assert_length_of($files, 3);
     
     foreach($libs as $lib) assert_true(defined('TEST_LIB_'.strtoupper($lib)));
     
     assert_empty(require_once_dir($root.'/tests/data/'));
     assert_true(is_array(require_once_dir($root.'/tests/data/')));
     
     assert_empty(require_once_dir($root.'/tests/data/unknown_dir'));
     assert_true(is_array(require_once_dir($root.'/tests/data/unknown_dir')));
   }
コード例 #4
0
ファイル: main.php プロジェクト: sniemela/limonade
function test_main_require_once_dir()
{
    $root = dirname(dirname(__FILE__));
    ob_start();
    assert_empty(require_once_dir($root));
    $files = require_once_dir($root, "AUTHORS");
    ob_clean();
    assert_length_of($files, 1);
    assert_match('/AUTHORS$/', $files[0]);
    $lib = $root . '/lib';
    $limonade = $lib . '/limonade';
    $files = require_once_dir($limonade);
    assert_not_empty($files);
    $tests_lib = $root . '/tests/data/lib0';
    $libs = array('a', 'b', 'c');
    foreach ($libs as $lib) {
        assert_false(defined('TEST_LIB_' . strtoupper($lib)));
    }
    $files = require_once_dir($tests_lib);
    assert_not_empty($files);
    assert_length_of($files, 3);
    foreach ($libs as $lib) {
        assert_true(defined('TEST_LIB_' . strtoupper($lib)));
    }
    assert_empty(require_once_dir($root . '/tests/data/'));
    assert_true(is_array(require_once_dir($root . '/tests/data/')));
    assert_empty(require_once_dir($root . '/tests/data/unknown_dir'));
    assert_true(is_array(require_once_dir($root . '/tests/data/unknown_dir')));
}
コード例 #5
0
    $oA_L = new ECPayLogistics();
    $oA_L->HashKey = TestC2CMerchantInfo::HASH_KEY;
    $oA_L->HashIV = TestC2CMerchantInfo::HASH_IV;
    $oA_L->Send = array("MerchantID" => TestC2CMerchantInfo::MERCHANT_ID, "AllPayLogisticsID" => "11810", "CVSPaymentNo" => "05902347158", "PlatformID" => "");
    // PrintFamilyC2CBill(Button 名稱, Form target)
    $sTest_Result = $oA_L->PrintFamilyC2CBill("列印全家小白單(全家超商 C2C)");
} catch (Exception $e) {
    $sTest_Result = $e->getMessage();
    unset($e);
}
assert_have($sTest_Result, "ECPayForm", $sTest_Subject);
unset($sHome_URL, $oA_L, $sTest_Subject, $sTest_Result);
/**
 * CheckMacValue 驗證功能(CheckOutFeedback)
 */
$sTest_Subject = "ECPay CheckMacValue 驗證功能(CheckOutFeedback)";
$sTest_Result = "";
$sHome_URL = "http://www.sample.com.tw";
$aTest_POST = array("MerchantID" => TestMerchantInfo::MERCHANT_ID, "MerchantTradeNo" => "no20160816070914", "MerchantTradeDate" => "2016/08/16 07:09:14", "LogisticsType" => "Home", "LogisticsSubType" => "TCAT", "GoodsAmount" => "1500", "IsCollection" => "N", "GoodsName" => "測試商品", "SenderName" => "測試寄件者", "SenderPhone" => "0226550115", "SenderCellPhone" => "0911222333", "ReceiverName" => "測試收件者", "ReceiverPhone" => "0226550115", "ReceiverCellPhone" => "0933222111", "ReceiverEmail" => "*****@*****.**", "TradeDesc" => "測試交易敘述", "ServerReplyURL" => $sHome_URL . "/ServerReplyURL.php", "ClientReplyURL" => $sHome_URL . "/ClientReplyURL.php", "LogisticsC2CReplyURL" => $sHome_URL . "/LogisticsC2CReplyURL.php", "Remark" => "測試備註", "PlatformID" => "", "SenderZipCode" => "11560", "SenderAddress" => "台北市南港區三重路 19-2 號 10 樓 D 棟", "ReceiverZipCode" => "11560", "ReceiverAddress" => "台北市南港區三重路 19-2 號 5 樓 D 棟", "Temperature" => "0003", "Distance" => "01", "Specification" => "0004", "ScheduledDeliveryTime" => "3", "ScheduledPickupTime" => "4", "CheckMacValue" => "BE972990BFE7BE986E33EE4673D37A45");
try {
    $oA_L = new ECPayLogistics();
    $oA_L->HashKey = TestMerchantInfo::HASH_KEY;
    $oA_L->HashIV = TestMerchantInfo::HASH_IV;
    // CheckOutFeedback(POST 參數)
    $oA_L->CheckOutFeedback($aTest_POST);
} catch (Exception $e) {
    $sTest_Result = $e->getMessage();
    unset($e);
}
assert_empty($sTest_Result, $sTest_Subject);
unset($sHome_URL, $oA_L, $sTest_Subject, $sTest_Result, $aTest_POST);
コード例 #6
0
ファイル: router.php プロジェクト: sniemela/limonade
function test_router_route()
{
    assert_empty(route());
    $r = route("get", "/index", "my_func");
    assert_length_of($r, 1);
    assert_length_of($r[0], 4);
    assert_equal($r[0]["method"], "GET");
    assert_equal($r[0]["pattern"], "#^/index(?:/*?)?\$#i");
    assert_empty($r[0]["names"]);
    assert_equal($r[0]["function"], "my_func");
    $r = route("put", "/blog/:id", "my_update_func");
    assert_length_of($r, 2);
    assert_length_of($r[1], 4);
    assert_equal($r[1]["method"], "PUT");
    assert_match($r[1]["pattern"], "/blog/102");
    assert_length_of($r[1]["names"], 1);
    assert_equal($r[1]["names"][0], "id");
    assert_equal($r[1]["function"], "my_update_func");
}