Skip to content

Commit 3e98ef1

Browse files
committed
docs(blog): note the argument order switch in the Assert and Expect post
The post tells the history of choosing PHPUnit's order, so its prose stays; the note and the corrected instanceOf() example keep readers from copying the old order. Assisted-By: Claude Opus 5.5 <noreply@anthropic.com>
1 parent c39d76e commit 3e98ef1

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

‎blog/assert-and-expect.md‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ Sure, we could eventually create a hundred functions, a trait, and a base class
5757

5858
I decided to start like the [webmozarts/assert](https://github.com/webmozarts/assert) library: since we no longer need to write `self::` or `$this->`, let's keep it simple: `Assert::same()`. I chose the familiar PHPUnit parameter order: **$expected** first, then **$actual** (webmozart puts the value being checked first, then the expected value, which actually **looks more logical**).
5959

60+
::: info
61+
Testo later switched to the direct order: <func>\Testo\Assert::same()</func> now takes the value being checked first and the expected one second.
62+
:::
63+
6064
Off we went. Made `::same()`, `::notSame`, `::null()`, `::true()`, `::false()`, `::equals()`, `::notEquals()`.
6165

6266
Then we got to `Assert::greaterThan()`. In PHPUnit, the argument order is the same: **$expected** first, then **$actual**.
@@ -137,7 +141,7 @@ So we made several of these pipe assertions.
137141
#[Test]
138142
public function checkIterableTraitMethods(): void
139143
{
140-
Assert::instanceOf(\DateTimeInterface::class, new \DateTimeImmutable());
144+
Assert::instanceOf(new \DateTimeImmutable(), \DateTimeInterface::class);
141145
// Shorthand for Assert::object($object)->instanceOf($class);
142146

143147
Assert::int(15)->greaterThan(10);

‎ru/blog/assert-and-expect.md‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ function simpleTest(): void
5656

5757
Я решил начать как в библиотеке [webmozarts/assert](https://github.com/webmozarts/assert): раз нам больше не нужно писать `self::` или `$this->`, будем проще: `Assert::same()`. Порядок параметров я решил взять привычный, как у PHPUnit: сначала **$expected**, затем **$actual** (у webmozart первым параметром указывается проверяемое значение, а потом ожидаемое, что, в принципе, **выглядит более логичным**).
5858

59+
::: info
60+
Позже Testo перешёл на прямой порядок: теперь <func>\Testo\Assert::same()</func> принимает сначала проверяемое значение, а затем ожидаемое.
61+
:::
62+
5963
Пошло-поехало. Сделали `::same()`, `::notSame`, `::null()`, `::true()`, `::false()`, `::equals()`, `::notEquals()`.
6064

6165
И вот мы дошли до функции `Assert::greaterThan()`. В PHPUnit порядок аргументов этой функции всё тот же: сначала **$expected**, затем **$actual**.
@@ -138,7 +142,7 @@ Expect::exception(Failure::class)
138142
#[Test]
139143
public function checkIterableTraitMethods(): void
140144
{
141-
Assert::instanceOf(\DateTimeInterface::class, new \DateTimeImmutable());
145+
Assert::instanceOf(new \DateTimeImmutable(), \DateTimeInterface::class);
142146
// Сокращение конструкции Assert::object($object)->instanceOf($class);
143147

144148
Assert::int(15)->greaterThan(10);

0 commit comments

Comments
 (0)