+ Add space::getSpacesByAccount unit test.
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
/**
|
||||
|
||||
title=测试 spaceModel->getSpacesByAccount();
|
||||
cid=1
|
||||
|
||||
*/
|
||||
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/space.class.php';
|
||||
|
||||
zdTable('user')->gen(5);
|
||||
zdTable('space')->config('space')->gen(5);
|
||||
|
||||
$owners = array('', 'admin', 'user1', 'test');
|
||||
|
||||
$spaceTester = new spaceTest();
|
||||
r($spaceTester->getSpacesByAccountTest($owners[0])) && p() && e('0'); // 获取用户名为空的空间列表
|
||||
r($spaceTester->getSpacesByAccountTest($owners[1])) && p('0:name,k8space,owner,default') && e('空间1,k8space,admin,0'); // 获取用户名为admin的空间列表
|
||||
r($spaceTester->getSpacesByAccountTest($owners[2])) && p('0:name,k8space,owner,default') && e('空间2,k8space,user1,0'); // 获取用户名为user1的空间列表
|
||||
r($spaceTester->getSpacesByAccountTest($owners[3])) && p() && e('0'); // 获取用户名为test的空间列表
|
||||
|
||||
r(count($spaceTester->getSpacesByAccountTest($owners[0]))) && p() && e('0'); // 获取用户名为空的空间数量
|
||||
r(count($spaceTester->getSpacesByAccountTest($owners[1]))) && p() && e('1'); // 获取用户名为admin的空间数量
|
||||
r(count($spaceTester->getSpacesByAccountTest($owners[2]))) && p() && e('1'); // 获取用户名为user1的空间数量
|
||||
r(count($spaceTester->getSpacesByAccountTest($owners[3]))) && p() && e('0'); // 获取用户名为test的空间数量
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
class spaceTest
|
||||
{
|
||||
public function __construct(string $account = 'admin')
|
||||
{
|
||||
su($account);
|
||||
|
||||
global $tester, $app;
|
||||
$this->objectModel = $tester->loadModel('space');
|
||||
|
||||
$app->rawModule = 'space';
|
||||
$app->rawMethod = 'browse';
|
||||
$app->setModuleName('space');
|
||||
$app->setMethodName('browse');
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取用户的空间列表。
|
||||
* Get space list by user account.
|
||||
*
|
||||
* @param string $account
|
||||
* @access public
|
||||
* @return array
|
||||
*/
|
||||
public function getSpacesByAccountTest(string $account): array
|
||||
{
|
||||
$spaceList = $this->objectModel->getSpacesByAccount($account);
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
return $spaceList;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
title: zt_space
|
||||
author: Shujie Tian
|
||||
version: "1.0"
|
||||
fields:
|
||||
- field: id
|
||||
range: 1-100
|
||||
- field: name
|
||||
range: 1-100
|
||||
prefix: 空间
|
||||
- field: owner
|
||||
fields:
|
||||
- field: account1
|
||||
range: admin,user{9}
|
||||
- field: account2
|
||||
range: "[],1-9"
|
||||
- field: k8space
|
||||
range: 'k8space'
|
||||
- field: deleted
|
||||
range: 0
|
||||
Reference in New Issue
Block a user