????????????л????Щ???÷?????????????г???????????????????????

 

<?php
/**
* ????????????
*
* @author    shayang88
* @since     2013-11-27
* @copyright Copyright (c) 2005-2012 Inc.
* @desc
*
*/
require_once dirname(__FILE__) . '/../../webroot/bootstrap.php';
class test_sign_task extends PHPUnit_Framework_TestCase
{
public $testUid = 5888882; //????????????id
/**
* ??????????????????????2?????е???????????????????????
*/
public function testClear(){
//??????б????????????????????????
$taskModel = new GuaziTaskModel();
$taskModel->clearTask($this->testUid?? 'sign');
//??????????????????????????????????
$signModel = new GuaziSignModel();
$signModel->getCollection()->update(array('uid' => $this->testUid )?? array('$unset' => array ('last_time' => 1?? 'sign_time' => 1)));
}
/**
* ???????????????????????????????????
*/
public function testEmpty(){
//??????????????????
$objSignTask = Task_Factory::factory('sign');
$signStatus = $objSignTask->getStatus($this->testUid);
//?????????????????????????0??????
$this->assertEquals(0?? $signStatus);
//????????????????
$signModel = new GuaziSignModel();
$arrsign = $signModel->getSignByUid($this->testUid);
//??????????????????????Σ???????NULL??????
$this->assertNull($arrsign['n_t']);
$this->assertNull($arrsign['t']);
}
/**
* ????????????????????????????????????????????????????????testSign???????????
* ??????????????????÷?@dataProvider
* @return array
*/
public function dataProducer() {
//?????????
//??1????????????????2?????????????????????3??????????????
return array(
array('2013-11-25 19:30'?? 1?? 1)??
array('2013-11-26 18:30'?? 2?? 2)??
array('2013-11-27 10:30'?? 3?? 3)??
array('2013-11-28 23:59'?? 4?? 4)??
array('2013-11-29 22:59'?? 5?? 4)??
);
}
/**
* @dataProvider dataProducer
*/
public function testSign($nowTime??$signCount??$taskStatus)
{
//???????dataProducer???????????????3????????????????????
$now = strtotime($nowTime);
$signModel = new GuaziSignModel();
//?????????????????
$objSignTask = Task_Factory::factory('sign');
//????????????????????????????????????
$doTaskRes = $objSignTask->doTaskForPhpunit($this->testUid?? $now);
//??????н??
$this->assertEquals(1?? $doTaskRes);
//?????????
$signStatus = $objSignTask->getStatus($this->testUid);
//??????????
$this->assertEquals($taskStatus?? $signStatus);
//??????????????
$ret = $signModel->updateLastSign($this->testUid??$now);
//???????????????
$this->assertCount($signCount?? $ret['t']);
}
}