CodeIgniter Forums
testing with phpunit in phpstorm - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forum-28.html)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forum-30.html)
+--- Thread: testing with phpunit in phpstorm (/thread-69442.html)



testing with phpunit in phpstorm - puschie - 11-22-2017

hey,
currently im trying to get phpunit run all tests ( include own application tests ) in phpstorm.

1. install all dependency via composer
  ( got an error on extractTo phpunit/php-code-coverage : no such file or stream | and git was not found : github.com/sebastianbergmann/php-code-coverage.git ) -> guess i dont need this for testing, so just as notice

2. download phpunit.phar and select it in Settings/Languages&Frameworks/PHP/TestFramework

when i try to run a test without the configuration file i get :
   Fatal error: Class 'CodeIgniter\Test\CIDatabaseTestCase' not found

when i try to run a test with the configuration file ( phpunit.xml.dist ) i get :
  require(application/Config/Paths.php): failed to open stream [...] \tests\_support\_bootstrap.php on line 10


im very new to phpunit - so maybe i miss some phpstorm configuration, but when i use the build-in test creation it work ( but i dont get codeignigter to run in a TestCase class )

thx for reading - hope someone had the same problems and solved it^^


RE: testing with phpunit in phpstorm - InsiteFX - 11-23-2017

I found that with phpStorm it's a good idea to add a url mapping to the public folder.


RE: testing with phpunit in phpstorm - natanfelles - 11-24-2017

I do not know how to configure it with the PhpStorm GUI.

But is possible just go to you CodeIgniter 4 root dir with the terminal and run: ./phpunit

If you want to test a specific file: ./phpunit tests/system/CLI/CLITest.php


RE: testing with phpunit in phpstorm - puschie - 11-27-2017

hmm, i test it but i get many errors like : "Uncaught ErrorException: Undefined index [...] \TestLogger.php:35"
so the testing suit is broken ? i thougth it have to work out of the box ( as it works in the travis builds )


RE: testing with phpunit in phpstorm - puschie - 01-08-2018

its working now... had to set a custom working directory ( to CI4 root )


RE: testing with phpunit in phpstorm - InsiteFX - 01-08-2018

I set all my projects to /htdocs/projectName that is my Root then I add another mapping to the public_html folder.
This is using XAMPP and Windoes 10 Pro.

Anything I need to test I just add a folder to the Root.