Skip to content

Commit 933801a

Browse files
pluchtsebastianbergmann
authored andcommitted
add assertSameSize() to assertions.rst
This resolves #241.
1 parent d8e50c2 commit 933801a

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

src/assertions.rst

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2783,6 +2783,49 @@ Reports an error identified by ``$message`` if the two variables ``$expected`` a
27832783
FAILURES!
27842784
Tests: 1, Assertions: 1, Failures: 1.
27852785
2786+
assertSameSize()
2787+
######################
2788+
2789+
``assertSameSize($expected, $actual, string $message = '')``
2790+
2791+
Reports an error identified by ``$message`` if the size of ``$actual`` and ``$expected`` is not the same.
2792+
2793+
``assertNotSameSize()`` is the inverse of this assertion and takes the same arguments.
2794+
2795+
.. code-block:: php
2796+
:caption: Usage of assertSameSize()
2797+
:name: appendixes.assertions.assertSameSize.example
2798+
2799+
<?php declare(strict_types=1);
2800+
use PHPUnit\Framework\TestCase;
2801+
2802+
final class SameSizeTest extends TestCase
2803+
{
2804+
public function testFailure(): void
2805+
{
2806+
$this->assertSameSize([1, 2], [1]);
2807+
}
2808+
}
2809+
2810+
.. parsed-literal::
2811+
2812+
$ phpunit StringEndsWithTest
2813+
PHPUnit |version|.0 by Sebastian Bergmann and contributors.
2814+
2815+
F
2816+
2817+
Time: 0 second, Memory: 4.00Mb
2818+
2819+
There was 1 failure:
2820+
2821+
1) SameSizeTest::testFailure
2822+
Failed asserting that actual size 1 matches expected size 2.
2823+
2824+
/home/sb/SameSizeTest.php:8
2825+
2826+
FAILURES!
2827+
Tests: 1, Assertions: 1, Failures: 1.
2828+
27862829
.. _appendixes.assertions.assertStringEndsWith:
27872830

27882831
assertStringEndsWith()

0 commit comments

Comments
 (0)