New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure that assertSame generates diff for arrays #2976

Merged
merged 1 commit into from Jan 27, 2018

Conversation

2 participants
@mhujer
Contributor

mhujer commented Jan 27, 2018

Fixes #2169.

With this patch, the arrays are diffed for assertSame() similarly to assertEquals():

<?php declare(strict_types = 1);

use PHPUnit\Framework\TestCase;

class ArrayDiffTest extends TestCase
{
	public function testEquality()
	{
		$this->assertEquals(
			[1, 2, 3, 4, 5, 6],
			[1, 2, 33, 4, 5, 6]
		);
	}

	public function testSame()
	{
		$this->assertSame(
			[1, 2, 3, 4, 5, 6],
			[1, 2, 33, 4, 5, 6]
		);
	}
1) ArrayDiffTest::testEquality
Failed asserting that two arrays are equal.
--- Expected
+++ Actual
@@ @@
 Array (
     0 => 1
     1 => 2
-    2 => 3
+    2 => 33


2) ArrayDiffTest::testSame
Failed asserting that two arrays are identical.
--- Expected
+++ Actual
@@ @@
 Array &0 (
     0 => 1
     1 => 2
-    2 => 3
+    2 => 33

I also tested it with PHPStorm and it fixes the diffing issue there as well:

image

Questions:

  1. is this a correct approach?
  2. Wouldn't is be better to merge it to 6.5 branch?
@mhujer

This comment has been minimized.

Contributor

mhujer commented Jan 27, 2018

Appveyor failure seems unrelated. It is caused by http://windows.php.net/downloads/releases/php-7.2.0-Win32-VC15-x86.zip not being available (7.2.1 is available, so probably the version number should be incremented in AppVeyor config).

EDIT: See #2977

@sebastianbergmann sebastianbergmann merged commit 25b2df6 into sebastianbergmann:master Jan 27, 2018

2 of 3 checks passed

continuous-integration/appveyor/pr AppVeyor build failed
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
stickler-ci No lint errors found.

@mhujer mhujer deleted the mhujer:mh-fix-2169 branch Jan 27, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment