After spending few hours, I successfully installed everything from wget, phpunit, php version upgrade to 5.6, and http://ift.tt/1RL7kgb
when i ran phpunit for the first time (it ran welcome_test.php) it worked great and output as below
OK (2 tests, 2 assertions)
Then i created "Home_test.php" to test my controller and put below code
class Home_test extends TestCase
{
public function tests_index(){
$actual = "something";
$expected = 'something';
$this->assertEquals($expected, $actual);
}
public function test_home(){
$output = $this->request('GET', ['Home', 'index']);
$this->assertContains('<title>Home</title>', $output);
}
}
when i run phpunit i get below error
PHPUnit 5.5.4 by Sebastian Bergmann and contributors.
2 / 2 (100%)
<?
defined('BASEPATH') OR exit('No direct script access allowed');
class Home extends CI_Controller {
public function __construct(){
parent::__construct();
}
public function index(){
$data['user'] = $this->session->get_userdata();
$this->load->view('header',$data);
$this->load->view('home');
$this->load->view('footer');
}
}
Time: 354 ms, Memory: 24.00MB
There was 1 failure:
1) Home_test::test_home
Failed asserting that 'Home::index() is not found' contains "<title>Home</title>".
/Applications/AMPPS/www/tab/video2/application/tests/controllers/Home_test.php:13
FAILURES!
Tests: 2, Assertions: 2, Failures: 1.
If i point this test to
$output = $this->request('GET', ['Welcome', 'index']);
instead of
$output = $this->request('GET', ['Home', 'index']);
then it works fine, that means Home_test.php and Welcome_test.php both are pointing to same controller, Welcome.php controller.
What i am doing wrong ?
Aucun commentaire:
Enregistrer un commentaire