Welcome Guest, Not a member yet? Register   Sign In
Call to undefined function CodeIgniter\Test\helper() for CIUnitTestCase
#1
Sad 

Summary
Call to undefined function CodeIgniter\Test\helper() for CIUnitTestCase

I'm trying codeigniter4 testing tutorial.
testing-feature

PHP Code:
// ci4_batches/batches/tests/app/Controllers/TestHome.php
<?php
namespace App;

use 
CodeIgniter\Router\Exceptions\RedirectException;
use 
CodeIgniter\Test\CIUnitTestCase;
use 
CodeIgniter\Test\ControllerTestTrait;
use 
CodeIgniter\Test\DatabaseTestTrait;
use 
Exception;

class 
TestHome extends CIUnitTestCase
{
    use DatabaseTestTrait;
    use ControllerTestTrait;
    
    
protected function setUp(): void
    
{
        parent::setUp();
        
        
// $this->myClassMethod();
    }
    
    
protected function tearDown(): void
    
{
        parent::tearDown();
        
        
// $this->anotherClassMethod();
    }
    
    
/**
    * @throws RedirectException
    * @throws Exception
    */
    public function testIndex()
    {
        // Get a simple page
        $result $this->call('get''/');
        
        $result
->assertOK();
    }


phpStorm will be pop up this message.
Quote:Method 'call' not found in TestHome

Let's Test from phpStorm
Quote:Warning: Use of undefined constant SUPPORTPATH - assumed 'SUPPORTPATH' (this will throw an Error in a future version of PHP) in D:\OneDrive\dev\ci4_batches\batches\vendor\phpunit\phpunit\src\Framework\TestBuilder.php on line 138

Warning: Use of undefined constant SUPPORTPATH - assumed 'SUPPORTPATH' (this will throw an Error in a future version of PHP) in D:\OneDrive\dev\ci4_batches\batches\vendor\phpunit\phpunit\src\Framework\TestBuilder.php on line 138
PHPUnit 9.5.10 by Sebastian Bergmann and contributors.

PHP Warning:  Use of undefined constant SUPPORTPATH - assumed 'SUPPORTPATH' (this will throw an Error in a future version of PHP) in D:\OneDrive\dev\ci4_batches\batches\vendor\phpunit\phpunit\src\Framework\TestBuilder.php on line 138
PHP Warning:  Use of undefined constant SUPPORTPATH - assumed 'SUPPORTPATH' (this will throw an Error in a future version of PHP) in D:\OneDrive\dev\ci4_batches\batches\vendor\phpunit\phpunit\src\Framework\TestBuilder.php on line 138

Error : Call to undefined function CodeIgniter\Test\helper()
D:\OneDrive\dev\ci4_batches\batches\vendor\codeigniter4\framework\system\Test\CIUnitTestCase.php:227



Time: 00:00.018, Memory: 6.00 MB


ERRORS!
Tests: 1, Assertions: 0, Errors: 1.

Process finished with exit code 2

Why can't I do it?
Reply
#2

Did you ever get this to work?
Reply
Reply
#4

The call method is defined in the CodeIgniter\Test\FeatureTestTrait trait but you didn't add it.
Reply
#5

(01-20-2022, 03:37 AM)sushiguru Wrote: Did you ever get this to work?

(01-20-2022, 04:41 AM)BilltheCat Wrote: https://codeigniter.com/user_guide/cli/c...=call#call

(01-20-2022, 09:11 AM)iRedds Wrote: The call method is defined in the CodeIgniter\Test\FeatureTestTrait trait but you didn't add it.

I found it while organizing past posts.
I can't remember exactly what I detail, but the reason I wasn't able to test with PHPStorm is probably that I didn't specify the interpreter as phpunit.

Thank you everyone.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB