Skip to content

Method assertSame doesn't create ComparisonFailure for arrays #2169

Closed
@SvetlanaZem

Description

@SvetlanaZem
<?php
class CompareTest extends PHPUnit_Framework_TestCase
{
    public function testSame()
    {
        $this->assertSame(array('one'), array('two'));
    }

    public function testEquals()
    {
        $this->assertEquals(array('one'), array('two'));
    }
}

Method $this->assertSame(array('one'), array('two')); will throw PHPUnit_Framework_ExpectationFailedException with ComparisonFailure equals to null while method $this->assertEquals(...) will create proper ComparisonFailure object.

$this->assertSame(...) uses PHPUnit_Framework_Constraint_IsIdentical.evaluate(...)
$this->assertEquals(...) uses PHPUnit_Framework_Constraint_IsEqual.evaluate(...)

The issue was reproduced with PHPUnit 5.3

Corresponding PhpStorm issue: https://youtrack.jetbrains.com/issue/WI-31705

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions