Not able to get debug working

I have a Drupal 7.x website that I am putting into PhpStorm for the first time.  Ultimately what I am wanting to do is be able to debug this site and follow the code so I can modify it.

What I did was copy the 'html' directory from the web server and I imported that into PhpStorm using these instructions - https://www.jetbrains.com/phpstorm/help/preparing-for-drupal-development-in-phpstorm.html

I am using XAMPP for apache and MySQL, both are running and I can browse to my localhost

The problem that I am not able to get past is when I select Run } Run 'html' I get an error in the event log:

"C:\Program Files (x86)\php-5.6.15-Win32-VC11-x86\php.exe" "C:\Program Files (x86)\php-5.6.15-Win32-VC11-x86\phpunit.phar" --no-configuration C:\Users\Baub\Baub\TR\code\web\outer-pages\html --teamcity

Testing started at 10:01 AM ...

Fatal error: Class 'DrupalWebTestCase' not found in C:\Users\Baub\Baub\TR\code\web\outer-pages\html\modules\simpletest\lib\Drupal\simpletest\Tests\PSR0WebTest.php on line 7

Call Stack:

    0.0732     447216   1. {main}() C:\Program Files (x86)\php-5.6.15-Win32-VC11-x86\phpunit.phar:0

    0.1602    8201864   2. PHPUnit_TextUI_Command::main() C:\Program Files (x86)\php-5.6.15-Win32-VC11-x86\phpunit.phar:509

    0.1602    8206248   3. PHPUnit_TextUI_Command->run() phar://C:/Program Files (x86)/php-5.6.15-Win32-VC11-x86/phpunit.phar/phpunit/TextUI/Command.php:105

    0.1612    8210864   4. PHPUnit_Runner_BaseTestRunner->getTest() phar://C:/Program Files (x86)/php-5.6.15-Win32-VC11-x86/phpunit.phar/phpunit/TextUI/Command.php:128

   32.4052    8244400   5. PHPUnit_Framework_TestSuite->addTestFiles() phar://C:/Program Files (x86)/php-5.6.15-Win32-VC11-x86/phpunit.phar/phpunit/Runner/BaseTestRunner.php:58

   32.4052    8251808   6. PHPUnit_Framework_TestSuite->addTestFile() phar://C:/Program Files (x86)/php-5.6.15-Win32-VC11-x86/phpunit.phar/phpunit/Framework/TestSuite.php:409

   32.4062    8346240   7. PHPUnit_Util_Fileloader::checkAndLoad() phar://C:/Program Files (x86)/php-5.6.15-Win32-VC11-x86/phpunit.phar/phpunit/Framework/TestSuite.php:335

   32.4062    8346424   8. PHPUnit_Util_Fileloader::load() phar://C:/Program Files (x86)/php-5.6.15-Win32-VC11-x86/phpunit.phar/phpunit/Util/Fileloader.php:38

   32.4072    8350296   9. include_once('C:\Users\Baub\Baub\TR\code\web\outer-pages\html\modules\simpletest\lib\Drupal\simpletest\Tests\PSR0WebTest.php') phar://C:/Program Files (x86)/php-5.6.15-Win32-VC11-x86/phpunit.phar/phpunit/Util/Fileloader.php:56

PHP Fatal error:  Class 'DrupalWebTestCase' not found in C:\Users\Baub\Baub\TR\code\web\outer-pages\html\modules\simpletest\lib\Drupal\simpletest\Tests\PSR0WebTest.php on line 7

PHP Stack trace:

PHP   1. {main}() C:\Program Files (x86)\php-5.6.15-Win32-VC11-x86\phpunit.phar:0

PHP   2. PHPUnit_TextUI_Command::main() C:\Program Files (x86)\php-5.6.15-Win32-VC11-x86\phpunit.phar:509

PHP   3. PHPUnit_TextUI_Command->run() phar://C:/Program Files (x86)/php-5.6.15-Win32-VC11-x86/phpunit.phar/phpunit/TextUI/Command.php:105

PHP   4. PHPUnit_Runner_BaseTestRunner->getTest() phar://C:/Program Files (x86)/php-5.6.15-Win32-VC11-x86/phpunit.phar/phpunit/TextUI/Command.php:128

PHP   5. PHPUnit_Framework_TestSuite->addTestFiles() phar://C:/Program Files (x86)/php-5.6.15-Win32-VC11-x86/phpunit.phar/phpunit/Runner/BaseTestRunner.php:58

PHP   6. PHPUnit_Framework_TestSuite->addTestFile() phar://C:/Program Files (x86)/php-5.6.15-Win32-VC11-x86/phpunit.phar/phpunit/Framework/TestSuite.php:409

PHP   7. PHPUnit_Util_Fileloader::checkAndLoad() phar://C:/Program Files (x86)/php-5.6.15-Win32-VC11-x86/phpunit.phar/phpunit/Framework/TestSuite.php:335

PHP   8. PHPUnit_Util_Fileloader::load() phar://C:/Program Files (x86)/php-5.6.15-Win32-VC11-x86/phpunit.phar/phpunit/Util/Fileloader.php:38

PHP   9. include_once() phar://C:/Program Files (x86)/php-5.6.15-Win32-VC11-x86/phpunit.phar/phpunit/Util/Fileloader.php:56

Process finished with exit code 255

This is in PSR0WebTest.php

<?php

namespace Drupal\simpletest\Tests {

  use DrupalWebTestCase;

  class PSR0WebTest extends DrupalWebTestCase {

    public static function getInfo() {
      return array(
          'name' => 'PSR0 web test',
          'description' => 'We want to assert that this PSR-0 test case is being discovered.',
          'group' => 'SimpleTest',
      );
    }

    function testArithmetics() {
      $this->assert(1 + 1 == 2, '1 + 1 == 2');
    }
  }
}
 


The files referenced do exist so I am not sure what the problem is.
9 comments
Comment actions Permalink

Hi there,

1. What is your PhpStorm version?
2. What is your PHPUnit version?
3. How did you installed PHPUnit (PHAR archive or via Composer)?
4. How did you configured PHPUnit in PhpStorm?

0
Comment actions Permalink

Here is my storm version - http://imgur.com/8aMLsAI  I am running this on Win 7 x64

I am using PHPUnit 5.0 with PhP 5.6.  I also tried PHPUnit 4.8 with PhP 5.5, both give the same error.  Oh, I also tried using 32-bit and 64-bit PhP, both give the same error.  

I did not install PHPUnit, I have troulbe with that in Composer.  But I jjust tried again in Composer since you just asked and I was able to get PHPUnit installed in Composer, not sure if this is what I should be using though - http://imgur.com/ZfVM95K  But I still get the same error I reported above.

For configuration of PHPUnit I was originally pointing to the phar file but since I just not got it installed in Composer I changed the setting to 'load from include path'. No change:

PHP Fatal error:  Class 'DrupalWebTestCase' not found in C:\Users\Baub\Baub\TR\code\web\aplha\html\modules\simpletest\lib\Drupal\simpletest\Tests\PSR0WebTest.php on line 5
PHP Stack trace:
PHP   1. {main}() C:\Users\Baub\AppData\Local\Temp\ide-phpunit.php:0

0
Comment actions Permalink

So ..

4. How did you configure PHPUnit in PhpStorm?

Have not seen anything for that yet.

-----

The error tells that PHP (yes, PHP itself) is unable to find your (well, Drupal's) classes.

Do you use bootstrap.php (where you can initiate some stuff (e.g. your own class autoloader; or modify php's include_path etc)) or some another class autoloading mechanism (e.g. Composer's autoload.php)? Try using them.

Try manually include/require file with that class -- will error be different?

-----

I just run PHPUnit tests in 2 custom libs (PhpStorm v10 on Windows 7; PHP 5.6.14; PHPUnit 4.5.1 & latest 5.0.8) -- they all went trough fine.

0
Comment actions Permalink
4. How did you configure PHPUnit in PhpStorm?




http://imgur.com/BR19Rdv

Was that what you were expecting?


Do you use bootstrap.php (where you can initiate some stuff (e.g. your own class autoloader; or modify php's include_path etc)) or some another class autoloading mechanism (e.g. Composer's autoload.php)? Try using them.

Try manually include/require file with that class -- will error be different?


I sort of know what you are asking here but not 100%.  I do have a 'bootstrap' dir and a 'custombootstrap' dir under 'html\sites\all\themes\' but none of those contain a bootstrap.php file.  I have attached my file structure.

I did find 'bootstrap.php' under \html\vendor\phpunit\phpunit\tests\.  Should I be referencing those somehow?



Attachment(s):
f.txt.zip
0
Comment actions Permalink

http://imgur.com/BR19Rdv

Was that what you were expecting?  

Yes.

It's just some people still making wrong choices here ... so I had to double check it.

I did find 'bootstrap.php' under \html\vendor\phpunit\phpunit\tests\.  Should I be referencing those somehow?


Do you have phpunit.xml file (or maybe phpunit.xml.dist) there? Try specifying it in that place from your last screenshot. If not -- specify that bootstrap.php there.

Thing is -- when running in terminal/console the PHPUnit may pick them up automatically .. but when running from within IDE it behaves more strictly (listens to parameters it was passed) and may be omitting them (I'm not 100% sure on this as I'm using my own phpunit.xml/bootstrrap.php all the time)

0
Comment actions Permalink

Got a different error about autoload.php (below)

http://imgur.com/iNjLVMM

Should I be using that as well as the phpunit.xml.dist file?  I found three:

C:\Users\Baub\Baub\TR\code\web\aplha\html\vendor\sebastian\comparator\tests\autoload.php
C:\Users\Baub\Baub\TR\code\web\aplha\html\sites\all\modules\mod_message\vendor\autoload.php
C:\Users\Baub\Baub\TR\code\web\aplha\html\vendor\autoload.php

As you can see in the settings, I specified one but got the following error:

C:\php-5.6.-x64\php.exe C:/Users/Baub/Baub/TR/code/web/aplha/html/vendor/phpunit/phpunit/phpunit --configuration C:\Users\Baub\Baub\TR\code\web\aplha\html\vendor\phpunit\phpunit\phpunit.xml.dist C:\Users\Baub\Baub\TR\code\web\aplha\html --teamcity
Testing started at 3:54 PM ...

Warning: require(C:\Users\Baub\Baub\TR\code\web\aplha\html\vendor\phpunit\phpunit\tests/../vendor/autoload.php): failed to open stream: No such file or directory in C:\Users\Baub\Baub\TR\code\web\aplha\html\vendor\phpunit\phpunit\tests\bootstrap.php on line 3

Call Stack:
    0.0000     235312   1. {main}() C:\Users\Baub\Baub\TR\code\web\aplha\html\vendor\phpunit\phpunit\phpunit:0
    0.0140     646504   2. PHPUnit_TextUI_Command::main() C:\Users\Baub\Baub\TR\code\web\aplha\html\vendor\phpunit\phpunit\phpunit:47
    0.0140     653960   3. PHPUnit_TextUI_Command->run() C:\Users\Baub\Baub\TR\code\web\aplha\html\vendor\phpunit\phpunit\src\TextUI\Command.php:108
    0.0140     656848   4. PHPUnit_TextUI_Command->handleArguments() C:\Users\Baub\Baub\TR\code\web\aplha\html\vendor\phpunit\phpunit\src\TextUI\Command.php:119
    0.0680     961880   5. PHPUnit_TextUI_Command->handleBootstrap() C:\Users\Baub\Baub\TR\code\web\aplha\html\vendor\phpunit\phpunit\src\TextUI\Command.php:628
    0.0780     970928   6. PHPUnit_Util_Fileloader::checkAndLoad() C:\Users\Baub\Baub\TR\code\web\aplha\html\vendor\phpunit\phpunit\src\TextUI\Command.php:799
    0.0790     971136   7. PHPUnit_Util_Fileloader::load() C:\Users\Baub\Baub\TR\code\web\aplha\html\vendor\phpunit\phpunit\src\Util\Fileloader.php:38
    0.0790     973936   8. include_once('C:\Users\Baub\Baub\TR\code\web\aplha\html\vendor\phpunit\phpunit\tests\bootstrap.php') C:\Users\Baub\Baub\TR\code\web\aplha\html\vendor\phpunit\phpunit\src\Util\Fileloader.php:56


Fatal error: require(): Failed opening required 'C:\Users\Baub\Baub\TR\code\web\aplha\html\vendor\phpunit\phpunit\tests/../vendor/autoload.php' (include_path='.;C:\php-5.6.-x64\pear;c:\php\includes;C:\Users\Baub\Baub\TR\code\web\OUTER-~1\html\includes') in C:\Users\Baub\Baub\TR\code\web\aplha\html\vendor\phpunit\phpunit\tests\bootstrap.php on line 3

Call Stack:
    0.0000     235312   1. {main}() C:\Users\Baub\Baub\TR\code\web\aplha\html\vendor\phpunit\phpunit\phpunit:0
    0.0140     646504   2. PHPUnit_TextUI_Command::main() C:\Users\Baub\Baub\TR\code\web\aplha\html\vendor\phpunit\phpunit\phpunit:47
    0.0140     653960   3. PHPUnit_TextUI_Command->run() C:\Users\Baub\Baub\TR\code\web\aplha\html\vendor\phpunit\phpunit\src\TextUI\Command.php:108
    0.0140     656848   4. PHPUnit_TextUI_Command->handleArguments() C:\Users\Baub\Baub\TR\code\web\aplha\html\vendor\phpunit\phpunit\src\TextUI\Command.php:119
    0.0680     961880   5. PHPUnit_TextUI_Command->handleBootstrap() C:\Users\Baub\Baub\TR\code\web\aplha\html\vendor\phpunit\phpunit\src\TextUI\Command.php:628
    0.0780     970928   6. PHPUnit_Util_Fileloader::checkAndLoad() C:\Users\Baub\Baub\TR\code\web\aplha\html\vendor\phpunit\phpunit\src\TextUI\Command.php:799
    0.0790     971136   7. PHPUnit_Util_Fileloader::load() C:\Users\Baub\Baub\TR\code\web\aplha\html\vendor\phpunit\phpunit\src\Util\Fileloader.php:38
    0.0790     973936   8. include_once('C:\Users\Baub\Baub\TR\code\web\aplha\html\vendor\phpunit\phpunit\tests\bootstrap.php') C:\Users\Baub\Baub\TR\code\web\aplha\html\vendor\phpunit\phpunit\src\Util\Fileloader.php:56

PHP Warning:  require(C:\Users\Baub\Baub\TR\code\web\aplha\html\vendor\phpunit\phpunit\tests/../vendor/autoload.php): failed to open stream: No such file or directory in C:\Users\Baub\Baub\TR\code\web\aplha\html\vendor\phpunit\phpunit\tests\bootstrap.php on line 3
PHP Stack trace:
PHP   1. {main}() C:\Users\Baub\Baub\TR\code\web\aplha\html\vendor\phpunit\phpunit\phpunit:0
PHP   2. PHPUnit_TextUI_Command::main() C:\Users\Baub\Baub\TR\code\web\aplha\html\vendor\phpunit\phpunit\phpunit:47
PHP   3. PHPUnit_TextUI_Command->run() C:\Users\Baub\Baub\TR\code\web\aplha\html\vendor\phpunit\phpunit\src\TextUI\Command.php:108
PHP   4. PHPUnit_TextUI_Command->handleArguments() C:\Users\Baub\Baub\TR\code\web\aplha\html\vendor\phpunit\phpunit\src\TextUI\Command.php:119
PHP   5. PHPUnit_TextUI_Command->handleBootstrap() C:\Users\Baub\Baub\TR\code\web\aplha\html\vendor\phpunit\phpunit\src\TextUI\Command.php:628
PHP   6. PHPUnit_Util_Fileloader::checkAndLoad() C:\Users\Baub\Baub\TR\code\web\aplha\html\vendor\phpunit\phpunit\src\TextUI\Command.php:799
PHP   7. PHPUnit_Util_Fileloader::load() C:\Users\Baub\Baub\TR\code\web\aplha\html\vendor\phpunit\phpunit\src\Util\Fileloader.php:38
PHP   8. include_once() C:\Users\Baub\Baub\TR\code\web\aplha\html\vendor\phpunit\phpunit\src\Util\Fileloader.php:56
PHP Fatal error:  require(): Failed opening required 'C:\Users\Baub\Baub\TR\code\web\aplha\html\vendor\phpunit\phpunit\tests/../vendor/autoload.php' (include_path='.;C:\php-5.6.-x64\pear;c:\php\includes;C:\Users\Baub\Baub\TR\code\web\OUTER-~1\html\includes') in C:\Users\Baub\Baub\TR\code\web\aplha\html\vendor\phpunit\phpunit\tests\bootstrap.php on line 3
PHP Stack trace:
PHP   1. {main}() C:\Users\Baub\Baub\TR\code\web\aplha\html\vendor\phpunit\phpunit\phpunit:0
PHP   2. PHPUnit_TextUI_Command::main() C:\Users\Baub\Baub\TR\code\web\aplha\html\vendor\phpunit\phpunit\phpunit:47
PHP   3. PHPUnit_TextUI_Command->run() C:\Users\Baub\Baub\TR\code\web\aplha\html\vendor\phpunit\phpunit\src\TextUI\Command.php:108
PHP   4. PHPUnit_TextUI_Command->handleArguments() C:\Users\Baub\Baub\TR\code\web\aplha\html\vendor\phpunit\phpunit\src\TextUI\Command.php:119
PHP   5. PHPUnit_TextUI_Command->handleBootstrap() C:\Users\Baub\Baub\TR\code\web\aplha\html\vendor\phpunit\phpunit\src\TextUI\Command.php:628
PHP   6. PHPUnit_Util_Fileloader::checkAndLoad() C:\Users\Baub\Baub\TR\code\web\aplha\html\vendor\phpunit\phpunit\src\TextUI\Command.php:799
PHP   7. PHPUnit_Util_Fileloader::load() C:\Users\Baub\Baub\TR\code\web\aplha\html\vendor\phpunit\phpunit\src\Util\Fileloader.php:38
PHP   8. include_once() C:\Users\Baub\Baub\TR\code\web\aplha\html\vendor\phpunit\phpunit\src\Util\Fileloader.php:56

Process finished with exit code 255

0
Comment actions Permalink

Well ... your screenshot seems to be OK (at least I do not see anything obviously wrong).

Should I be using that as well as the phpunit.xml.dist file?

I would at least try that.

I found three:

The one which I've used is from "vendor" folder. So .. #3.

-----

As it stands right now I not know what else to suggest.

If that project is open source .. or you can create some simple project that would reproduce the issue and profile whole proejct as zip archive (including PhpStorm settings, which are in .idea subfolder) then I could have a closer look.

No other useful ideas from me right now: you either wait and see if one of the devs/tech support guys will see this thread .. or try with support ticket at https://intellij-support.jetbrains.com/hc/en-us/requests/new

0
Comment actions Permalink

Something has got to be wrong in general.  I can't get anything to work, get the same error as in OP.


I created a 'new project' and added the drupal support.  I then added in a base drupal install.  Configured that and ran it, got the same error as in OP.

Is there a way to increase the logging anywhere in PHPStorm?

What is also strange to me is I have tried to get the same code working in PHPStorm in an Ubuntu VM.  I was getting the same error as on my Win7 x64 box so I just switched back to Win because it was faster.

0
Comment actions Permalink

I think (hope) I am making progress.  I found that just running 'php PSR0WebTest.php' from the command line also produced the error so I changed that php file and got it working in my environment so it doesn't throw any errors.  Now when I run the site I get the following (a bit different than before):

C:\xampp\php\php.exe C:\xampp\php\phpunit.phar --no-configuration C:\Users\Baub\Baub\TR\code\web\aplha --teamcity
Testing started at 3:39 PM ...

Warning: require_once(C:\Users\Baub\Baub\TR\code\web\aplha\html\sites\all\libraries\recurly\Tests/../vendor/autoload.php): failed to open stream: No such file or directory in C:\Users\Baub\Baub\TR\code\web\aplha\html\sites\all\libraries\recurly\Tests\test_helpers.php on line 3

Call Stack:
    0.0140     450392   1. {main}() C:\xampp\php\phpunit.phar:0
    0.1260    8174472   2. PHPUnit_TextUI_Command::main() C:\xampp\php\phpunit.phar:513
    0.1260    8178864   3. PHPUnit_TextUI_Command->run() phar://C:/xampp/php/phpunit.phar/phpunit/TextUI/Command.php:105
    0.1300    8183472   4. PHPUnit_Runner_BaseTestRunner->getTest() phar://C:/xampp/php/phpunit.phar/phpunit/TextUI/Command.php:128
   22.9343    8293672   5. PHPUnit_Framework_TestSuite->addTestFiles() phar://C:/xampp/php/phpunit.phar/phpunit/Runner/BaseTestRunner.php:58
   23.0013    8323520   6. PHPUnit_Framework_TestSuite->addTestFile() phar://C:/xampp/php/phpunit.phar/phpunit/Framework/TestSuite.php:409
   23.0053    8419592   7. PHPUnit_Util_Fileloader::checkAndLoad() phar://C:/xampp/php/phpunit.phar/phpunit/Framework/TestSuite.php:335
   23.0083    8419744   8. PHPUnit_Util_Fileloader::load() phar://C:/xampp/php/phpunit.phar/phpunit/Util/Fileloader.php:38
   23.0113    8425416   9. include_once('C:\Users\Baub\Baub\TR\code\web\aplha\html\sites\all\libraries\recurly\Tests\Recurly\Account_List_Test.php') phar://C:/xampp/php/phpunit.phar/phpunit/Util/Fileloader.php:56
   23.0143    8502520  10. require_once('C:\Users\Baub\Baub\TR\code\web\aplha\html\sites\all\libraries\recurly\Tests\test_helpers.php') C:\Users\Baub\Baub\TR\code\web\aplha\html\sites\all\libraries\recurly\Tests\Recurly\Account_List_Test.php:3


Fatal error: require_once(): Failed opening required 'C:\Users\Baub\Baub\TR\code\web\aplha\html\sites\all\libraries\recurly\Tests/../vendor/autoload.php' (include_path='.;C:\xampp\php\PEAR') in C:\Users\Baub\Baub\TR\code\web\aplha\html\sites\all\libraries\recurly\Tests\test_helpers.php on line 3

Call Stack:
    0.0140     450392   1. {main}() C:\xampp\php\phpunit.phar:0
    0.1260    8174472   2. PHPUnit_TextUI_Command::main() C:\xampp\php\phpunit.phar:513
    0.1260    8178864   3. PHPUnit_TextUI_Command->run() phar://C:/xampp/php/phpunit.phar/phpunit/TextUI/Command.php:105
    0.1300    8183472   4. PHPUnit_Runner_BaseTestRunner->getTest() phar://C:/xampp/php/phpunit.phar/phpunit/TextUI/Command.php:128
   22.9343    8293672   5. PHPUnit_Framework_TestSuite->addTestFiles() phar://C:/xampp/php/phpunit.phar/phpunit/Runner/BaseTestRunner.php:58
   23.0013    8323520   6. PHPUnit_Framework_TestSuite->addTestFile() phar://C:/xampp/php/phpunit.phar/phpunit/Framework/TestSuite.php:409
   23.0053    8419592   7. PHPUnit_Util_Fileloader::checkAndLoad() phar://C:/xampp/php/phpunit.phar/phpunit/Framework/TestSuite.php:335
   23.0083    8419744   8. PHPUnit_Util_Fileloader::load() phar://C:/xampp/php/phpunit.phar/phpunit/Util/Fileloader.php:38
   23.0113    8425416   9. include_once('C:\Users\Baub\Baub\TR\code\web\aplha\html\sites\all\libraries\recurly\Tests\Recurly\Account_List_Test.php') phar://C:/xampp/php/phpunit.phar/phpunit/Util/Fileloader.php:56
   23.0143    8502520  10. require_once('C:\Users\Baub\Baub\TR\code\web\aplha\html\sites\all\libraries\recurly\Tests\test_helpers.php') C:\Users\Baub\Baub\TR\code\web\aplha\html\sites\all\libraries\recurly\Tests\Recurly\Account_List_Test.php:3


Process finished with exit code 255



I wasn't able to figure out why this is happening.  We do have recurly installed on our site.
0

Please sign in to leave a comment.