???????г???????????????ЩPHPUnit??????????????????????????????????????????????????飬?????Leader?????????????????“??????????鷢??”????????????????д????Model???е?????????????????д??
????Db?????????????MysqlDump????????Mysql???xml???????洢????????????????????????????????????????????£?
<?xml version="1.0"?>
<mysqldump xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<database name="bbg_mall">
<table_structure name="admin">
<field Field="id" Type="int(11) unsigned" Null="NO" Key="PRI" Extra="auto_increment"  />
<field Field="username" Type="varchar(20)" Null="NO" Key="" Extra=""  />
<field Field="password" Type="varchar(32)" Null="NO" Key="" Default="" Extra=""  />
<field Field="login_time" Type="int(10)" Null="NO" Key="" Default="0" Extra="" />
<field Field="login_num" Type="int(11)" Null="NO" Key="" Default="0" Extra="" />
<field Field="pid" Type="smallint(6)" Null="YES" Key="" Default="0" Extra=""  />
<key Table="admin" Non_unique="0" Key_name="PRIMARY" Seq_in_index="1" Column_name="id" Collation="A" Cardinality="21" Null="" Index_type="BTREE" Comment="" Index_comment="" />
<key Table="admin" Non_unique="1" Key_name="member_id" Seq_in_index="1" Column_name="id" Collation="A" Cardinality="21" Null="" Index_type="BTREE" Comment="" Index_comment="" />
<options Name="admin" Engine="InnoDB" Version="10" Row_format="Compact" Rows="21" Avg_row_length="780" Data_length="16384" Max_data_length="0" Index_length="16384" Data_free="0" Auto_increment="45" Create_time="2015-11-20 11:10:32" Collation="utf8_general_ci" Create_options="" Comment="" />
</table_structure>
<table_data name="admin">
<row>
<field name="id">1</field>
<field name="username">admin</field>
<field name="password">324d1907d9ca6733d399b87affe48c74</field>
<field name="login_time">1448011176</field>
<field name="login_num">1276</field>
<field name="pid">0</field>
</row>
</table_data>
</database>
</mysqldump>
???????????
????mysqldump -uroot -p --xml your_db_name admin > test/data/Application/Admin/Model/admin.xml
?????????????
????????????????????????????????????TP???????“?????”????DbModel?з??????κ???????????????????????????????????á?
????“??”????????ж????????sql?????????????????????????????
????php??????????????????????????????????????????????????????У???????????????????????????????Ч????o???????????????????
?????????????????????£????????????????????????????????????????к??????????????????????????????????巵???????????????????????????????????
???????????
<?php
namespace AdminModel;
/**
* Generated by PHPUnit_SkeletonGenerator on 2016-06-01 at 15:17:36.
*/
class AdminTest extends TimeCheerTestDatabaseTestCase
{
/**
* @var Admin
*/
protected $object;
/**
* Sets up the fixture?? for example?? opens a network connection.
* This method is called before a test is executed.
*/
protected function setUp()
{
parent::setUp();
$this->object = new Admin;
}
protected function getDataSet()
{
return $this->createMySQLXMLDataSet(TEST_PATH . '/data/Application/Admin/Model/admin.xml');
}
/**
* @covers AdminModelAdmin::getList
* @todo   Implement testGetList().
*/
public function testGetList()
{
$this->assertEquals(1?? $this->getConnection()->getRowCount('admin')?? "Pre-Condition");
}
/**
* @covers AdminModelAdmin::add
* @todo   Implement testAdd().
*/
public function testAdd()
{
$this->assertFalse($this->object->add([]));
//TODO ????????????
}
/**
* @covers AdminModelAdmin::update
* @todo   Implement testUpdate().
*/
public function testUpdate()
{
$this->assertFalse($this->object->update([]));
$result = $this->object->update(['id' => '-2']);
$this->assertFalse($result);
//TODO ????????????
}
/**
* @covers AdminModelAdmin::del
* @todo   Implement testDel().
*/
public function testDel()
{
$this->assertTrue($this->object->del(1));
}
/**
* @covers AdminModelAdmin::del
* @todo   Implement testDel().
*/
public function testDel2()
{
$this->assertFalse($this->object->del(0));
}
?????????Ч??
????1?????????????????????????????????鷢??????????????鯔??????
????2??????????DbModel?????update????????н?????ж?????bug??????mysqlδ??????????????????sql???????????true????affected_rows?0???????????????????????????????????