CodeIgniter Forums
Unit testing problem - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: Unit testing problem (/showthread.php?tid=76162)



Unit testing problem - maxxd - 04-17-2020

Hi all.

I'm working on some very simple unit testing with CI4 and am running into an issue. I'm trying to use the call() method as described in the 'Requesting a Page' section here: https://codeigniter4.github.io/userguide/testing/feature.html.

My code:
PHP Code:
<?php
namespace App;

use 
CodeIgniter\Test\FeatureTestCase;

class 
RoutesTest extends FeatureTestCase{
  /**
   * @runInSeparateProcess
   * @preserveGlobalState disabled
   */
  function testGetClassesList(){
    $result $this->call('get''https://mytestapp.com:8001/classes');
    $this->assertTrue($result->isOK());
  }


And the results are this:
Code:
1) App\RoutesTest::testGetClassesList()
ErrorException: Trying to get property 'database_name' of non-object

Anybody have any ideas?