Welcome Guest, Not a member yet? Register   Sign In
Problems with Unit Testing
#1

(This post was last modified: 04-17-2021, 03:07 AM by pilly100.)

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("/");
    }


Reply
#2

(This post was last modified: 04-17-2021, 09:17 AM by pilly100.)

(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?
Reply
#3

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
Reply




Theme © iAndrew 2016 - Forum software by © MyBB