znt/module/upgrade/test/model/hasconsistencyerror.php

52 lines
1.5 KiB
PHP
Raw Permalink Normal View History

#!/usr/bin/env php
<?php
declare(strict_types=1);
/**
title=测试 upgradeModel->hasConsistencyError();
cid=19533
- 当前日志文件不存在返回false @0
- 当前日志文件存在但倒数两行没有错误信息返回false @0
- 当前日志文件存在但包含错误返回true @1
**/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/model.class.php';
global $app;
$path = $app->getTmpRoot() . 'log/';
$filename = 'consistency.%s.log.php';
function genFile(string $filename, array $contents)
{
$contents = implode("\n", $contents);
file_put_contents($filename, $contents);
}
$filePath = sprintf($path . $filename, date('Ymd'));
$upgrade = new upgradeModelTest();
if(file_exists($filePath)) unlink($filePath);
r($upgrade->hasConsistencyError()) && p('') && e(0); //当前日志文件不存在返回false
$contents = array(
'success',
'your zentao has been upgraded successfully.',
);
genFile($filePath, $contents);
r($upgrade->hasConsistencyError()) && p('') && e(0); //当前日志文件存在但倒数两行没有错误信息返回false
if(file_exists($filePath)) unlink($filePath);
$filePath = sprintf($path . $filename, date('Ymd'));
$contents = array(
'HasError',
'you have some consistency errors in your zentao.',
);
genFile($filePath, $contents);
r($upgrade->hasConsistencyError()) && p('') && e(1); //当前日志文件存在但包含错误返回true