premier commit
[bazdig.git] / test / QueryTest.php
blobc9533cadcf30234e8ac4e512dcc3544d9b16d51b
1 <?php
2 /**
3 * PHPUnit test case for Query
4 *
5 * The method skeletons below need to be filled in with
6 * real data so that the tests will run correctly. Replace
7 * all EXPECTED_VAL and PARAM strings with real data.
8 *
9 * Created with PHPUnit_Skeleton on 2006-11-29
11 require_once 'PHPUnit.php';
12 class QueryTest extends PHPUnit_TestCase {
14 var $Query;
16 function QueryTest($name)
18 $this->PHPUnit_TestCase($name);
21 function setUp()
23 require_once '../lib/database.php';
24 $this->Query =& new Query();
25 $this->DataBase =& new DataBase("sqlite://home/slim/waraq/test/database.db");
28 function tearDown()
30 unset($this->Query);
33 function testdb()
35 $result = $this->Query->db(PARAM);
36 $expected = EXPECTED_VAL;
37 $this->assertEquals($expected, $result);
40 function testinsert()
42 $addItemQuery = new Query;
43 //$addItemQuery->insert("item")->set("p1='test'")->then("p2='test'");
45 $addItemQuery->string();
49 $p1 = $getItemQuery->db();
50 $this->assertEquals($expected, $result);
54 function testselect()
56 $result = $this->Query->select("p1")->from("item")->where("p2='test'")->string();
57 $expected = "select p1 from item where p2='test'";
58 $this->assertEquals($expected, $result);
61 function testfrom()
63 $result = $this->Query->from(PARAM);
64 $expected = EXPECTED_VAL;
65 $this->assertEquals($expected, $result);
68 function testwhere()
70 $result = $this->Query->where(PARAM);
71 $expected = EXPECTED_VAL;
72 $this->assertEquals($expected, $result);
76 // Running the test.
77 $suite = new PHPUnit_TestSuite('QueryTest');
78 $result = PHPUnit::run($suite);
79 echo $result->toString();