diff options
Diffstat (limited to 'demos/sqlmap-sample/tests/PersonTest.php')
| -rw-r--r-- | demos/sqlmap-sample/tests/PersonTest.php | 57 | 
1 files changed, 57 insertions, 0 deletions
diff --git a/demos/sqlmap-sample/tests/PersonTest.php b/demos/sqlmap-sample/tests/PersonTest.php new file mode 100644 index 00000000..c40bffa0 --- /dev/null +++ b/demos/sqlmap-sample/tests/PersonTest.php @@ -0,0 +1,57 @@ +<?php
 +
 +class PersonTest extends UnitTestCase
 +{
 +	function testPersonList()
 +	{
 +		//try it
 +		$people = TMapper::instance()->queryForList("SelectAll");
 +
 +		//test it
 +		$this->assertNotNull($people, "Person list is not returned");
 +		$this->assertTrue(count($people) > 0, "Person list is empty");
 +		$person = $people[0];
 +		$this->assertNotNull($person, "Person not returned");
 +	}
 +
 +	function testPersonUpdate()
 +	{
 +		$expect = "wei";
 +		$edited = "Nah";
 +		
 +		//get it;
 +		$person = TMapper::instance()->queryForObject("Select", 1);
 +
 +		//test it
 +		$this->assertNotNull($person);
 +		$this->assertEqual($expect, $person->FirstName);
 +
 +		//change it
 +		$person->FirstName = $edited;
 +		TMapper::instance()->update("Update", $person);
 +
 +		//get it again
 +		$person = TMapper::instance()->queryForObject("Select", 1);
 +
 +		//test it
 +		$this->assertEqual($edited, $person->FirstName);
 +
 +		//change it back
 +		$person->FirstName = $expect;
 +		TMapper::instance()->update("Update", $person);
 +	}
 +
 +	function testPersonDelete()
 +	{
 +		//insert it
 +		$person = new Person;
 +		$person->ID = -1;
 +		TMapper::instance()->insert("Insert", $person);
 +
 +		//delte it
 +		$count = TMapper::instance()->delete("Delete", -1);
 +		$this->assertEqual(1, $count);
 +	}
 +}
 +
 +?>
\ No newline at end of file  | 
