Skip to content

Commit 2dd6eea

Browse files
author
Richard McDaniel
committed
fix
1 parent 02ba578 commit 2dd6eea

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

tests/bootstrap.php

+6-1
Original file line numberDiff line numberDiff line change
@@ -609,4 +609,9 @@ function &get_instance()
609609
/* Location: ./system/core/CodeIgniter.php */
610610

611611
/* End of file index.php */
612-
/* Location: ./index.php */
612+
/* Location: ./index.php */
613+
614+
function load_controller($class) {
615+
require_once(FCPATH . APPPATH . 'controllers/' . strtolower($class) . '.php');
616+
return new $class();
617+
}

tests/unit.php

+7-5
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,12 @@ public function setUp()
1010

1111
public function testLogin()
1212
{
13-
$_POST['email'] = '[email protected]';
14-
$_POST['password'] = 'password123';
15-
require_once(FCPATH . APPPATH . 'controllers/user.php');
16-
$this->CI->User = new User();
17-
echo $this->CI->User->login();
13+
$email = '[email protected]';
14+
$password = 'password123';
15+
$_POST['email'] = $email;
16+
$_POST['password'] = $password;
17+
$this->CI->User = load_controller('User');
18+
$result = json_decode($this->CI->User->login())->output;
19+
$this->assertEquals($result->email, $email);
1820
}
1921
}

0 commit comments

Comments
 (0)