Welcome Guest, Not a member yet? Register   Sign In
HTTP Feature Testing : don't echo the output
#1

Hello,

I'm trying to implement some UnitTest on a CI4 application but I encountered a problem with the HTTP Feature Testing. Whenever I test that one of my page is correctly responding, it dump all of my page content for the test that meet all requirement.

I have this test : 

PHP Code:
<?php

namespace App\Controllers\Admin;

use 
CodeIgniter\Test\FeatureTestCase;

class 
AdminUserTest extends FeatureTestCase {

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

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

    public function 
testIndexWithPerm() {
        
$values = [
            
'id' => 42,
            
'permission_ids' => [
                
44
            
]
        ];
        
$result $this->withSession($values)->get('admin/user');
        
$result->assertOK();
    }


What I want is checking that the page is responding correctly (HTTP 200) and that there's a body in it BUT without printing its content. Is it doable?
Reply
#2

How about this?

$result->assertStatus(200);
$result->assertSee('<title>Welcome to CodeIgniter 4!</title>');
Reply




Theme © iAndrew 2016 - Forum software by © MyBB