+ Add unit test case for mr->getMRProduct.

This commit is contained in:
caoyanyi
2023-12-21 13:14:37 +08:00
parent a46c4fc356
commit 2a2cd2e006
4 changed files with 51 additions and 15 deletions
+3 -13
View File
@@ -1234,20 +1234,10 @@ class mrModel extends model
*/
public function getMRProduct(object $MR): object|false
{
$product = false;
$productID = 0;
if(is_object($MR) && $MR->repoID)
{
$productID = $this->dao->select('product')->from(TABLE_REPO)->where('id')->eq($MR->repoID)->fetch('product');
}
else
{
$products = $this->loadModel('gitlab')->getProductsByProjects(array($MR->targetProject, $MR->sourceProject));
$productID = array_shift($products);
}
$productID = $this->dao->select('product')->from(TABLE_REPO)->where('id')->eq($MR->repoID)->fetch('product');
if(!$productID) return false;
if($productID) $product = $this->loadModel('product')->getById((int)$productID);
return $product;
return $this->loadModel('product')->getById((int)$productID);
}
/**