![]() |
PHPUnit test $obj = new ProgTestClass() don't craate controller's object - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: Model-View-Controller (https://forum.codeigniter.com/forumdisplay.php?fid=10) +--- Thread: PHPUnit test $obj = new ProgTestClass() don't craate controller's object (/showthread.php?tid=92340) |
PHPUnit test $obj = new ProgTestClass() don't craate controller's object - krychu_m - 01-19-2025 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(); 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 RE: PHPUnit test $obj = new ProgTestClass() don't craate controller's object - ozornick - 01-19-2025 Use ReflectionHelper for protected properties. https://github.com/codeigniter4/CodeIgniter4/blob/develop/system/Test/ReflectionHelper.php#L18 |