Skip to content

assertArraySubset with $strict=true doesn't display differences properlyΒ #3234

Closed
elecena/nano
#2
@crhg

Description

@crhg
Q A
PHPUnit version 7.2.7
PHP version 7.2.5
Installation Method Composer

The following test will fail but no differences will be displayed.

<?php
use PHPUnit\Framework\TestCase;

class FooTest extends TestCase
{
    public function testFoo()
    {
        $this->assertArraySubset(['foo' => 1], ['foo' => '1'], true);
    }
}
% ./vendor/bin/phpunit FooTest.php
PHPUnit 7.2.7 by Sebastian Bergmann and contributors.

F                                                                   1 / 1 (100%)

Time: 28 ms, Memory: 4.00MB

There was 1 failure:

1) FooTest::testFoo
Failed asserting that an array has the subset Array &0 (
    'foo' => 1
).
--- Expected
+++ Actual

/Users/matsui/src.nobk/phpunit-test/FooTest.php:8

FAILURES!
Tests: 1, Assertions: 1, Failures: 1.

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