• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem with HTTP Feature Testing

#1
Hello All !

I found a really annoying problem... I don´t know if it is a BUG or a problem with my code.

I followed everything from the manual and made the following code :

PHP Code:
<?php namespace App\CI4\Controllers;

use 
CodeIgniter\Test\FeatureTestCase;


class 
HomeControllerTest extends FeatureTestCase
{

    public function 
setUp(): void
    
{
        
parent::setUp();
    }
    
    
public function tearDown(): void
    
{
        parent::tearDown();
    }

    public function 
testSimple()
    {
        
$test defined('APPPATH');
        
$this->assertTrue($test);
    }

    public function testShowHomeIndex()
    {

        $result $this->get('I/Page/Home/Index');            

        $this
->assertTrue($result->isOK());
    }

    public function testShowHomePage()
    {

        $result $this->get('I/Page/Home/Page');                

        $this
->assertTrue($result->isOK());
    }

    public function testShowHomeMain()
    {

        $result $this->get('home/main');        

        $this
->assertTrue($result->isOK());
    }

 
For this example my "Home" controller is located at app/i/page/Home.php  and it is acessible using the URL http://localhost:8080/i/page/home/index 

The problem is when running multiple tests ! Only the first one validates ! Just the first one. If I change the methods order, the first one will pass, the others wont.

Weird right ?

Code:
There were 2 errors:

1) App\HomeControllerTest::testShowHomePage
CodeIgniter\Exceptions\PageNotFoundException: Controller or its method is not found: App\Controllers\I\Page\::home

C:\Users\gabri\Documents\asist.com.br\system\Exceptions\PageNotFoundException.php:14
C:\Users\gabri\Documents\asist.com.br\system\CodeIgniter.php:911
C:\Users\gabri\Documents\asist.com.br\system\CodeIgniter.php:262
C:\Users\gabri\Documents\asist.com.br\system\Test\FeatureTestCase.php:173
C:\Users\gabri\Documents\asist.com.br\system\Test\FeatureTestCase.php:208
C:\Users\gabri\Documents\asist.com.br\tests\app\CodeIt4Me\Candidates\Controllers\candidatesHtmlControllerTest.php:36

2) App\HomeControllerTest::testShowHomeMain
CodeIgniter\Exceptions\PageNotFoundException: Controller or its method is not found: App\Controllers\I\Page\::home

C:\Users\gabri\Documents\asist.com.br\system\Exceptions\PageNotFoundException.php:14
C:\Users\gabri\Documents\asist.com.br\system\CodeIgniter.php:911
C:\Users\gabri\Documents\asist.com.br\system\CodeIgniter.php:262
C:\Users\gabri\Documents\asist.com.br\system\Test\FeatureTestCase.php:173
C:\Users\gabri\Documents\asist.com.br\system\Test\FeatureTestCase.php:208
C:\Users\gabri\Documents\asist.com.br\tests\app\CodeIt4Me\Candidates\Controllers\candidatesHtmlControllerTest.php:48


And If I change the order of the methods I have:

Code:
There were 2 errors:

1) App\HomeControllerTest::testShowHomeIndex
CodeIgniter\Exceptions\PageNotFoundException: Controller or its method is not found: App\Controllers\I\Page\::I

C:\Users\gabri\Documents\asist.com.br\system\Exceptions\PageNotFoundException.php:14
C:\Users\gabri\Documents\asist.com.br\system\CodeIgniter.php:911
C:\Users\gabri\Documents\asist.com.br\system\CodeIgniter.php:262
C:\Users\gabri\Documents\asist.com.br\system\Test\FeatureTestCase.php:173
C:\Users\gabri\Documents\asist.com.br\system\Test\FeatureTestCase.php:208
C:\Users\gabri\Documents\asist.com.br\tests\app\HomeControllerTest.php:37

2) App\HomeControllerTest::testShowHomeMain
CodeIgniter\Exceptions\PageNotFoundException: Controller or its method is not found: App\Controllers\I\Page\::home

C:\Users\gabri\Documents\asist.com.br\system\Exceptions\PageNotFoundException.php:14
C:\Users\gabri\Documents\asist.com.br\system\CodeIgniter.php:911
C:\Users\gabri\Documents\asist.com.br\system\CodeIgniter.php:262
C:\Users\gabri\Documents\asist.com.br\system\Test\FeatureTestCase.php:173
C:\Users\gabri\Documents\asist.com.br\system\Test\FeatureTestCase.php:208
C:\Users\gabri\Documents\asist.com.br\tests\app\HomeControllerTest.php:46
Reply

#2
By the way... It works just fine if the Home.php controller is under the "Controller" folder....
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2019 MyBB Group.