I'm using PHPUnit 3.7.10 via CakePHP v2.3 and I run the following:
$this->assertEquals(array('a', 'b', 'c'), array('a', 'c', 'd'));
And all I get is:
Failed asserting that two arrays are equal.
Why do I not get the diff below as outlined here? http://www.phpunit.de/manual/current/en/writing-tests-for-phpunit.html#writing-tests-for-phpunit.assertions.assertEquals.example5
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
Array (
0 => 'a'
- 1 => 'b'
- 2 => 'c'
+ 1 => 'c'
+ 2 => 'd'
)
What am I missing?
Update. Test file called via test.php?case=Cache/Engine/PhpUnit&debug=1
<?php
class PhpUnitTest extends CakeTestCase {
public function testDiff() {
$this->assertEquals(array('a', 'b', 'c'), array('a', 'c', 'd'));
}
}
This was a regression bug in CakePHP 2.3. Fixed in https://github.com/cakephp/cakephp/commit/659715664d648d9a599002b5a7c3b55505efdcde
For ref here was the ticked I opened: http://cakephp.lighthouseapp.com/projects/42648/tickets/3503-23-suppresses-phpunit-diff-output
Works for me:
<?php
class SoTest extends PHPUnit_Framework_TestCase
{
public function testIt()
{
$this->assertEquals(array('a', 'b', 'c'), array('a', 'c', 'd'));
}
}
?>
Output:
$ phpunit SoTest.php
PHPUnit 3.7.10 by Sebastian Bergmann.
F
Time: 0 seconds, Memory: 3.00Mb
There was 1 failure:
1) SoTest::testIt
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
Array (
0 => 'a'
- 1 => 'b'
- 2 => 'c'
+ 1 => 'c'
+ 2 => 'd'
)
/home/cweiske/SoTest.php:6
FAILURES!
Tests: 1, Assertions: 1, Failures: 1.
You are running the unit tests on the browser. You will see the expected result when you run it on the CLI with --debug
modifier. You can also try adding &debug=1
at the end of the url when using the web browser to run the tests but that has not worked many times for me.