znt/module/metric/test/model/isheadergroup.php

63 lines
3.5 KiB
PHP
Executable file
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/env php
<?php
/**
title=测试 metricModel::isHeaderGroup();
timeout=0
cid=17140
- 步骤1测试包含headerGroup属性的header数组 @1
- 步骤2测试不包含headerGroup属性的header数组 @0
- 步骤3测试空header数组 @0
- 步骤4测试null值输入 @0
- 步骤5测试包含多个headerGroup的复杂header数组 @1
- 步骤6测试包含空headerGroup值的header数组 @1
- 步骤7测试只有一个元素包含headerGroup的混合数组 @1
*/
include dirname(__FILE__, 5) . '/test/lib/init.php';
include dirname(__FILE__, 2) . '/lib/calc.unittest.class.php';
$metric = new metricTest();
// 测试数据准备包含headerGroup属性的header数组
$headerWithGroup = array();
$headerWithGroup[] = array('name' => 'scope', 'title' => 'projectname', 'fixed' => 'left', 'width' => 128);
$headerWithGroup[] = array('name' => '2023-12-19', 'title' => '12-19', 'headerGroup' => '2023年', 'align' => 'center', 'width' => 68);
$headerWithGroup[] = array('name' => '2023-12-16', 'title' => '12-16', 'headerGroup' => '2023年', 'align' => 'center', 'width' => 68);
// 测试数据准备不包含headerGroup属性的header数组
$headerWithoutGroup = array();
$headerWithoutGroup[] = array('name' => 'scope', 'title' => 'projectname', 'fixed' => 'left', 'width' => 128);
$headerWithoutGroup[] = array('name' => '2023-12-19', 'title' => '2023', 'align' => 'center', 'width' => 68);
// 测试数据准备空header数组
$emptyHeader = array();
// 测试数据准备包含多个headerGroup的复杂header数组
$complexHeaderWithGroup = array();
$complexHeaderWithGroup[] = array('name' => 'scope', 'title' => 'scope', 'width' => 100);
$complexHeaderWithGroup[] = array('name' => 'jan', 'title' => '1月', 'headerGroup' => '第一季度', 'width' => 80);
$complexHeaderWithGroup[] = array('name' => 'feb', 'title' => '2月', 'headerGroup' => '第一季度', 'width' => 80);
$complexHeaderWithGroup[] = array('name' => 'mar', 'title' => '3月', 'headerGroup' => '第一季度', 'width' => 80);
// 测试数据准备包含空headerGroup值的header数组
$headerWithEmptyGroup = array();
$headerWithEmptyGroup[] = array('name' => 'scope', 'title' => 'scope', 'width' => 100);
$headerWithEmptyGroup[] = array('name' => 'value', 'title' => 'value', 'headerGroup' => '', 'width' => 80);
// 测试数据准备只有一个元素包含headerGroup的混合数组
$mixedHeaderWithGroup = array();
$mixedHeaderWithGroup[] = array('name' => 'scope', 'title' => 'scope', 'width' => 100);
$mixedHeaderWithGroup[] = array('name' => 'value1', 'title' => 'value1', 'width' => 80);
$mixedHeaderWithGroup[] = array('name' => 'value2', 'title' => 'value2', 'headerGroup' => '分组', 'width' => 80);
r($metric->isHeaderGroup($headerWithGroup)) && p() && e('1'); // 步骤1测试包含headerGroup属性的header数组
r($metric->isHeaderGroup($headerWithoutGroup)) && p() && e('0'); // 步骤2测试不包含headerGroup属性的header数组
r($metric->isHeaderGroup($emptyHeader)) && p() && e('0'); // 步骤3测试空header数组
r($metric->isHeaderGroup(null)) && p() && e('0'); // 步骤4测试null值输入
r($metric->isHeaderGroup($complexHeaderWithGroup)) && p() && e('1'); // 步骤5测试包含多个headerGroup的复杂header数组
r($metric->isHeaderGroup($headerWithEmptyGroup)) && p() && e('1'); // 步骤6测试包含空headerGroup值的header数组
r($metric->isHeaderGroup($mixedHeaderWithGroup)) && p() && e('1'); // 步骤7测试只有一个元素包含headerGroup的混合数组