CodeIgniter Forums
Problems with Unit Testing - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Installation & Setup (https://forum.codeigniter.com/forumdisplay.php?fid=9)
+--- Thread: Problems with Unit Testing (/showthread.php?tid=79071)



Problems with Unit Testing - pilly100 - 04-16-2021

Hello,

I want to make some unit tests but allways get an error:

CodeIgniter\Exceptions\PageNotFoundException: Controller or its method is not found: \App\Controllers\Tests::codeigniter

but I dont want to test the Tests Controller

PHP Code:
<?php

namespace App;

use 
CodeIgniter\Test\FeatureTestCase ;

class 
TestHome extends FeatureTestCase
{
    public function setUp(): void
    
{
        parent::setUp();
    }

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

    public function testIndex(){

        $this->get("/");
    }





RE: Problems with Unit Testing - pilly100 - 04-17-2021

(04-16-2021, 05:54 PM)pilly100 Wrote: Hello,

I want to make some unit tests but allways get an error:

CodeIgniter\Exceptions\PageNotFoundException: Controller or its method is not found: \App\Controllers\Tests::codeigniter

but I dont want to test the Tests Controller

PHP Code:
<?php

namespace App;

use 
CodeIgniter\Test\FeatureTestCase ;

class 
TestHome extends FeatureTestCase
{
    public function setUp(): void
    
{
        parent::setUp();
    }

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

    public function testIndex(){

        $this->get("/");
    }




The problem is I installed it in a subfolder tests/codeigniter ...

is it possible to test the application in a subfolder?


RE: Problems with Unit Testing - pilly100 - 04-19-2021

i found an opportunity to test it in a subfolder

change:
framework/system/Test/FeatureTestTrait.php
Line 310
$uri    = new URI(rtrim($config->baseURL, '/') . '/' . trim($path, '/ '));
to
$uri    = new URI('/' . trim($path, '/ '));

now you it is posible to test in subfolders

 Smile