2

PHPUnit runs regular tests without trouble, but it mistakenly reports this basic PHPT example as failing when it should pass:

--TEST--
strtr() function - basic test for strstr()
--FILE--
<?php
/* Do not change this test it is a README.TESTING example. */
$trans = array("hello"=>"hi", "hi"=>"hello", "a"=>"A", "world"=>"planet");
var_dump(strtr("# hi all, I said hello world! #", $trans));
?>
--EXPECT--
string(32) "# hello All, I sAid hi planet! #"

Running this with phpunit basic-format.phpt gives

There was 1 failure:

1) basic-format.php
--- Expeccted
+++ Actual
@@ @@
- # hello All, I sAid hi planet! #
+

I'm using Windows / PHP 5.4.6. The test works fine with PHP 5.4.0, but I'm unable to determine any discrepancy other than php version.

David Harkness
  • 35,992
  • 10
  • 112
  • 134
Brad Kent
  • 4,982
  • 3
  • 22
  • 26
  • That's because .phpt files aren't phpunit test files - they are for PHP's internal testing utility – Mark Baker Aug 21 '12 at 16:04
  • how does one run a .phpt test ? I know it works just fine on one installation of I have of PHP/PHPUnit here's one thread: http://stackoverflow.com/questions/4922207/docs-examples-on-how-to-use-phpt-test-cases-with-phpunit – Brad Kent Aug 22 '12 at 00:16
  • So what does your phpunit test script look like? Or what do you get if you execute php's run-tests against that phpt file? – Mark Baker Aug 22 '12 at 00:41
  • `C:\php\tests\path\tests>phpunit AllTests.php PHPUnit 3.6.12 by Sebastian Bergmann. Time: 0 seconds, Memory: 3.75Mb There was 1 failure: 1) C:\php\tests\path\tests\basic.phpt --- Expected +++ Actual @@ @@ -string(32) "# hello All, I sAid hi planet! #" + C:\php\phpunit:46 FAILURES! Tests: 82, Assertions: 153, Failures: 1.` sorry, not sure how to format my comment nutshell all the tests work, sans .phpt – Brad Kent Aug 22 '12 at 01:39
  • sorry... now I see you're referring to "php's run-tests" is this an executable, php command line switch, .php file, other how do I install or learn more? – Brad Kent Aug 22 '12 at 01:55
  • C:\php\tests\path\tests>pear run-tests / Running 1 tests / PASS strtr() function - basic test for strstr()[basic.phpt] / TOTAL TIME: 00:00 / 1 PASSED TESTS / 0 SKIPPED TESTS – Brad Kent Aug 22 '12 at 01:59
  • I assume the php 5.4.0, where it works, is also Windows? Can you post a _diff_ of the output from `phpinfo` on the two installs? (On linux you can do that with a one-liner, see http://darrendev.blogspot.com/2010/11/bash-tips-meld-on-program-output.html ; for Windows it most likely requires a bit of copy-and-paste into an online diff tool ) – Darren Cook Aug 22 '12 at 03:15
  • 1
    @MarkBaker phpunit is able to execute .phpt test cases. They are used internally for it's own regression test suite for example. – edorian Aug 27 '12 at 12:27
  • What happens when you run the test using PEAR? `pear run-tests basic-format.phpt` – David Harkness Sep 06 '12 at 18:41

0 Answers0