blob: 699d2906a5a279281f78640473a06c9b6b8a3e5f [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 */
Taufan Aditya0793b1c2012-04-05 21:47:53 +07008 protected $db;
Taufan Aditya5b421662012-04-05 01:24:50 +07009
10 public function set_up()
11 {
Taufan Aditya0793b1c2012-04-05 21:47:53 +070012 $this->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
18 // ------------------------------------------------------------------------
19
20 /**
21 * @see ./mocks/schema/skeleton.php
22 */
23 public function test_get_simple()
24 {
Taufan Aditya0793b1c2012-04-05 21:47:53 +070025 $jobs = $this->db->get('job')->result_array();
Andrey Andreevc1862882012-06-09 23:16:58 +030026
Taufan Aditya5b421662012-04-05 01:24:50 +070027 // Dummy jobs contain 4 rows
28 $this->assertCount(4, $jobs);
29
30 // Check rows item
31 $this->assertEquals('Developer', $jobs[0]['name']);
32 $this->assertEquals('Politician', $jobs[1]['name']);
33 $this->assertEquals('Accountant', $jobs[2]['name']);
34 $this->assertEquals('Musician', $jobs[3]['name']);
35 }
Taufan Aditya55f622f2012-04-05 19:01:34 +070036
37 // ------------------------------------------------------------------------
38
39 /**
40 * @see ./mocks/schema/skeleton.php
41 */
42 public function test_get_where()
43 {
Taufan Aditya0793b1c2012-04-05 21:47:53 +070044 $job1 = $this->db->get('job', array('id' => 1))->result_array();
Andrey Andreevc1862882012-06-09 23:16:58 +030045
Taufan Aditya55f622f2012-04-05 19:01:34 +070046 // Dummy jobs contain 1 rows
47 $this->assertCount(1, $job1);
48
49 // Check rows item
50 $this->assertEquals('Developer', $job1[0]['name']);
51 }
Andrey Andreevc1862882012-06-09 23:16:58 +030052
Taufan Aditya5b421662012-04-05 01:24:50 +070053}