blob: 5a4ac690de6c6bc9fc7a2e1f099123354542bc06 [file] [log] [blame]
Taufan Aditya6e131cb2012-05-03 12:14:19 +07001<?php
2
3class From_test extends CI_TestCase {
4
5 /**
6 * @var object Database/Query Builder holder
7 */
8 protected $db;
9
10 public function set_up()
11 {
12 $this->db = Mock_Database_Schema_Skeleton::init(DB_DRIVER);
13
14 Mock_Database_Schema_Skeleton::create_tables();
15 Mock_Database_Schema_Skeleton::create_data();
16 }
17
18 // ------------------------------------------------------------------------
19
20 /**
21 * @see ./mocks/schema/skeleton.php
22 */
23 public function test_from_simple()
24 {
25 $jobs = $this->db->from('job')
Andrey Andreevc1862882012-06-09 23:16:58 +030026 ->get()
27 ->result_array();
28
Andrey Andreev20d9b0a2017-12-20 19:57:39 +020029 $this->assertCount(4, $jobs);
Taufan Aditya6e131cb2012-05-03 12:14:19 +070030 }
31
32 // ------------------------------------------------------------------------
33
34 /**
35 * @see ./mocks/schema/skeleton.php
36 */
37 public function test_from_with_where()
38 {
39 $job1 = $this->db->from('job')
Andrey Andreevc1862882012-06-09 23:16:58 +030040 ->where('id', 1)
41 ->get()
42 ->row();
43
Taufan Aditya6e131cb2012-05-03 12:14:19 +070044 $this->assertEquals('1', $job1->id);
45 $this->assertEquals('Developer', $job1->name);
46 $this->assertEquals('Awesome job, but sometimes makes you bored', $job1->description);
47 }
Andrey Andreevc1862882012-06-09 23:16:58 +030048
Andrey Andreev20d9b0a2017-12-20 19:57:39 +020049}