php - Why PhpStorm doesn't know PHPUnit_Framework_TestCase -


i'm trying configure phpstorm 2017.2 use phpunit 5 php 5.6 project.

  1. i've downloaded phpunit-5.7.21.phar file the official source , placed in php 5.6 installation dir.

  2. in phpstorm settings >> languages & frameworks >> php >> test frameworks, i've linked .phar executable , set default config file phpunit.xml in project root directory

enter image description here

  1. here contents of phpunit.xml:

.

<?xml version="1.0" encoding="utf-8"?>  <phpunit>     <testsuites>         <testsuite name="test suite">             <directory>tests</directory>         </testsuite>     </testsuites> </phpunit> 

i'm trying structure tests in tests/unit directory within source file project structure mirrored described in manual. instance:

// project files: classone.php vendor/   classtwo.php   utility.php  // test files tests/unit/   classonetest.php   vendor/     classtwotest.php     utilitytest.php 

i have 2 problems though:

first, don't know how configure phpstorm create tests within tests/unit/ mirroring sructure respect project root. when create test, default file put in same directory project file.

secondly, don't know how phpstorm index phpunit source code. though i've linked phpunit-5.7.21.phar file shown above, ide complains when create test:

namespace vendor; class utilitytest extends \phpunit_framework_testcase{} 

undefined class phpunit_framework_testcase

update 1

i solved 2nd problem adding directory had saved .phar phpstorm include path, set in settings >> languages & frameworks >> php >> include path tab. alternatively, put .phar file within project directory , indexed.

i still need first problem.

update 2

thanks Ástþór's answer figured out how phpstorm mirror project structure within dedicated tests directory. go phpstorm settings >> directories , select base testing directory. click test near top mark test sources root

enter image description here

the next time create test, automatically placed in directory.

mark directory source classes "source root" , directory tests "test sources root". after directories pre-filled on test creation (e.g. via ctrl+shift+t on source class).
not sure though if work fine "mirroring" system: guess still have manually adjust directories part of tests


Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -