12

I've spent some time to figure out how to configure Netbeans 7.1 to work with Symfony 2 and PHPUnit, but I didn't succeed. When I try to run any test under console, there is no problem. But when running using shift+F6, it returns

"PHP Fatal error: Class 'Symfony\Bundle\FrameworkBundle\Test\WebTestCase' not found"

Does anybody know how to succeed with such kind of configuration?

hakre
  • 193,403
  • 52
  • 435
  • 836
pbuchman
  • 161
  • 2
  • 5
  • 1
    Make sure you have pointed NetBeans to your `phpunit.xml` and `bootstrap.php` files. The latter must set up the include path and autoloader (if necessary). It might help if you can post your `bootstrap.php` file too. – David Harkness Jan 09 '12 at 07:16

2 Answers2

20

I had the same issue with Netbeans 7.2 This is what I had to do:

  1. Right click on the symfony2 project -> Properties -> PHPUnit
  2. Here check on the "Use Bootstrap" and Browse to the \app\bootstrap.php.cache
  3. Also check on the "Use XML configuration" and Browse to \app\phpunit.xml.dist.

After saving, the ALT+F6 should work

Kristóf Dombi
  • 3,927
  • 3
  • 18
  • 14
  • 5
    I also had to point it to a "directory with tests". I just gave it `src/`. Unfortunately, this makes all my custom source show up under "Test files", but I'm not sure how this can be helped. I also like using a custom suite to run only certain tests. See http://forum.symfony-project.org/viewtopic.php?f=23&t=33543 – Adam Monsen Sep 13 '12 at 11:01
  • 1
    I did what you wrote and NetBeans 7.2.1 asks me to define Test Source directory. It's confusing, since tests are inside different bundles all around src directory. Anyone had the same problem? – ducin Jan 14 '13 at 16:33
  • Here is a solution for not defined Test dir: http://forum.symfony-project.org/viewtopic.php?t=33543 Basically, you have to create a custom test suite. – Jevgenij Evll Jun 13 '13 at 17:38
  • @tkoomzaaskz It may sound like a lot of work but you can add multiple test directories e.g. src\Acme\AppBundle\Tests, src\Acme\App2Bundle\Tests, src\Acme2\FooBundle\Tests etc. - that will only put these files into the NetBeans Test Files folder. – webDEVILopers Jan 21 '15 at 10:51
  • On **Netbeans 8.1** i had to use the `\app\autoload.php` instead of the `\app\bootstrap.php.cache` as bootstrap file – eXe Mar 04 '16 at 20:45
1

Instead of putting src/ folder as a test folder, the better idea is to create symbolic link by executing:

mklink /D tests src

inside project folder in Windows. This way we have src folder in "Source files" and phpunit testing works great.

I can't answer to Kristóf Dombi answer so I have to put this answer here.

atay
  • 155
  • 10