Welcome Guest, Not a member yet? Register   Sign In
PHPUnit test $obj = new ProgTestClass() don't craate controller's object
#1

Hi All

I'm writing a small test and I want to check the value of a property after calling initController

PHP Code:
      $obj = new \App\Controllers\Prog();
      $this->assertTrue$obj->baseOK ); 

Unfortunately, after running the tests I get the following message:
1) App\Controllers\ProgTest::testinitController
Error: Cannot access protected property App\Controllers\Prog::$baseOK

I am using CI4 and phpunit PHPUnit 10.5.41
Thank you in advance for all replies
Reply
#2

Use ReflectionHelper for protected properties.
https://github.com/codeigniter4/CodeIgni...er.php#L18
Simple CI 4 project for beginners codeigniter-expenses ( topic )
Reply




Theme © iAndrew 2016 - Forum software by © MyBB