Skip to content

add assertSameSize() to assertions.rst #245

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

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions src/assertions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2715,6 +2715,49 @@ Reports an error identified by ``$message`` if the two variables ``$expected`` a
FAILURES!
Tests: 1, Assertions: 1, Failures: 1.

assertSameSize()
######################

``assertSameSize($expected, $actual, string $message = '')``

Reports an error identified by ``$message`` if the sizes of ``$actual`` and ``$expected`` are not the same.

``assertNotSameSize()`` is the inverse of this assertion and takes the same arguments.

.. code-block:: php
:caption: Usage of assertSameSize()
:name: appendixes.assertions.assertSameSize.example

<?php declare(strict_types=1);
use PHPUnit\Framework\TestCase;

final class SameSizeTest extends TestCase
{
public function testFailure(): void
{
$this->assertSameSize([1, 2], [1]);
}
}

.. parsed-literal::

$ phpunit StringEndsWithTest
PHPUnit |version|.0 by Sebastian Bergmann and contributors.

F

Time: 0 second, Memory: 4.00Mb

There was 1 failure:

1) SameSizeTest::testFailure
Failed asserting that actual size 1 matches expected size 2.

/home/sb/SameSizeTest.php:8

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

.. _appendixes.assertions.assertStringEndsWith:

assertStringEndsWith()
Expand Down