|
@@ -0,0 +1,68 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+
|
|
|
+use PHPUnit\Framework\TestCase;
|
|
|
+
|
|
|
+define('APP_ID', 'test');
|
|
|
+define('BASE_ROOT_PATH', str_replace('/test', '', dirname(__FILE__)));
|
|
|
+
|
|
|
+require_once(BASE_ROOT_PATH . '/global.php');
|
|
|
+require_once(BASE_CORE_PATH . '/lrlz.php');
|
|
|
+require_once(BASE_ROOT_PATH . '/fooder.php');
|
|
|
+
|
|
|
+class TestAccount extends TestCase
|
|
|
+{
|
|
|
+ public static function setUpBeforeClass(): void
|
|
|
+ {
|
|
|
+ Base::run_util();
|
|
|
+ }
|
|
|
+
|
|
|
+ public function testLog()
|
|
|
+ {
|
|
|
+ $files = ['65937-81.log','65937-45.log','65937-175.log'];
|
|
|
+
|
|
|
+ $total = 0.0;
|
|
|
+ foreach ($files as $file)
|
|
|
+ {
|
|
|
+ $amount = $this->parase_file($file);
|
|
|
+ $total += $amount;
|
|
|
+ Log::record("total={$total} {$file} amount = {$amount}",Log::DEBUG);
|
|
|
+ }
|
|
|
+
|
|
|
+ Log::record("total = {$total}",Log::DEBUG);
|
|
|
+ }
|
|
|
+
|
|
|
+ private function parase_file($file)
|
|
|
+ {
|
|
|
+ $fn = fopen(BASE_ROOT_PATH . "/data/amount/{$file}", "r");
|
|
|
+
|
|
|
+
|
|
|
+ $total_amount = ncPriceFormat(0.00);
|
|
|
+
|
|
|
+ $i = 0;
|
|
|
+ while (!feof($fn)) {
|
|
|
+ $i++;
|
|
|
+ $line = trim(fgets($fn));
|
|
|
+ $ret = preg_match('/[\w\W]+UPDATE[\w\W]+available_predeposit=available_predeposit(?P<oper>[-+]+)(?P<amount>[.\d]+)/i', $line, $matches);
|
|
|
+ if ($ret)
|
|
|
+ {
|
|
|
+ $oper = $matches['oper'];
|
|
|
+ $amount = $matches['amount'];
|
|
|
+ if ($oper == '-') {
|
|
|
+ $total_amount = ncPriceFormat($total_amount) - ncPriceFormat($amount);
|
|
|
+
|
|
|
+ } else {
|
|
|
+ $total_amount = ncPriceFormat($total_amount) + ncPriceFormat($amount);
|
|
|
+ }
|
|
|
+
|
|
|
+ Log::record("index = {$i} {$total_amount} = {$total_amount} {$oper} {$amount}", Log::DEBUG);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ Log::record("total_amount:{$total_amount}", Log::DEBUG);
|
|
|
+ fclose($fn);
|
|
|
+
|
|
|
+ return $total_amount;
|
|
|
+ }
|
|
|
+}
|
|
|
+//docker-compose run phpcli php /var/www/html/phpunit-9.2.5.phar --filter "/(TestAccount::testLog)( .*)?$/" --test-suffix TestAccount.php /var/www/html/test
|