This question already has an answer here:
PHPUnit error while creating unit test cases
(1 answer)
Closed 9 years ago.
am trying to write my first test in PHPUnit in Netbeans. I tried to follow the example on the Netbeans website http://netbeans.org/kb/docs/php/phpunit.html but I keep getting the error below. I dont have a clue what is happening as I did everything just the way I was instructed on the website.
> PHP Fatal error: Class 'Calculator' not found in C:\wamp\www\Calculator\tests\CalculatorTest.php on line 18
PHP Stack trace:
PHP 1. {main}() C:\wamp\bin\php\php5.3.8\phpunit:0
PHP 2. PHPUnit_TextUI_Command::main() C:\wamp\bin\php\php5.3.8\phpunit:46
PHP 3. PHPUnit_TextUI_Command->run() C:\wamp\bin\php\php5.3.8\pear\PHPUnit\TextUI\Command.php:130
PHP 4. PHPUnit_TextUI_TestRunner->doRun() C:\wamp\bin\php\php5.3.8\pear\PHPUnit\TextUI\Command.php:192
PHP 5. PHPUnit_Framework_TestSuite->run() C:\wamp\bin\php\php5.3.8\pear\PHPUnit\TextUI\TestRunner.php:325
PHPUnit 3.6.12 by Sebastian Bergmann.
PHP 6. PHPUnit_Framework_TestSuite->run() C:\wamp\bin\php\php5.3.8\pear\PHPUnit\Framework\TestSuite.php:705
PHP 7. PHPUnit_Framework_TestSuite->runTest() C:\wamp\bin\php\php5.3.8\pear\PHPUnit\Framework\TestSuite.php:745
PHP 8. PHPUnit_Framework_TestCase->run() C:\wamp\bin\php\php5.3.8\pear\PHPUnit\Framework\TestSuite.php:772
PHP 9. PHPUnit_Framework_TestResult->run() C:\wamp\bin\php\php5.3.8\pear\PHPUnit\Framework\TestCase.php:751
PHP 10. PHPUnit_Framework_TestCase->runBare() C:\wamp\bin\php\php5.3.8\pear\PHPUnit\Framework\TestResult.php:649
PHP 11. CalculatorTest->setUp() C:\wamp\bin\php\php5.3.8\pear\PHPUnit\Framework\TestCase.php:801
Any help would be appreciated to help me understand what am doing wrong please.
Screen shot
You should make sure that the file containing the class Calculator can be found by the unittest.
require_once dirname(__FILE__) . '/../Calculator.php';
The test class is placed in a subdirectory, so you need to declare the path relative to the file, containing the unittest. Maybe your application uses autoloading, but your unittest doesn't know about it.
If you use Netbeans to create the unittest, the path should already be correct.
PHP Fatal error: Class 'Calculator' not found
If you did the same as in the webpage, why can Calculator be loaded in the web?
Try including the files he is complaining about.
Related
I have tried to run/debug multiple projects on PhpStorm (two of them are imported, one is created on phpstorm) Each of them gives me (different) PHP Fatal errors when I run or debug.
This is the first error.
PHP Fatal error: Class 'Doctrine\Tests\Common\Cache\CacheTest' not found in C:\wamp64\www\bodisatva\vendor\doctrine\cache\tests\Doctrine\Tests\Common\Cache\ApcCacheTest.php on line 10
Problem is that CacheTest exists.
The second project:
PHP Fatal error: Class 'Doctrine\Tests\DoctrineTestCase' not found in C:\wamp64\www\larasocial\vendor\doctrine\inflector\tests\Doctrine\Tests\Common\Inflector\InflectorTest.php on line 8
Again, it exists.
Project that I completely set up on PhpStorm for testing.
PHP Fatal error: Class 'Tests\Behat\Gherkin\Keywords\KeywordsTest' not found in C:\wamp64\www\larazine\vendor\behat\gherkin\tests\Behat\Gherkin\Keywords\ArrayKeywordsTest.php on line 8
Different and same.
Am I missing something? I tried to google these errors only to find specific (but probably outdated as I had even more errors trying them) solutions.
How did you configure PHPUnit in File | Settings | Languages & Frameworks | PHP | PHPUnit? Is it PHPunit 5 or 6? You might want to attach a screenshot of your config here.
Are there any inspection errors in C:\wamp64\www\larasocial\vendor\doctrine\inflector\tests\Doctrine\Tests\Common\Inflector\InflectorTest.php on line 8, e.g. DoctrineTestCase or TestCase are highlighted?
This question already has answers here:
Symfony 2 - Fatal error: Cannot redeclare class SessionHandlerInterface in C:\...\app\cache\dev\classes.php on line 532
(7 answers)
Closed 6 years ago.
I have a working symfony project on my linux computer.
I'm trying to set it up with hosting www.one.com
I wrote a .htaccess file but I'm getting the following error:
Fatal error: Cannot declare interface Symfony\Component\DependencyInjection\ContainerAwareInterface, because the name is already in use in /customers/x/x/x/xxxxxxxxxx.be/httpd.www/var/cache/dev/classes.php on line 6397
Can anyone help me in the write direction?
ps:
I followed the guide http://trac.symfony-project.org/wiki/InstallingSymfonyOnOne but it does not seems to be working.
A guide which you are following is about Symfony 1.x, interface you mention is from Symfony 2 so you have a mismatch here. Try to follow this guide (and remember that Symfony 1.x and 2.x/3.x has nothing in common).
And just a guess: try to clear the cache on your new machine:
app/console cache:clear --env=prod
The error in question:
[RuntimeException]
Error Output: PHP Warning: require(/home/admin/web/"webpage"/public_html/test/app/Http/helpers.php): failed to open stream: N
o such file or directory in /home/admin/web/"webpage"/public_html/test/vendor/composer/autoload_real.php on line 58
PHP Stack trace:
PHP 1. {main}() /home/admin/web/"webpage"/public_html/test/artisan:0
PHP 2. require() /home/admin/web/"webpage"/public_html/test/artisan:16
PHP 3. require() /home/admin/web/"webpage"/public_html/test/bootstrap/autoload.php:17
PHP 4. ComposerAutoloaderInit95cd02d44d232a8b8d6e5e52544d8647::getLoader() /home/admin/web/"webpage"/public_html/test/vendor
/autoload.php:7
PHP 5. composerRequire95cd02d44d232a8b8d6e5e52544d8647() /home/admin/web/"webpage"/public_html/test/vendor/composer/autoload
_real.php:49
PHP Fatal error: require(): Failed opening required '/home/admin/web/"webpage"/public_html/test/app/Http/helpers.php' (includ
e_path='/home/admin/web/"webpage"/public_html/test/vendor/phpunit/php-text-template:/home/admin/web/"webpage"/pub
lic_html/test/vendor/phpunit/php-timer:.:/usr/share/pear:/usr/share/php') in /home/admin/web/"webpage"/public_html/test/vendor
/composer/autoload_real.php on line 58
PHP Stack trace:
PHP 1. {main}() /home/admin/web/"webpage"/public_html/test/artisan:0
PHP 2. require() /home/admin/web/"webpage"/public_html/test/artisan:16
PHP 3. require() /home/admin/web/"webpage"/public_html/test/bootstrap/autoload.php:17
PHP 4. ComposerAutoloaderInit95cd02d44d232a8b8d6e5e52544d8647::getLoader() /home/admin/web/"webpage"/public_html/test/vendor
/autoload.php:7
PHP 5. composerRequire95cd02d44d232a8b8d6e5e52544d8647() /home/admin/web/"webpage"/public_html/test/vendor/composer/autoload
_real.php:49
Background: Was developing locally, got to the point where I wanted to have a staging site. Set up the staging site on digital ocean (entOS 6.5 x64). I then cloned my git repo into my desired folder - configured vhosts DefaultDirectory to my public path.
A default installation works, composer update/install works. However, with my cloned repository I am getting said error. '/home/admin/web/"webpage"/public_html/test/app/Http/helpers.php' is a file I made with some helper methods I could use in various controllers. It has not caused any problems locally. I can composer update/install locally, without any problems.
Any guidance would be greatly appreciated!
Are those literal quotation marks in your file path
/home/admin/web/"webpage"/public_html/test/app/Http/helpers.php
Or are you just using that to indicate your website name normally goes there? If the former, I'd consider not doing that as it's pretty weird to have quotes in unix file names, and you may run into problems based on assumptions other people have made.
Regardless -- you have the information you need
[RuntimeException] Error Output: PHP Warning: require(/home/admin/web/"webpage"/public_html/test/app/Http/helpers.php): failed to open stream: N o such file or directory in /home/admin/web/"webpage"/public_html/test/vendor/composer/autoload_real.php
PHP is telling you it tried to require in a specific file
/home/admin/web/"webpage"/public_html/test/app/Http/helpers.php
but it could not find it ("failed to open stream"). This means either the file doesn't exist on the computer you're trying to load it from, or PHP can't see it for some reason (try dumping the results of is_readable('/home/admin/web/"webpage"/public_html/test/app/Http/helpers.php'); to see if PHP thinks it can read the file or not.
I have a Symfony2 project with some functional tests.
When I run the test suite without code coverage enabled, there is no problem.
But when I am trying to generate the code coverage I am getting a PHP Fatal error :
Generating code coverage report, this may take a moment.
PHP Fatal error: Allowed memory size of 209715200 bytes exhausted
(tried to allocate 79 bytes) in /usr/share/php/PHP/Token/Stream.php on line 205
PHP Stack trace:
PHP 1. {main}() /usr/bin/phpunit:0
PHP 2. PHPUnit_TextUI_Command::main() /usr/bin/phpunit:46
PHP 3. PHPUnit_TextUI_Command->run() /usr/share/php/PHPUnit/TextUI/Command.php:130
PHP 4. PHPUnit_TextUI_TestRunner->doRun() /usr/share/php/PHPUnit/TextUI/Command.php:192
PHP 5. PHP_CodeCoverage_Report_HTML->process() /usr/share/php/PHPUnit/TextUI/TestRunner.php:373
PHP 6. PHP_CodeCoverage->getReport() /usr/share/php/PHP/CodeCoverage/Report/HTML.php:133
PHP 7. PHP_CodeCoverage_Report_Factory->create() /usr/share/php/PHP/CodeCoverage.php:141
PHP 8. PHP_CodeCoverage_Report_Factory->addItems() /usr/share/php/PHP/CodeCoverage/Report/Factory.php:76
PHP 9. PHP_CodeCoverage_Report_Factory->addItems() /usr/share/php/PHP/CodeCoverage/Report/Factory.php:98
PHP 10. PHP_CodeCoverage_Report_Node_Directory->addFile() /usr/share/php/PHP/CodeCoverage/Report/Factory.php:94
PHP 11. PHP_CodeCoverage_Report_Node_File->__construct() /usr/share/php/PHP /CodeCoverage/Report/Node/Directory.php:211
PHP 12. PHP_CodeCoverage_Util::getLinesToBeIgnored() /usr/share/php/PHP/CodeCoverage/Report/Node/File.php:166
PHP 13. PHP_Token_Stream_CachingFactory::get() /usr/share/php/PHP/CodeCoverage/Util.php:254
PHP 14. PHP_Token_Stream->__construct() /usr/share/php/PHP/Token/Stream/CachingFactory.php:68
PHP 15. PHP_Token_Stream->scan() /usr/share/php/PHP/Token/Stream.php:147
I already modified memory_limit for both cli and server php.ini.
I also already modified the memory_limit of suhosin.
When I print a phpinfo() in the cli I got these values :
memory_limit => 2048M => 2048M
suhosin.memory_limit => 2G => 2G
Does anyone has an idea of what may be causing this problem ? Has anyone faced such a situation ?
Looks like it stops at 200 Megabytes so either you need to look through your config more to allow more memory to be used or you have an include loop somewhere in the code. This has happened to me with twig includes a couple of times
Increase your PHP Memory Limit (I used 1744M to leave some safety space for PHP). I had the same problem before doing the extra memory. The next thing I changed was to exclude external libraries from the code-coverage (they are tested in their package by the author, so I do not need to know their code-coverage in my project). This allowed our project to then parse properly and get proper code coverage analysis.
I'm developing a PHP application which generating reports to PDF
Right now I'm facing some troubles
I'm working from my own computer with XAMPP Server and the code ran well
But when I copied the codes to my office's WAMP5 Version 1.6.5 Server I got errors
Fatal error: Call to undefined function array_fill_keys() in D:\wwwroot\tcpdf\include\tcpdf_fonts.php on line 1848
I went to that troubled line and removed it, but another Fatal error: Call to undefined function occured
Is there something wrong with my WAMP5 configuration?
Thanks
Your version of php is to old... as Royal Bg suspected.
Either upgrade to 1.6.6 for php 5.2. But if there is no reason to use such an old version switch to something less than 7 years old :)
see:
http://sourceforge.net/p/wampserver/news/?source=navbar