+ [misc] Add unit tests for instanceModel::__construct() method
🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
<?php
|
||||
declare(strict_types = 1);
|
||||
class instanceTest
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
global $tester;
|
||||
$this->objectModel = $tester->loadModel('instance');
|
||||
$this->objectTao = $tester->loadTao('instance');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test __construct method.
|
||||
*
|
||||
* @access public
|
||||
* @return mixed
|
||||
*/
|
||||
public function __constructTest()
|
||||
{
|
||||
$result = new stdClass();
|
||||
$result->cneLoaded = property_exists($this->objectModel, 'cne') && is_object($this->objectModel->cne);
|
||||
$result->actionLoaded = property_exists($this->objectModel, 'action') && is_object($this->objectModel->action);
|
||||
$result->parentCalled = property_exists($this->objectModel, 'dao') && is_object($this->objectModel->dao);
|
||||
|
||||
if(dao::isError()) return dao::getError();
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
Executable
+32
@@ -0,0 +1,32 @@
|
||||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
/**
|
||||
|
||||
title=测试 instanceModel::__construct();
|
||||
timeout=0
|
||||
cid=0
|
||||
|
||||
- 执行instanceTest模块的__constructTest方法
|
||||
- 属性cneLoaded @1
|
||||
- 属性actionLoaded @1
|
||||
- 属性parentCalled @1
|
||||
- 执行instanceTest模块的__constructTest方法 属性cneLoaded @1
|
||||
- 执行instanceTest模块的__constructTest方法 属性actionLoaded @1
|
||||
- 执行instanceTest模块的__constructTest方法 属性parentCalled @1
|
||||
- 执行instanceTest模块的__constructTest方法 @1
|
||||
|
||||
*/
|
||||
|
||||
include dirname(__FILE__, 5) . '/test/lib/init.php';
|
||||
include dirname(__FILE__, 2) . '/lib/instance.unittest.class.php';
|
||||
|
||||
su('admin');
|
||||
|
||||
$instanceTest = new instanceTest();
|
||||
|
||||
r($instanceTest->__constructTest()) && p('cneLoaded,actionLoaded,parentCalled') && e('1,1,1');
|
||||
r($instanceTest->__constructTest()) && p('cneLoaded') && e('1');
|
||||
r($instanceTest->__constructTest()) && p('actionLoaded') && e('1');
|
||||
r($instanceTest->__constructTest()) && p('parentCalled') && e('1');
|
||||
r(is_object($instanceTest->__constructTest())) && p() && e('1');
|
||||
Reference in New Issue
Block a user