blob: dd946a40c447342d8fb2535d7509d020467698a0 [file] [log] [blame]
Taufan Aditya5b421662012-04-05 01:24:50 +07001<?php
2
3class Get_test extends CI_TestCase {
4
5 /**
6 * @var object Database/Query Builder holder
7 */
8 protected $query_builder;
9
10 public function set_up()
11 {
Taufan Aditya55f622f2012-04-05 19:01:34 +070012 $db = Mock_Database_Schema_Skeleton::init(DB_DRIVER);
Taufan Aditya5b421662012-04-05 01:24:50 +070013
Taufan Aditya55f622f2012-04-05 19:01:34 +070014 Mock_Database_Schema_Skeleton::create_tables();
15 Mock_Database_Schema_Skeleton::create_data();
Taufan Aditya5b421662012-04-05 01:24:50 +070016
17 $this->query_builder = $db;
18 }
19
20 // ------------------------------------------------------------------------
21
22 /**
23 * @see ./mocks/schema/skeleton.php
24 */
25 public function test_get_simple()
26 {
27 $jobs = $this->query_builder->get('job')->result_array();
28
29 // Dummy jobs contain 4 rows
30 $this->assertCount(4, $jobs);
31
32 // Check rows item
33 $this->assertEquals('Developer', $jobs[0]['name']);
34 $this->assertEquals('Politician', $jobs[1]['name']);
35 $this->assertEquals('Accountant', $jobs[2]['name']);
36 $this->assertEquals('Musician', $jobs[3]['name']);
37 }
Taufan Aditya55f622f2012-04-05 19:01:34 +070038
39 // ------------------------------------------------------------------------
40
41 /**
42 * @see ./mocks/schema/skeleton.php
43 */
44 public function test_get_where()
45 {
46 $job1 = $this->query_builder->get('job', array('id' => 1))->result_array();
47
48 // Dummy jobs contain 1 rows
49 $this->assertCount(1, $job1);
50
51 // Check rows item
52 $this->assertEquals('Developer', $job1[0]['name']);
53 }
Taufan Aditya5b421662012-04-05 01:24:50 +070054
55}