* Adjust branch changeBranchLanguage method unit test case.
This commit is contained in:
@@ -686,16 +686,17 @@ class branchModel extends model
|
||||
}
|
||||
|
||||
/**
|
||||
* Change branch language.
|
||||
* 设置分支/平台名称。
|
||||
* Set branch/platform name.
|
||||
*
|
||||
* @param int $productID
|
||||
* @access public
|
||||
* @return void
|
||||
* @return bool
|
||||
*/
|
||||
public function changeBranchLanguage($productID)
|
||||
public function changeBranchLanguage(int $productID): bool
|
||||
{
|
||||
$product = $this->loadModel('product')->getByID($productID);
|
||||
if($product->type == 'normal') return;
|
||||
if(!$product || $product->type == 'normal') return false;
|
||||
|
||||
$productType = $product->type;
|
||||
|
||||
@@ -716,6 +717,7 @@ class branchModel extends model
|
||||
$this->lang->branch->existName = str_replace('@branch@', $this->lang->product->branchName[$productType], $this->lang->branch->existName);
|
||||
$this->lang->branch->mergeTips = str_replace('@branch@', $this->lang->product->branchName[$productType], $this->lang->branch->mergeTips);
|
||||
$this->lang->branch->targetBranchTips = str_replace('@branch@', $this->lang->product->branchName[$productType], $this->lang->branch->targetBranchTips);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -385,7 +385,7 @@ class branchTest
|
||||
global $tester;
|
||||
global $lang;
|
||||
|
||||
$filePath = dirname(dirname(dirname(__FILE__))) . DS . 'module' . DS . 'branch' . DS . 'lang' . DS . 'zh-cn.php';
|
||||
$filePath = dirname(__FILE__, 2) . DS . 'lang' . DS . 'zh-cn.php';
|
||||
include $filePath;
|
||||
|
||||
$this->objectModel->changeBranchLanguage($productID);
|
||||
|
||||
@@ -2,25 +2,27 @@
|
||||
<?php
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/branch.class.php';
|
||||
|
||||
$product = zdTable('product');
|
||||
$product->id->range('41-45');
|
||||
$product->type->range('normal,branch,platform');
|
||||
$product->gen(5);
|
||||
|
||||
zdTable('branch')->gen(10);
|
||||
su('admin');
|
||||
|
||||
/**
|
||||
|
||||
title=测试 branchModel->changeBranchLanguage();
|
||||
timeout=0
|
||||
cid=1
|
||||
pid=1
|
||||
|
||||
测试修改productID 1 的分支语言项 >> 新建%s
|
||||
测试修改productID 41 的分支语言项 >> 新建分支
|
||||
测试修改productID 81 的分支语言项 >> 新建平台
|
||||
测试修改productID 42 的分支语言项 >> 新建分支
|
||||
|
||||
*/
|
||||
$productID = array(1, 41, 81, 42);
|
||||
$productID = array(41, 42, 43, 81);
|
||||
|
||||
$branch = new branchTest();
|
||||
|
||||
r($branch->changeBranchLanguageTest($productID[0])) && p() && e('新建%s'); // 测试修改productID 1 的分支语言项
|
||||
r($branch->changeBranchLanguageTest($productID[1])) && p() && e('新建分支'); // 测试修改productID 41 的分支语言项
|
||||
r($branch->changeBranchLanguageTest($productID[2])) && p() && e('新建平台'); // 测试修改productID 81 的分支语言项
|
||||
r($branch->changeBranchLanguageTest($productID[3])) && p() && e('新建分支'); // 测试修改productID 42 的分支语言项
|
||||
r($branch->changeBranchLanguageTest($productID[0])) && p() && e('新建%s'); // 正常产品
|
||||
r($branch->changeBranchLanguageTest($productID[1])) && p() && e('新建分支'); // 多分支产品
|
||||
r($branch->changeBranchLanguageTest($productID[2])) && p() && e('新建平台'); // 多平台产品
|
||||
r($branch->changeBranchLanguageTest($productID[3])) && p() && e('新建%s'); // 不存在的产品
|
||||
|
||||
Reference in New Issue
Block a user