CodeIgniter Forums

Full Version: testing with phpunit in phpstorm
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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^^
I found that with phpStorm it's a good idea to add a url mapping to the public folder.
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
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 )
its working now... had to set a custom working directory ( to CI4 root )
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.