Taufan Aditya | 5b42166 | 2012-04-05 01:24:50 +0700 | [diff] [blame^] | 1 | <?php |
| 2 | |
| 3 | class 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 | { |
| 12 | $config = Mock_Database_DB::config(DB_DRIVER); |
| 13 | $connection = new Mock_Database_DB($config); |
| 14 | $db = Mock_Database_DB::DB($connection->set_dsn(DB_DRIVER), TRUE); |
| 15 | |
| 16 | $this->ci_instance_var('db', $db); |
| 17 | |
| 18 | $loader = new Mock_Core_Loader(); |
| 19 | $loader->dbforge(); |
| 20 | |
| 21 | $forge = $this->ci_instance->dbforge; |
| 22 | |
| 23 | Mock_Database_Schema_Skeleton::create_tables($forge); |
| 24 | Mock_Database_Schema_Skeleton::create_data($db); |
| 25 | |
| 26 | $this->query_builder = $db; |
| 27 | } |
| 28 | |
| 29 | // ------------------------------------------------------------------------ |
| 30 | |
| 31 | /** |
| 32 | * @see ./mocks/schema/skeleton.php |
| 33 | */ |
| 34 | public function test_get_simple() |
| 35 | { |
| 36 | $jobs = $this->query_builder->get('job')->result_array(); |
| 37 | |
| 38 | // Dummy jobs contain 4 rows |
| 39 | $this->assertCount(4, $jobs); |
| 40 | |
| 41 | // Check rows item |
| 42 | $this->assertEquals('Developer', $jobs[0]['name']); |
| 43 | $this->assertEquals('Politician', $jobs[1]['name']); |
| 44 | $this->assertEquals('Accountant', $jobs[2]['name']); |
| 45 | $this->assertEquals('Musician', $jobs[3]['name']); |
| 46 | } |
| 47 | |
| 48 | } |