sebastianbergmann / dbunit

DbUnit port for PHP/PHPUnit.
https://phpunit.de/
Other
225 stars 186 forks source link

Empty tables are not displayed correctly #195

Closed sebastianbergmann closed 6 years ago

sebastianbergmann commented 6 years ago
<?php
use PHPUnit\Framework\TestCase;
use PHPUnit\DbUnit\TestCaseTrait;
use PHPUnit\DbUnit\DataSet\ArrayDataSet;

class Test extends TestCase
{
    use TestCaseTrait;

    public function getConnection()
    {
        $pdo = new PDO('sqlite::memory:');

        return $this->createDefaultDBConnection($pdo, ':memory:');
    }

    public function getDataSet()
    {
        return new ArrayDataSet([]);
    }

    public function testOne()
    {
        $this->assertDataSetsEqual(
            new ArrayDataSet(
                [
                    'empty_table' => [
                    ],
                    'not_empty_table' => [
                        ['foo' => 'bar']
                    ]
                ]
            ),
            new ArrayDataSet(
                [
                    'empty_table' => [
                    ],
                    'not_empty_table' => [
                        ['foo' => 'baz']
                    ]
                ]
            )
        );
    }
}

Actual Result

PHPUnit 6.4.3 by Sebastian Bergmann and contributors.

F                                                                   1 / 1 (100%)

Time: 33 ms, Memory: 4.00MB

There was 1 failure:

1) Test::testOne
Failed asserting that 
+
| empty_table |
+
|
+

+----------------------+
| not_empty_table      |
+----------------------+
|         foo          |
+----------------------+
|         baz          |
+----------------------+

 is equal to expected 
+
| empty_table |
+
|
+

(table diff enabled)
+----------------------+
| not_empty_table      |
+----------------------+
|         foo          |
+----------------------+
| 'bar' != actual 'baz |
+----------------------+

.

/home/sb/Test.php:36

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

Expected Result

PHPUnit 6.4.3 by Sebastian Bergmann and contributors.

F                                                                   1 / 1 (100%)

Time: 33 ms, Memory: 4.00MB

There was 1 failure:

1) Test::testOne
Failed asserting that 
+-------------+
| empty_table |
+-------------+

+----------------------+
| not_empty_table      |
+----------------------+
|         foo          |
+----------------------+
|         baz          |
+----------------------+

 is equal to expected 

+-------------+
| empty_table |
+-------------+

(table diff enabled)
+----------------------+
| not_empty_table      |
+----------------------+
|         foo          |
+----------------------+
| 'bar' != actual 'baz |
+----------------------+

.

/home/sb/Test.php:36

FAILURES!
Tests: 1, Assertions: 1, Failures: 1.
D4rkMindz commented 6 years ago

@sebastianbergmann shouldn't this issue be closed?

sebastianbergmann commented 6 years ago

Of course! Thanks.