Skip to content

Commit 2d03af0

Browse files
committed
Revert "Test Case Implement"
This reverts commit 931d719. Conflicts: core/MY_Model.php
1 parent 8c0ef83 commit 2d03af0

13 files changed

+4
-58
lines changed

core/MY_Model.php

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,10 @@ public function __construct()
103103

104104
$this->load->helper('inflector');
105105

106-
$this->_database = $this->db;
107-
108106
$this->_fetch_table();
109107

108+
$this->_database = $this->db;
109+
110110
array_unshift($this->before_create, 'protect_attributes');
111111
array_unshift($this->before_update, 'protect_attributes');
112112

@@ -611,14 +611,6 @@ public function table()
611611
return $this->_table;
612612
}
613613

614-
/**
615-
* Getter for the primary key
616-
*/
617-
public function primary_key()
618-
{
619-
return $this->primary_key;
620-
}
621-
622614
/* --------------------------------------------------------------
623615
* GLOBAL SCOPES
624616
* ------------------------------------------------------------ */
@@ -871,7 +863,7 @@ private function _fetch_table()
871863
/**
872864
* Guess the primary key for current table
873865
*/
874-
protected function _fetch_primary_key()
866+
private function _fetch_primary_key()
875867
{
876868
if($this->primary_key == NULl)
877869
{

tests/MY_Model_test.php

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -41,24 +41,6 @@ public function test_constructor_guesses_the_table_name()
4141
$this->assertEquals($this->model->table(), 'records');
4242
}
4343

44-
public function test_constructor_guess_the_primary_key()
45-
{
46-
$this->model = new Book_model($this->model->_database, 'id');
47-
48-
$this->model->_database->expects($this->once())
49-
->method('query')
50-
->with($this->equalTo("SHOW KEYS FROM `books` WHERE Key_name = 'PRIMARY'"))
51-
->will($this->returnValue($this->model->_database))
52-
;
53-
$this->model->_database->expects($this->once())
54-
->method('row')
55-
->will($this->returnValue((object)array('Column_name'=>'fake_primary_key')));
56-
57-
$this->model = $this->model->__construct($this->model->_database);
58-
59-
$this->assertEquals($this->model->primary_key(), 'fake_primary_key');
60-
}
61-
6244
/* --------------------------------------------------------------
6345
* CRUD INTERFACE
6446
* ------------------------------------------------------------ */

tests/support/database.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ public function limit() { }
3131
public function count_all_results() { }
3232
public function count_all() { }
3333
public function truncate() { }
34-
public function query() { }
3534

3635
/**
3736
* CI_DB_Result

tests/support/models/after_callback_model.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ class After_callback_model extends MY_Model
1818
protected $after_update = array('test_throw');
1919
protected $after_get = array('test_data_callback', 'test_data_callback_two');
2020
protected $after_delete = array('test_throw');
21-
protected $primary_key = 'id';
2221

2322
protected function test_throw($row)
2423
{

tests/support/models/before_callback_model.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ class Before_callback_model extends MY_Model
1818
protected $before_update = array('test_data_callback', 'test_data_callback_two');
1919
protected $before_get = array('test_throw');
2020
protected $before_delete = array('test_throw');
21-
protected $primary_key = 'id';
2221

2322
protected function test_throw($row)
2423
{

tests/support/models/book_model.php

Lines changed: 0 additions & 16 deletions
This file was deleted.

tests/support/models/callback_parameter_model.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
class Callback_parameter_model extends MY_Model
1616
{
1717
public $callback = array('some_callback(some_param,another_param)');
18-
protected $primary_key = 'id';
1918

2019
public function some_method()
2120
{

tests/support/models/protected_attributes_model.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,4 @@
1414
class Protected_attributes_model extends MY_Model
1515
{
1616
public $protected_attributes = array( 'id', 'hash' );
17-
protected $primary_key = 'id';
1817
}
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
<?php
22

3-
class Record_model extends MY_Model {
4-
protected $primary_key = 'id';
5-
}
3+
class Record_model extends MY_Model { }

tests/support/models/relationship_model.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,9 @@ class Belongs_to_model extends MY_Model
1515
{
1616
public $belongs_to = array( 'author' );
1717
public $has_many = array( 'comments' );
18-
protected $primary_key = 'id';
1918
}
2019

2120
class Author_model extends MY_Model
2221
{
2322
protected $_table = 'authors';
24-
protected $primary_key = 'id';
2523
}

0 commit comments

Comments
 (0)