sebastianbergmann / phpunit Goto Github PK
View Code? Open in Web Editor NEWThe PHP Unit Testing framework.
Home Page: https://phpunit.de/
License: BSD 3-Clause "New" or "Revised" License
The PHP Unit Testing framework.
Home Page: https://phpunit.de/
License: BSD 3-Clause "New" or "Revised" License
I noticed that the Trac ticket listener is no longer present. Is that a temporary situation, or is it no longer maintained or usable?
Graham 'itrebal'
I searched for a long time but could not find any solution. I tried to use the @Depends parameter with SeleniumTestCase but it did not work.
Is it because this is not implemented in SeleniumTestCase or is there some special trick to get it work?
If it's not implemented, consider this issues as a feature-request :-)
I sure would love to have the output formatted like below. Is this a possibility in the future?
Or, could I be pointed to where that is done so that I could modify the code?
..... .....
..... .....
..... .....
..... .....
..... .....
..... .....
etcetera
Chapter 2 should refer to 'count()' not 'sizeof()'.
I expect to have the test methods name and test methods line number in stack trace, when a expected exception was not raised on the test method where i used the setExpectedException() method. Would be great if we can have the line number of the setExpectedException() call also in the stack trace.
The missing stack trace (and missing line numbers) makes my IDE (netbeans) unable to navigate to the failing test method by clicking on the failing test in the "Test Results" windows.
The example below will only add the /path/to/*Test.php
files and /path/to/MyTest.php
file if the PHP version is at least 5.3.0.
<testsuite name="My Test Suite">
<directory phpVersion="5.3.0" phpVersionOperator=">=">/path/to/*Test.php files</directory>
<file phpVersion="5.3.0" phpVersionOperator=">=">/path/to/MyTest.php</file>
</testsuite>
The phpVersionOperator
attribute is optional and defaults to >=
.
The comparison will be implemented as
version_compare(PHP_VERSION, <phpVersion>, <phpVersionOperator>)
Fatal error: Class 'PHPUnit_TextUI_TestRunner' not found in /usr/share/php/PHPUnit/TextUI/Command.php on line 140
Hi
Since the update to phpunit 3.5 I receive the following error for the code:
$this->assertType('string', 'Hello world');
Failed opening required 'string.php'
The reason is probably my autoloader. I first hat this problem with the Zend_Framework Autoloader, and then tried my own autoloader:
function test_autoload($class) {
$file = str_replace('_', '/', $class) . '.php';
require_once $file;
}
spl_autoload_register('test_autoload');
The reason that the exception is thrown is because my autoloader is called by the function class_exists in PHPUnit_Framework_Assert. Should I use assertType only for classs and not string, int etc.? Or how should I modify my autoloader? Is this an expected behaviour?
I saw in phpunit.bat that it uses a enviroment variables to find the php_bin and phpunit are installed, these variables could be created automatic using setx.exe or using a php setup to generate phpunit.bat file.
Due to this, assertion of XML is impossible using PHPUnit_Framework_Assert::assertSelect*().
Here is a patch:
diff --git a/PHPUnit/Util/XML.php b/PHPUnit/Util/XML.php
index 3e73b76..d369fba 100644
--- a/PHPUnit/Util/XML.php
+++ b/PHPUnit/Util/XML.php
@@ -522,12 +522,13 @@ class PHPUnit_Util_XML
* @since Method available since Release 3.3.0
* @author Mike Naberezny <[email protected]>
* @author Derek DeVries <[email protected]>
+ * @author Tobias Schlitt <[email protected]>
*/
public static function cssSelect($selector, $content, $actual, $isHtml = TRUE)
{
$matcher = self::convertSelectToTag($selector, $content);
$dom = self::load($actual, $isHtml);
- $tags = self::findNodes($dom, $matcher);
+ $tags = self::findNodes($dom, $matcher, $isHtml);
return $tags;
}
Our 404 pages return content as well as a 404 HTTP status. PHPUnit throws a Framework_Exception when a 404 page is loaded so I can't test the page.
I've upgraded PHPUnit to 3.5.0 and found this:
phpunit works normal until "--repeat" option is used. With "--repeat 2" I got:
PHP Fatal error: Class 'PHPUnit_Extensions_RepeatedTest' not found in
/usr/share/pear/PHPUnit/TextUI/TestRunner.php on line 166
without it - it works.
And, btw, requiring 'PHPUnit/Extensions/TestDecorator.php' from within test didn't fix the problem.
Example:
$this->assertSelectCount(
'textarea[name=somename]', 1, $html,
'The generated textarea name is missing or incorrect!'
);
If the selector doesn't match anything, the output message is just "Failed asserting that integer:0 matches expected integer:1."
The parameter $message is lost when calling assertEquals from assertSelectEquals.
Specifying the --process-isolation
flag will raise errors for global objects that implement the Serializable
interface. Consider the following test:
<?php
class AClass implements Serializable {
public function serialize() { return serialize('abc'); }
public function unserialize($data) {}
}
$GLOBALS['A'] = new AClass;
class ATest extends PHPUnit_Framework_TestCase
{
public function testTrue()
{
$this->assertTrue(true);
}
}
Running this test with the --process-isolation
flag will raise the following error:
$ phpunit --process-isolation ATest.php
PHPUnit 3.5.0RC2 by Sebastian Bergmann.
E
Time: 0 seconds, Memory: 5.25Mb
There was 1 error:
1) ATest::testTrue
RuntimeException: PHP Warning: Class __PHP_Incomplete_Class has no unserializer in - on line 79
PHP Stack trace:
PHP 1. {main}() -:0
PHP 2. unserialize() -:79
FAILURES!
Tests: 1, Assertions: 0, Errors: 1.
This happens because http://github.com/sebastianbergmann/phpunit/blob/master/PHPUnit/Framework/Process/TestCaseMethod.tpl.dist processes globals before it processes included files. For objects that implement the Serializable
interface this will not work as the class declaration is needed before the object can be unserialized.
Hi
I use Galileo Eclipse with PHPUnit 3.4.9. The PHPUnit Source Folder Pattern is set to the default "/%p/tests/%d"
When I try to run phpunit I get the following in the eclipse console:
/usr/bin/php -c /tmp/zend_debug/session2774194926505594077.tmp -d asp_tags=off /home/srikanth/.eclipse/org.eclipse.platform_3.5.0_155965261/plugins/org.phpsrc.eclipse.pti.tools.phpunit_0.4.0.R20100628000000/php/tools/phpunit.php --log-junit "/tmp/pti_phpunit/phpunit.xml" FluentDOMTest "/home/srikanth/code/FluentDOM/tests/FluentDOMTest.php"
PHPUnit 3.4.9 by Sebastian Bergmann.
Cannot open file "./"/home/srikanth/code/FluentDOM/tests/FluentDOMTest.php"".
Somehow "./" is added before the actual directory! Could you please help me on how to fix this?
Thanks
Srikanth
PHPUnit/Util/File.php does not halt upon token T_HALT_COMPILER. This may cause problems later on. For example flow3 stores something like "[...]CLASS[....]some_name" after halt-compiler and phpunit seems to interpret this as a new class but withou end ('endLine' won't be set ever). See http://lists.typo3.org/pipermail/flow3-general/2010-October/000603.html for details and possible fix. Greetings Martin.
Greetings,
This happens in PHPUnit 3.5.0, on PHP 5.2.13, with XDebug 2.1.0:
In some classes (most of them, in fact) of my project, lines that are not covered do not appear hilighted (neither gray, green nor orange). And now most of the concerned class are marked as beeing 100% covered when they shouldn't.
Regards
Hello,
I have been using PHPUnit and to be honest I really like it. I just had a question:
When running a test in process isolation:
===== SYSTEM UNDER TEST.php =====
<?php class MyHello { public function sayHello() { system('echo hey >&2'); return 'I feel good'; } } ?>
==== TEST RUNNER FILE.php ======
<?php require_once 'PHPUnit/Framework.php'; /** * @runTestsInSeparateProcesses */ class MyHelloTest extends PHPUnit_Framework_TestCase { public function testSayHello() { require_once 'test.php'; $myHello = new MyHello(); $out = $myHello->sayHello(); $this->assertTrue($out === 'I feel good'); } } ?>
====== OUTPUT =====
localhost 21:34:29 ~ $ phpunit runtest.php PHPUnit 3.4.12 by Sebastian Bergmann. E Time: 0 seconds, Memory: 4.50Mb There was 1 error: 1) MyHelloTest::testSayHello RuntimeException: hey FAILURES! Tests: 1, Assertions: 0, Errors: 1.
If there is anything written to the STDERR, the test is considered to be a failure. Is there any way to intersect line 179 in
excerpt from http://github.com/sebastianbergmann/phpunit/blob/3.5/PHPUnit/Util/PHP.php
173 * @param string $stdout 174 * @param string $stderr 175 * @since Method available since Release 3.5.0 176 */ 177 protected static function processChildResult(PHPUnit_Framework_Test $test, PHPUnit_Framework_TestResult $result, $stdout, $stderr) 178 { 179 if (!empty($stderr)) { 180 $time = 0; 181 $result->addError( 182 $test, 183 new RuntimeException(trim($stderr)), $time 184 ); 185 } else {
I couldn't find a way to do this in an object oriented way. Could you allow a hook on line 605 of TestCase.php
excerpt from http://github.com/sebastianbergmann/phpunit/blob/3.5/PHPUnit/Framework/TestCase.php
603 $this->prepareTemplate($template); 604 605 PHPUnit_Util_PHP::runJob($template->render(), $this, $result); 606 } else { 607 $result->run($this);
I don't want to copy paste the entire run() method in TestCase.php in my class that extends PHPUnit_Framework_TestCase and modify line 605
excerpt from
http://github.com/sebastianbergmann/phpunit/blob/3.5/PHPUnit/Framework/TestCase.php
488 public function run(PHPUnit_Framework_TestResult $result = NULL)
just to be able to judge if a test is actually a success and the output in STDERR buffer is just extra noise. I couldn't find a way as I said, because
a) PHPUnit_Util_PHP::runJob() is called within run()
b) after it's called, I have no way to intersect stderr returned by the result from test in separate process
Any help is really appreciated. Thank you.
When running phpunit.bat on a freshly installed 3.5.0RC1 I get an error like "Files not expected" (sorry if it's not the real error, my OS is not english). A bit of debugging showed that the path environment variable PHPBIN was had double "double quotes". I'm not a .bat expert but here's one that works for me:
if "%PHPBIN%" == "" set PHPBIN=C:\Program Files (x86)\PHP\php.exe
if not exist "%PHPBIN%" if "%PHP_PEAR_PHP_BIN%" neq "" goto USE_PEAR_PATH
GOTO RUN
:USE_PEAR_PATH
set PHPBIN=%PHP_PEAR_PHP_BIN%
:RUN
"%PHPBIN%" "C:\Program Files (x86)\php\phpunit" %*
Some IDEs have some command line switches hardcoded to support phpunit (e.g. netbeans). The only way to configure phpunit behavior is to provide a "XML Configuration File" - one big issue is that command line switches wins against xml options.
E.g.: netbeans runs phpunit by using the command line switch "--log-junit". At the moment there is no way in netbeans to add the "--verbose" switch. In the xml configuration file there is no separate xml element to make phpunit to be verbose. The only way is to use this:
<logging> <log type="junit" target="/tmp/logfile.xml" logIncompleteSkipped="true"/> </logging>
But this xml element is igored by phpunit when "--log-junit" command line switch is given.
Solution:
a) add an independent xml element (verbose) to supplement the "--log-junit" command line switch
b) add a "force" attribute to each xml element to determ if a xml option should override a command line switch (to invert default override behavior)
To me solution a would be better, because i donยดt know at what path netbeans expects the result xml. Maybe you implement both to make phpunit more flexible.
Yes indeed a change to the code of netbeans can solve this issue, too. But we all know how long to wait to have a feature request implemented in closed souce software... And i think this is not an issue specific to netbeans, there are probably other programs out there calling phpunit by hardcoded command line switches.
I get the following error when using the --process-isolation option.
RuntimeException: Parse error: syntax error, unexpected T_CONSTANT_ENCAPSED_STRING
You can reproduce it using this code: http://github.com/caefer/sfPhpUnitDbBootstrapExperimentPlugin
Follow the README.md instruction for setup and perform the included experiments (<2minutes).
The code that writes out global PHP data to a serialized string doesn't take into account the case where the serialized data contains single quotes - when it does, the string being passed to unserialize results in a parse error.
It's this line:
http://github.com/sebastianbergmann/phpunit/blob/master/PHPUnit/Util/GlobalState.php#L323
When I have a tree of depending tests:
They are executed linearily and still the same object is passed as argument, so for example at testIpsum, I got the object with changes from testLorem). Which I consider as unexpected and not wanted behaviour.
I think that the order of executed tests should be tree-like, everytime with a new object:
running testBasic: testBasic
running testBar: testBasic - testBar
running testLorem: testBasic - testLorem
running testFoo: testBasic - testLorem - testFoo
running testIpsum - testBasic - testIpsum
Trying out PHPUnit 3.5 got me confused for two days. First, I tried to add new tests for some new models I created in Symfony2 PR3's sandbox, which failed with a weird error:
RuntimeException: PHP Parse error: parse error in
C:\(...)\symony2_pr3\-
on line 131 (notice the\-
at the end of the path)
Thinking it was related to Symfony, I left it there. Today, I wanted to introduce PHPUnit into another (non-Symfony) project. Eventually, I ran into the same error:
RuntimeException: PHP Parse error: parse error in
C:\(...)\MyProject\-
on line 141 (again, notice the\-
at the end of the path)
After some trial-and-error, I removed processIsolation="true"
from phpunit.xml, and all worked!
I tried debugging the error, but even using xdebug's profiler I wasn't able to locate the origin of the error.
The PHPUnit test runner should be enhanced to read a list of previously failed tests from an XML logfile and run these tests before the other tests.
I put into some commented test cases.
Result is
..E..
Time: 1 second, Memory: 5.00Mb
There was 1 error:
<?php
class BlubException extends Exception
{
}
class ExpectedExceptionTest extends PHPUnit_Framework_TestCase
{
/**
* This works fine
*
* @expectedException BlubException
*/
public function testExpectedException()
{
throw new BlubException();
}
/**
* This works fine
*/
public function testExpectedMessageOldSchool()
{
try {
throw new BlubException("Haha");
$this->fail('Exception expected, but none thrown');
} catch (BlubException $e) {
$this->assertEquals('Haha', $e->getMessage());
}
}
/**
* This fails, because the exception is not caught, probably it should pass
*
* @expectedExceptionMessage Haha
*/
public function testExpectedMessage()
{
throw new BlubException("Haha");
}
/**
* This should fail, because the message is wrong, but it passes
* @expectedException BlubException
* @expectedExceptionMessage Haha
*/
public function testExpectedMessageWrongMessage()
{
throw new BlubException("Blublub");
}
/**
* This old school version should fail, according to several examples, but passes
* e.g. see PHP QA Book german version page 30
*/
public function testOldSchoolForGenericExceptionFailsButIsStillInSomeExamples()
{
try {
// do something that does not throw an exception, but was expected to
$this->fail('Exception expected, but none thrown');
} catch (Exception $e) {
// We end up here, because fail() throws an exception, nowadays.
$this->assertEquals('PHPUnit_Framework_AssertionFailedError', get_class($e));
}
}
}
When PHPUnit is given a file with no test methods, with private test methods, with no public constructor, etc., it creates a PHPUnit_Framework_Warning object and "runs" it. Since this object has $backupGlobals === NULL, "running" it results in all the globals being serialized and then unserialized. In our environment there are globals that cannot be serialized, so this behavior breaks things and causes subsequent tests in the same suite to fail. So there needs to be a way to turn this behavior off. My suggestion is to have this behavior always be off by adding
protected $backupGlobals = FALSE;
to the PHPUnit_Framework_Warning class.
For example:
phpunit bootstrap="not_existent_bootstrap.php">
.
gives out this error:
PHP Warning: include_once(/home/giorgio): failed to open stream: Nessun file o directory in /usr/share/php/PHPUnit/Util/Fileloader.php on line 103
Warning: include_once(/home/giorgio): failed to open stream: Nessun file o directory in /usr/share/php/PHPUnit/Util/Fileloader.php on line 103
PHP Warning: include_once(): Failed opening '' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /usr/share/php/PHPUnit/Util/Fileloader.php on line 103
Warning: include_once(): Failed opening '' for inclusion (include_path='.:/usr/share/php:/usr/share/pear') in /usr/share/php/PHPUnit/Util/Fileloader.php on line 103
which does not even contain the offending filename "not_existent_bootstrap.php". Sorry for the mangled code but this issue tracker does not let me post XML.
If a data provider function returns an emty array the results XML contains some XML elements about the skipped test (the test method that uses this data provider).
When defining a test method and using a @dataProvider annotation, but pointing to a non existing data provider function this should be create the same XML about the skipped test.
Because of the missing XML about the skipped test (second example above) i can not notice the skipped test in my IDE (netbeans).
PHPUnit 3.4.10
The generated junit log does not appear to be understood by cruisecontrol:
http://test.pear.php.net:8080/cruisecontrol/buildresults/HTML_Table?tab=buildResults
Relevant line:
Steps to reproduce:
clockwerx@sg1:~/cruisecontrol/projects/HTML_Table$ ant
Unable to locate tools.jar. Expected to find it in /usr/lib/jvm/java-6-sun-1.6.0.20/lib/tools.jar
Buildfile: build.xml
checkout:
[exec] At revision 302332.
(snip)
phpunit:
[exec] PHPUnit 3.4.10 by Sebastian Bergmann.
[exec]
[exec] ...............................
[exec]
[exec] Time: 6 seconds, Memory: 10.50Mb
[exec]
[exec] OK (31 tests, 0 assertions)
build:
BUILD SUCCESSFUL
Total time: 14 seconds
which generates
Compared to other packages:
I'm not sure if this is the right place, but:
After upgrading to 3.5 I couldn't find the new compmonts even though PEAR said they were installed like:
phpunit/PHPUnit_Selenium is already installed and is the same as the released version 1.0.0
I had to uninstall phpunit and all components seperatly. Then the phpunit installation would work properly. I had this phenomenon on by local MAC Enviroment php 5.3.1 and on a debian server running php 5.3.3.
TestResult
TestResult
just as a Collecting Parameter to collect test resultsTestSuiteIterator
to get all tests that are to be run from the top-level TestSuite
FilterIterator
implementations to filter tests based on --filter
, --group
, and --exclude-group
, for instance@depends
annotationsTestCase
objects and clean them up immediately after a test has been run
When mocking class Imagick of the pecl/imagick extension 3.0.0, mocking fails with the following error message:
Fatal error: Call to a member function verify() on a non-object in /usr/share/php/PHPUnit/Framework/MockObject/Generator.php(172) : eval()'d code on line 4358
The testcase is quite easy:
class test extends PHPUnit_Framework_TestCase
{
public function test()
{
$mock = $this->getMock('Imagick');
}
}
The server is running Ubunt 10.04 with PHP 5.3.2 from the Ubuntu repository, Imagick installed via pecl and PHPUnit installed from PEAR.
Basically, when using autoloading, the framework cannot have access to a certain class until it's autoloaded. Then, if the first test case stored something in the static scope, it will be available to all the subsequent tests cases and, if someone access the static scope, it can breaks a test with an unexpected behavior. It's an edge case.
I created some example files to show this: http://github.com/eriksencosta/phpunit-bsa-edge-case
Just run AllTests and see that the assertEquals calls fails. Then, uncommenting the 14th line from OneTest will cause the tests passes (or just checkouts the "pass" branch).
One solution I thought was to replace the registered autoloaders with rewrited copies that would call GlobalState::backupStaticAttributes() when the class was first loaded (something like what MockObject do when create the mock with a class skeleton).
For this, backupStaticAttributes could be refactored and a specific method would backup the static attributes of a newly loaded class. All the subsequent calls would behave as expected because as the class name would be returned in the get_declared_classes() call of GlobalState::backupStaticAttributes().
Maybe with the backupStaticAttributes = FALSE recommendation, this could be an unnecessary effort. But while the option exists, some people will eventually have problems with this, maybe thinking is misusing the option.
I've just installed 3.5.0RC2 using pear, on a Snow Leopard box using macports, and went on to test symfony2 using it. It'm getting a fatal error as I do:
DB:~/Sites/symfony $ phpunit
PHPUnit 3.5.0RC2 by Sebastian Bergmann.
............................................................ 60 / 1446
............................................................ 120 / 1446
............................................................ 180 / 1446
............................................................ 240 / 1446
............................................................ 300 / 1446
............................................................ 360 / 1446
............................................................ 420 / 1446
............................................................ 480 / 1446
..............PHP Fatal error: Class 'PHPUnit_Framework_MockObject_Generator' not found in /opt/local/PEAR/PHPUnit/Framework/TestCase.php on line 1049
Fatal error: Class 'PHPUnit_Framework_MockObject_Generator' not found in /opt/local/PEAR/PHPUnit/Framework/TestCase.php on line 1049
Checking the files in /opt/local/PEAR/PHPUnit reveals no class for declaration for the above -- even though it seems to gets used three times in the PHPUnit source code.
Am looking at the docs for release 3.5 and wondering what happened to BDD (used to be Chapter 14). Thanks
Version : PHPUnit 3.5
Platform : PHP 5.3.2-1ubuntu4.5 with Suhosin-Patch (cli) (built: Sep 17 2010 13:41:55)
I appreciate that an abstract class with no abstract methods may seem a little odd, we have such classes that we want to test through PHPUnit. This unit tests demonstrates what I mean.
<?php
abstract class HasAbstractMethod {
function foo() {}
abstract function bar();
}
abstract class HasNoAbstractMethods {
function foo() {}
}
class BugReport_getMockForAbstractClass_NoAbstractMethods extends PHPUnit_Framework_TestCase {
public function testCanUseGetMockForAbstractClassWhenClassHasAbstractMethods() {
$c = $this->getMockForAbstractClass('HasAbstractMethod');
}
public function testCanUseGetMockForAbstractClassWhenClassHasNoAbstractMethods() {
$c = $this->getMockForAbstractClass('HasNoAbstractMethods');
// this test fails:
//Argument 2 passed to PHPUnit_Framework_MockObject_Generator::generateMock() must be an array, null given, called in /usr/share/php/PHPUnit/Framework/MockObject/Generator.php on line 283
}
}
Would be a fairly straightforward mix - just to pass in a blank array rather than null in Generator.php:
230c230
< $methods = array();
---
> $methods = NULL;
phpunit --log-junit build/logs/phpunit.xml --coverage-clover build/logs/clover.xml --coverage-html build/coverage --configuration tests/phpunit.xml tests/
this results in Writing code coverage data to XML file, this may take a moment.Command '--log-junit' is not valid, try ' help'
version 3.5.0
If any @Covers annotation specifies an invalid class, method, function, etc. the tests stop due to an uncaught RuntimeException. While this relates to code coverage, the fix belongs in PHPUnit itself.
To turn this into a test error, replace this line in PHPUnit_Framework_TestResult::run():
$this->codeCoverage->append($data, $test, $filterGroups);
with this block:
try {
$this->codeCoverage->append($data, $test, $filterGroups);
} catch (Exception $cce) {
// @todo Create specific CC exception?
$error = TRUE;
if (!isset($e)) {
$e = $cce;
}
}
I have a test case that uses a database TestCase extension, and it appears that the code is somehow timing-dependent. If I run queries in an ordinary test method, it sometimes sees the inserted data and sometimes an empty database. If I add a usleep(1000) to the beginning of my method, it seems to work OK. The DB is MySQL, and this seems to be limited to MyISAM tables (changing the table type to InnoDB appeared to resolve it).
I'm using PHPUnit v3.4.5, is this something that might have been fixed by a later version?
Affected version 3.5.
If assertType() assertion is used with autoloader, autoloader tries to load asserted type as php file. For example with Zend Framework autoloader enabled, calling assertType('array', array()) results in error include_once(array.php): failed to open stream: No such file or directory.
This could be fixed by setting parameter $autoload=false to functions class_exists() and interface_exists() in PHPUnit_Util_Type::isType().
I can't open a ticket on phpunit.de so I have to do it here, not know if this is the right place.
In PHPUnit 3.4.15, this test case:
getMock('DummyInterfaceWithoutMethods'); $mock->expects($this->any()) ->method('doesNotExist') ->will($this->returnValue('foo')); } } interface DummyInterfaceWithoutMethods {}
does not fail. If an error were raise, it will be simple to find mystakes and typos in method names.
PHPUnit requires DbUnit, PHPUnit_MockObject, and PHPUnit_Selenium in its package.xml. The latter three require PHPUnit in their package.xml. While this may work for PEAR based packaging I'm pretty certain that won't work out for downstream distributions. Is this an oversight? I guess downstream could also bundle the four packages together instead of splitting them but then I don't know why one would split these upstream.
Currently, when two tests B and C depend on the same test A, the same result from A will be passed to both B and C. In the future it should also be possible to rerun A to provide the result for B and C as well as performing a clone
or deep-copy operation on the result that is returned from A.
I've suddenly started running into maximum execution time errors when running my tests in bulk (i.e. on an entire directory, rather than test by test). The errors always occur somewhere in DataSet/FlatXmlDataSet.php or DataSet/AbstractTable.php, e.g. "
Fatal error: Maximum execution time of 10 seconds exceeded in /usr/local/share/pear/PEAR/PHPUnit/Extensions/Database/DataSet/FlatXmlDataSet.php on line 90".
I have tried setting max_execution_time and max_input_time to 0 in my php.ini, and have also tried setting them using the -d parameter to phpunit (e.g. phpunit -d max_input_time=0), but it does not have any affect.
When running the tests one by one, the problem does not occur.
The maximum execution time that it claims is always 10 seconds.
Version information
With --process-isolation setUpBeforeClass()
is not run before tests, but instead for each test.
<?php
require 'PHPUnit/Framework/TestCase.php';
class FooTest extends PHPUnit_Framework_TestCase
{
static function setUpBeforeClass()
{
echo "setUpBeforeClass, pid=" . getmypid() . "\n";
}
function testA()
{
echo "testA, pid=" . getmypid() . "\n";
$this->assertTrue(TRUE);
}
function testB()
{
echo "testB, pid=" . getmypid() . "\n";
$this->assertTrue(TRUE);
}
}
Expected output:
PHPUnit 3.5.0RC1 by Sebastian Bergmann.
setUpBeforeClass, pid=23871
testA, pid=23872
.testB, pid=23873
.
Time: 0 seconds, Memory: 3.50Mb
OK (2 tests, 2 assertions)
Actual output:
PHPUnit 3.5.0RC1 by Sebastian Bergmann.
setUpBeforeClass, pid=23882
setUpBeforeClass, pid=23883
testA, pid=23883
.setUpBeforeClass, pid=23884
testB, pid=23884
.
Time: 1 second, Memory: 3.50Mb
OK (2 tests, 2 assertions)
I was stumped for about an hour trying to figure out why I was getting a cryptic error message when I put two test files in a folder and tried to run phpunit against the folder. See my stackoverflow question here:
I scoured the documentation but found nothing about this, and just tried it based on hunch (after observing all files were named somethingTest.php.
Perhaps there is a way to make it clear that at least by default, filenames should end with Test.php for them to get picked up by the test runner?
@small
, @medium
and @large
as aliases for @group small
, @group medium
and @group large
@depend
a test that is larger than itself@covers
annotation to declare the component-under-test.I'm running 3.4.15 (from pear). I have a test that segfaults. My colleague tested this on Mac and it works there. This is the test.
$search = $this->getMockFromWsdl(
'http://www.mondialrelay.fr/webservice/Web_Services.asmx?WSDL',
'WSI2_RecherchePointRelais'
);
I made it dump core, you can find the backtrace below. Please, let me know if you need anything else.
GNU gdb (GDB) 7.1-ubuntu
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later http://gnu.org/licenses/gpl.html
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
For bug reporting instructions, please see:
http://www.gnu.org/software/gdb/bugs/...
Reading symbols from /usr/bin/php...(no debugging symbols found)...done.
warning: core file may not match specified executable file.
[New Thread 10918]
warning: Can't read pathname for load map: Input/output error.
Reading symbols from /lib/libcrypt.so.1...Reading symbols from /usr/lib/debug/lib/libcrypt-2.11.1.so...done.
done.
Loaded symbols for /lib/libcrypt.so.1
Reading symbols from /lib/libz.so.1...(no debugging symbols found)...done.
Loaded symbols for /lib/libz.so.1
Reading symbols from /usr/lib/libedit.so.2...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/libedit.so.2
Reading symbols from /lib/libncurses.so.5...(no debugging symbols found)...done.
Loaded symbols for /lib/libncurses.so.5
Reading symbols from /lib/libssl.so.0.9.8...(no debugging symbols found)...done.
Loaded symbols for /lib/libssl.so.0.9.8
Reading symbols from /usr/lib/libdb-4.8.so...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/libdb-4.8.so
Reading symbols from /lib/libbz2.so.1.0...(no debugging symbols found)...done.
Loaded symbols for /lib/libbz2.so.1.0
Reading symbols from /lib/libpcre.so.3...(no debugging symbols found)...done.
Loaded symbols for /lib/libpcre.so.3
Reading symbols from /lib/librt.so.1...Reading symbols from /usr/lib/debug/lib/librt-2.11.1.so...done.
done.
Loaded symbols for /lib/librt.so.1
Reading symbols from /lib/libm.so.6...Reading symbols from /usr/lib/debug/lib/libm-2.11.1.so...done.
done.
Loaded symbols for /lib/libm.so.6
Reading symbols from /lib/libdl.so.2...Reading symbols from /usr/lib/debug/lib/libdl-2.11.1.so...done.
done.
Loaded symbols for /lib/libdl.so.2
Reading symbols from /lib/libnsl.so.1...Reading symbols from /usr/lib/debug/lib/libnsl-2.11.1.so...done.
done.
Loaded symbols for /lib/libnsl.so.1
Reading symbols from /usr/lib/libgssapi_krb5.so.2...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/libgssapi_krb5.so.2
Reading symbols from /usr/lib/libkrb5.so.3...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/libkrb5.so.3
Reading symbols from /usr/lib/libk5crypto.so.3...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/libk5crypto.so.3
Reading symbols from /lib/libcom_err.so.2...(no debugging symbols found)...done.
Loaded symbols for /lib/libcom_err.so.2
Reading symbols from /usr/lib/libxml2.so.2...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/libxml2.so.2
Reading symbols from /lib/libc.so.6...Reading symbols from /usr/lib/debug/lib/libc-2.11.1.so...done.
done.
Loaded symbols for /lib/libc.so.6
Reading symbols from /lib/libcrypto.so.0.9.8...(no debugging symbols found)...done.
Loaded symbols for /lib/libcrypto.so.0.9.8
Reading symbols from /lib/libresolv.so.2...Reading symbols from /usr/lib/debug/lib/libresolv-2.11.1.so...done.
done.
Loaded symbols for /lib/libresolv.so.2
Reading symbols from /lib/libbsd.so.0...(no debugging symbols found)...done.
Loaded symbols for /lib/libbsd.so.0
Reading symbols from /lib/libpthread.so.0...Reading symbols from /usr/lib/debug/lib/libpthread-2.11.1.so...done.
done.
Loaded symbols for /lib/libpthread.so.0
Reading symbols from /lib64/ld-linux-x86-64.so.2...Reading symbols from /usr/lib/debug/lib/ld-2.11.1.so...done.
done.
Loaded symbols for /lib64/ld-linux-x86-64.so.2
Reading symbols from /usr/lib/libkrb5support.so.0...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/libkrb5support.so.0
Reading symbols from /lib/libkeyutils.so.1...(no debugging symbols found)...done.
Loaded symbols for /lib/libkeyutils.so.1
Reading symbols from /usr/lib/php5/20090626/xdebug.so...done.
Loaded symbols for /usr/lib/php5/20090626/xdebug.so
Reading symbols from /usr/lib/php5/20090626/apc.so...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/php5/20090626/apc.so
Reading symbols from /usr/lib/php5/20090626/curl.so...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/php5/20090626/curl.so
Reading symbols from /usr/lib/libcurl.so.4...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/libcurl.so.4
Reading symbols from /usr/lib/libidn.so.11...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/libidn.so.11
Reading symbols from /usr/lib/liblber-2.4.so.2...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/liblber-2.4.so.2
Reading symbols from /usr/lib/libldap_r-2.4.so.2...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/libldap_r-2.4.so.2
Reading symbols from /usr/lib/libsasl2.so.2...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/libsasl2.so.2
Reading symbols from /usr/lib/libgnutls.so.26...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/libgnutls.so.26
Reading symbols from /usr/lib/libtasn1.so.3...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/libtasn1.so.3
Reading symbols from /lib/libgcrypt.so.11...(no debugging symbols found)...done.
Loaded symbols for /lib/libgcrypt.so.11
Reading symbols from /lib/libgpg-error.so.0...(no debugging symbols found)...done.
Loaded symbols for /lib/libgpg-error.so.0
Reading symbols from /usr/lib/php5/20090626/gd.so...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/php5/20090626/gd.so
Reading symbols from /usr/lib/libgd.so.2...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/libgd.so.2
Reading symbols from /usr/lib/libt1.so.5...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/libt1.so.5
Reading symbols from /usr/lib/libfreetype.so.6...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/libfreetype.so.6
Reading symbols from /usr/lib/libX11.so.6...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/libX11.so.6
Reading symbols from /usr/lib/libXpm.so.4...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/libXpm.so.4
Reading symbols from /lib/libpng12.so.0...(no debugging symbols found)...done.
Loaded symbols for /lib/libpng12.so.0
Reading symbols from /usr/lib/libjpeg.so.62...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/libjpeg.so.62
Reading symbols from /usr/lib/libfontconfig.so.1...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/libfontconfig.so.1
Reading symbols from /usr/lib/libxcb.so.1...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/libxcb.so.1
Reading symbols from /lib/libexpat.so.1...(no debugging symbols found)...done.
Loaded symbols for /lib/libexpat.so.1
Reading symbols from /usr/lib/libXau.so.6...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/libXau.so.6
Reading symbols from /usr/lib/libXdmcp.so.6...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/libXdmcp.so.6
Reading symbols from /usr/lib/php5/20090626/memcache.so...done.
Loaded symbols for /usr/lib/php5/20090626/memcache.so
Reading symbols from /usr/lib/php5/20090626/memcached.so...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/php5/20090626/memcached.so
Reading symbols from /usr/lib/libmemcached.so.2...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/libmemcached.so.2
Reading symbols from /usr/lib/php5/20090626/mysql.so...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/php5/20090626/mysql.so
Reading symbols from /usr/lib/libmysqlclient_r.so.16...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/libmysqlclient_r.so.16
Reading symbols from /usr/lib/php5/20090626/mysqli.so...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/php5/20090626/mysqli.so
Reading symbols from /usr/lib/php5/20090626/pdo.so...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/php5/20090626/pdo.so
Reading symbols from /usr/lib/php5/20090626/pdo_mysql.so...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/php5/20090626/pdo_mysql.so
Reading symbols from /usr/lib/php5/20090626/pdo_sqlite.so...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/php5/20090626/pdo_sqlite.so
Reading symbols from /usr/lib/libsqlite3.so.0...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/libsqlite3.so.0
Reading symbols from /usr/lib/php5/20090626/redis.so...done.
Loaded symbols for /usr/lib/php5/20090626/redis.so
Reading symbols from /usr/lib/php5/20090626/sqlite.so...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/php5/20090626/sqlite.so
Reading symbols from /usr/lib/libsqlite.so.0...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/libsqlite.so.0
Reading symbols from /usr/lib/php5/20090626/sqlite3.so...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/php5/20090626/sqlite3.so
Reading symbols from /usr/lib/php5/20090626/thrift_protocol.so...done.
Loaded symbols for /usr/lib/php5/20090626/thrift_protocol.so
Reading symbols from /usr/lib/libstdc++.so.6...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/libstdc++.so.6
Reading symbols from /lib/libgcc_s.so.1...(no debugging symbols found)...done.
Loaded symbols for /lib/libgcc_s.so.1
Reading symbols from /usr/lib/php5/20090626/xsl.so...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/php5/20090626/xsl.so
Reading symbols from /usr/lib/libexslt.so.0...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/libexslt.so.0
Reading symbols from /usr/lib/libxslt.so.1...(no debugging symbols found)...done.
Loaded symbols for /usr/lib/libxslt.so.1
Reading symbols from /lib/libnss_files.so.2...Reading symbols from /usr/lib/debug/lib/libnss_files-2.11.1.so...done.
done.
Loaded symbols for /lib/libnss_files.so.2
Reading symbols from /lib/libnss_compat.so.2...Reading symbols from /usr/lib/debug/lib/libnss_compat-2.11.1.so...done.
done.
Loaded symbols for /lib/libnss_compat.so.2
Reading symbols from /lib/libnss_nis.so.2...Reading symbols from /usr/lib/debug/lib/libnss_nis-2.11.1.so...done.
done.
Loaded symbols for /lib/libnss_nis.so.2
Core was generated by `/usr/bin/php /usr/bin/phpunit library/PC/PickupPoint/FactoryTest.php'.
Program terminated with signal 11, Segmentation fault.
#0 __strlen_sse2 () at ../sysdeps/x86_64/multiarch/../strlen.S:31
31 ../sysdeps/x86_64/multiarch/../strlen.S: No such file or directory.
in ../sysdeps/x86_64/multiarch/../strlen.S
(gdb) bt
#0 __strlen_sse2 () at ../sysdeps/x86_64/multiarch/../strlen.S:31
#1 0x00000000005f9e59 in php_addcslashes ()
#2 0x00007fac1991dacb in xdebug_var_export (struc=0x7fffda7cbfe8, str=0x7fffda7cbff0, level=1, debug_zval=0, options=0x373b5b0)
at /build/buildd/xdebug-2.0.5/build-php5/xdebug_var.c:283
#3 0x00007fac1991df8e in xdebug_get_zval_value (val=0x34960f8, debug_zval=0, options=0x373b5b0) at /build/buildd/xdebug-2.0.5/build-php5/xdebug_var.c:365
#4 0x00007fac1990327e in add_stack_frame (zdata=0x7fac1d507358, op_array=0x2be4228, type=2) at /build/buildd/xdebug-2.0.5/build-php5/xdebug.c:1081
#5 0x00007fac19904984 in xdebug_execute (op_array=0x2be4228) at /build/buildd/xdebug-2.0.5/build-php5/xdebug.c:1512
#6 0x00000000006d165c in ?? ()
#7 0x00000000006bd400 in execute ()
#8 0x00007fac19904b9e in xdebug_execute (op_array=0x34656a0) at /build/buildd/xdebug-2.0.5/build-php5/xdebug.c:1562
#9 0x00000000006e5c26 in ?? ()
#10 0x00000000006bd400 in execute ()
#11 0x00007fac19904b9e in xdebug_execute (op_array=0x345d368) at /build/buildd/xdebug-2.0.5/build-php5/xdebug.c:1562
#12 0x000000000068b324 in zend_call_function ()
#13 0x0000000000540c24 in ?? ()
#14 0x00007fac19904f2a in xdebug_execute_internal (current_execute_data=0x7fac1d506678, return_value_used=1) at /build/buildd/xdebug-2.0.5/build-php5/xdebug.c:1631
#15 0x00000000006e5f36 in ?? ()
#16 0x00000000006bd400 in execute ()
#17 0x00007fac19904b9e in xdebug_execute (op_array=0x3463a50) at /build/buildd/xdebug-2.0.5/build-php5/xdebug.c:1562
#18 0x00000000006e5c26 in ?? ()
#19 0x00000000006bd400 in execute ()
#20 0x00007fac19904b9e in xdebug_execute (op_array=0x34638b8) at /build/buildd/xdebug-2.0.5/build-php5/xdebug.c:1562
#21 0x00000000006e5c26 in ?? ()
#22 0x00000000006bd400 in execute ()
#23 0x00007fac19904b9e in xdebug_execute (op_array=0x2d97620) at /build/buildd/xdebug-2.0.5/build-php5/xdebug.c:1562
#24 0x00000000006e5c26 in ?? ()
#25 0x00000000006bd400 in execute ()
#26 0x00007fac19904b9e in xdebug_execute (op_array=0x34635f0) at /build/buildd/xdebug-2.0.5/build-php5/xdebug.c:1562
#27 0x00000000006e5c26 in ?? ()
#28 0x00000000006bd400 in execute ()
#29 0x00007fac19904b9e in xdebug_execute (op_array=0x2fb83e8) at /build/buildd/xdebug-2.0.5/build-php5/xdebug.c:1562
#30 0x00000000006e5c26 in ?? ()
#31 0x00000000006bd400 in execute ()
#32 0x00007fac19904b9e in xdebug_execute (op_array=0x2fac790) at /build/buildd/xdebug-2.0.5/build-php5/xdebug.c:1562
#33 0x00000000006e5c26 in ?? ()
#34 0x00000000006bd400 in execute ()
#35 0x00007fac19904b9e in xdebug_execute (op_array=0x2c363a8) at /build/buildd/xdebug-2.0.5/build-php5/xdebug.c:1562
#36 0x00000000006e5c26 in ?? ()
#37 0x00000000006bd400 in execute ()
#38 0x00007fac19904b9e in xdebug_execute (op_array=0x2c21c80) at /build/buildd/xdebug-2.0.5/build-php5/xdebug.c:1562
#39 0x00000000006e5c26 in ?? ()
#40 0x00000000006bd400 in execute ()
#41 0x00007fac19904b9e in xdebug_execute (op_array=0x2c112e0) at /build/buildd/xdebug-2.0.5/build-php5/xdebug.c:1562
#42 0x00000000006e5c26 in ?? ()
#43 0x00000000006bd400 in execute ()
#44 0x00007fac19904b9e in xdebug_execute (op_array=0x2be1438) at /build/buildd/xdebug-2.0.5/build-php5/xdebug.c:1562
#45 0x000000000069512d in zend_execute_scripts ()
---Type to continue, or q to quit---
#46 0x0000000000640d98 in php_execute_script ()
#47 0x0000000000726236 in ?? ()
#48 0x00007fac1a92cc4d in __libc_start_main (main=, argc=, ubp_av=, init=,
fini=<value optimized out>, rtld_fini=<value optimized out>, stack_end=0x7fffda7d0888) at libc-start.c:226
#49 0x000000000042c639 in _start ()
(gdb)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.