Asked  3 Months ago    Answers:  5   Viewed   64 times

I am using the Symfony3 plugin in PhpStorm. My PHP Interpreter is 7.0.18. I have PHPUnit 6.3.0 configured in PhpStorm by having the .phar file in the root directory of my project.

Unit test work like a charm inside the IDE however performing any operation on the server (like bin/console server:start) triggers the following messages:

PHP Fatal error: Class 'PHPUnitFrameworkTestCase' not found in /1tb/programming/PhpstormProjects/binary_search/src/AppBundle/Search/BinarySearchTest.php on line 13
PHP Fatal error: Class 'PHPUnitFrameworkTestCase' not found in /1tb/programming/PhpstormProjects/binary_search/vendor/symfony/symfony/src/Symfony/Bundle/FrameworkBundle/Tests/TestCase.php on line 17

BinarySearchTest.php:

 <?php

namespace AppBundleSearch;

use PHPUnitFrameworkTestCase;

class BinarySearchTest extends TestCase
{

}

TestCase.php:

<?php

namespace SymfonyBundleFrameworkBundleTests;

use PHPUnitFrameworkTestCase as PHPUnitTestCase;

class TestCase extends PHPUnitTestCase
{

}

I have read many posts with problems similar but none of them describe the problem the way I do. Then I tried running PHPUnit with phpunit . in the root directory of the folder with this error:

PHP Fatal error: Class 'DoctrineTestsCommonCacheCacheTest' not found in /1tb/programming/PhpstormProjects/binary_search/vendor/doctrine/cache/tests/Doctrine/Tests/Common/Cache/ApcCacheTest.php on line 10

It seems whatever I do I just run into more errors. I only just got started with Symfony and read a bit of the documentation but I can't get a grip on this thing, I have been at it for two days. Any suggestions for me?

 Answers

40

Installation of PHPUnit via composer worked. It turns out my composer installation went wrong in some way. After composer was successfully installed, I let it handle installing PHPUnit. After that it just worked. Tests work fine in the IDE and the server is responsive again. Thanks LazyOne.

Wednesday, September 1, 2021
 
bayman
answered 3 Months ago
79

On Mac OS X environment variables available in Terminal and for the normal applications can be different, check the related question for the solution how to make them similar.

Note that this solution will not work on Mountain Lion (10.8).

Saturday, May 29, 2021
 
Nate
answered 7 Months ago
38

PhpStorm has special integration script to run PHPUnit tests (all messages/progress indicators are transferred into GUI part where you can easily see what tests have passed and what did not etc).

PhpStorm's console does not support ANSI colors -- http://youtrack.jetbrains.com/issue/IDEA-69880 and related tickets.

But you can install Grep Console plugin and it will add support for ANSI colors (needs to be activated in Settings). I have tried it with PHPUnit and it worked -- not everything was colored (some of the codes were not recognized, but most worked). You can contact plugin author with not working parts if desired.

Saturday, May 29, 2021
 
Zeth
answered 7 Months ago
37

PHP classes should be defined before instantiation, see the "new" section of the PHP OO documentation.

An easy way to achieve that is by first declaring the classes and then the main code:

--PublicacionController.php--
<?php
/*Some random includes, those are 
right as far as I'm concerned*/

class PublicacionController extends Controller{/* STUFF*/}

//AJAX call
if(!empty($_POST)){
    if($_POST['call']=='nuevaPublicacion'){
        $pc = new PublicacionController();
        $pc->nuevaPublicacion($_POST);
        exit;
    }
}

?>
Friday, October 22, 2021
 
Kevin S.
answered 2 Months ago
12

Got the solution ,it is happening because of instant run, Just disable it

Goto :

Android Studio --> File --> Setting --> Build, execution, deploy -->  Instant run.
Friday, November 5, 2021
 
Muazam
answered 1 Month ago
Only authorized users can answer the question. Please sign in first, or register a free account.
Not the answer you're looking for? Browse other questions tagged :  
Share