1
votes

I am having a problem with my PHP project (using the Kohana 3.2 framework) in PHPStorm 4.0.3. When setting up PHPUnit with the Class or Method scope, it is not able to detect the class from the specified unit testing file if the test class extends from Unittest_Database_Testcase.

For example, I could not test the below class because the Choose Test Class dialog box displays "Nothing to show".

/**
 * Class cannot be chosen.
 */
class A_Test extends Unittest_Database_Testcase {
    public function test_something() { /* ... hence this method test cannot be chosen */ }
}

However, if the file extends from Unittest_Testcase, the class (and subsequently the method) can be detected by PHPStorm and I was able to run the test.

class A_Test extends Unittest_Testcase {
    public function test_something() {}
}

I suspect the reason is that PHPStorm is yet to support running database testing individually. Is there a way to get around this?

Note: I have no problems with running the entire test suite, however, I am concerned that the number of tests are growing. It takes roughly half a second to run a single database test (due to the queries involved) hence it will be very time-consuming to run the entire test suite every time I need to verify a newly-written test is working properly.

1
When you Ctrl+Click on Unittest_Database_Testcase, does it take you to class definition? If it does -- can you go further (to parent class of this class and so on)? I've seen the message in the past, for kind of similar situation, and an advice was to make sure that PhpStorm knows about PHPUnit classes (e.g. PHPUnit files added to the project as External Library).LazyOne
It works now - I did not include PHPUnit as an external library. However, it now fails for a different reason: I have an abstract class named "Abstract_Class" which sits inbetween Unittest_Database_Testcase and my unit test file (i.e. it inherits all tests from the abstract class). Every time I run a single test, it just says "Class 'Abstract_Class' not found". It was somehow not recognised...Arthur Rimbun
Who says that -- PHPUnit or PhpStorm? Keep in mind that PHPUnit is the one that executes the tests, PhpStorm only does the integration thing, therefore that "Abstract_Class" should be available for PHP during execution.LazyOne
Ah it works now. I had to manually include Abstract_Class in the bootstrap file. Probably because it was not included automatically when PHPUnit was pointed to the test file. Thanks!Arthur Rimbun

1 Answers

1
votes

For anyone who missed it, the OP found the answer and posted it in the comments...

I had to manually include Abstract_Class in the bootstrap file. Probably because it was not included automatically when PHPUnit was pointed to the test file.