#!/usr/bin/env php printCell() cid=1 pid=1 */ function call($programplan, $col, $plan, $users, $productID) { ob_start(); $programplan->printCellTest($col, $plan, $users, $productID); $result = ob_get_clean(); $pattern = '/]*>(.*?)<\/td>/s'; preg_match_all($pattern, $result, $matches); return $matches; } $programplan = new programplanTest(); $colIDList = array('id', 'name', 'percent', 'attribute', 'begin', 'end', 'realBegan', 'realEnd', 'output', 'version', 'editedBy', 'openedBy', 'editedDate', 'openedDate', 'actions'); $col = new stdClass(); $col->id = $colIDList[0]; $col->show = true; $plan = new stdClass(); $plan->id = '1'; $plan->milestone = true; $plan->grade = 1; $plan->children = 1; $plan->name = '名称'; $plan->percent = '10'; $plan->attribute = '10'; $plan->begin = '2023-05-06'; $plan->editedBy = 'id_desc'; $plan->editedDate = '2023-05-06'; $users = array(); $matches= call($programplan, $col, $plan, $users, 1); r(isset($matches[1][0]) ? $matches[1][0] : 0) && p() && e('001'); // 验证类型为id 的输出td $col->id = $colIDList[1]; $matches = call($programplan, $col, $plan, $users, 1); $result = isset($matches[1][0]) && str_contains($matches[1][0], $plan->name)? 1 : 0; r($result) && p() && e('1'); // 验证类型为name 的输出td $col->id = $colIDList[2]; $matches = call($programplan, $col, $plan, $users, 1); $result = isset($matches[1][0]) && $matches[1][0] == '10%' ? 1 : 0; r($result) && p() && e('1'); // 验证类型为percent 的输出td /* $colIDList key 4-9验证方法一致 */ $col->id = $colIDList[4]; $matches = call($programplan, $col, $plan, $users, 1); $result = isset($matches[1][0]) && $matches[1][0] == $plan->begin ? 1 : 0; r($result) && p() && e('1'); // 验证类型为begin 的输出td /* $colIDList key 10-11验证方法一致 */ $col->id = $colIDList[10]; $matches = call($programplan, $col, $plan, $users, 1); $result = isset($matches[1][0]) && $matches[1][0] == $plan->editedBy ? 1 : 0; r($result) && p() && e('1'); // 验证类型为editedBy 的输出td /* $colIDList key 12-13验证方法一致 */ $col->id = $colIDList[12]; $matches = call($programplan, $col, $plan, $users, 1); $result = isset($matches[1][0]) && $matches[1][0] == '05-06' ? 1 : 0; r($result) && p() && e('1'); // 验证类型为editedDate 的输出td