From 42669a71a4e3744c10f014dd9f56e8b3e81899e3 Mon Sep 17 00:00:00 2001 From: Pavel Date: Wed, 19 Jun 2019 12:14:40 +0300 Subject: [PATCH] ListResponse implements \Countable --- src/Bot/Model/Response/ListResponse.php | 4 ++-- tests/Bot/Tests/ClientListTest.php | 18 +++++++++--------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Bot/Model/Response/ListResponse.php b/src/Bot/Model/Response/ListResponse.php index 488f03b..8f48551 100644 --- a/src/Bot/Model/Response/ListResponse.php +++ b/src/Bot/Model/Response/ListResponse.php @@ -45,7 +45,7 @@ namespace RetailCrm\Mg\Bot\Model\Response; * @license https://opensource.org/licenses/MIT MIT License * @link http://help.retailcrm.pro/docs/Developers */ -class ListResponse implements \Iterator, \ArrayAccess { +class ListResponse implements \Iterator, \ArrayAccess, \Countable { /** * @var array */ @@ -95,7 +95,7 @@ class ListResponse implements \Iterator, \ArrayAccess { } /** - * `count()` alternative for ListResponse + * \Countable implementation * * @return int */ diff --git a/tests/Bot/Tests/ClientListTest.php b/tests/Bot/Tests/ClientListTest.php index 969a267..3e6ab16 100644 --- a/tests/Bot/Tests/ClientListTest.php +++ b/tests/Bot/Tests/ClientListTest.php @@ -57,7 +57,7 @@ class ClientListTest extends TestCase $response = $client->channels($request); - static::assertEquals(4, $response->count(), "Incorrect channels count"); + static::assertEquals(4, count($response), "Incorrect channels count"); static::assertTrue($response[0] instanceof Channel\Channel, "Incorrect channel instance"); } @@ -79,7 +79,7 @@ class ClientListTest extends TestCase $response = $client->chats($request); - static::assertEquals(2, $response->count(), "Incorrect chats count"); + static::assertEquals(2, count($response), "Incorrect chats count"); static::assertTrue($response[0] instanceof Chat, "Incorrect chat instance"); } @@ -99,7 +99,7 @@ class ClientListTest extends TestCase $request = new Request\MembersRequest(); $response = $client->members($request); - static::assertEquals(4, $response->count(), "Incorrect members count"); + static::assertEquals(4, count($response), "Incorrect members count"); static::assertTrue($response[0] instanceof ChatMember, "Incorrect member instance"); } @@ -122,7 +122,7 @@ class ClientListTest extends TestCase $response = $client->messages($request); - static::assertEquals(2, $response->count(), "Incorrect message count"); + static::assertEquals(2, count($response), "Incorrect message count"); static::assertTrue($response[0] instanceof Message, "Incorrect message instance"); } @@ -142,7 +142,7 @@ class ClientListTest extends TestCase $request = new Request\CommandsRequest(); $response = $client->commands($request); - self::assertEquals(0, $response->count(), "Invalid commands count"); + self::assertEquals(0, count($response), "Invalid commands count"); } /** @@ -164,7 +164,7 @@ class ClientListTest extends TestCase $data = $client->bots($request); - static::assertEquals(3, $data->count()); + static::assertEquals(3, count($data)); } /** @@ -186,7 +186,7 @@ class ClientListTest extends TestCase $response = $client->users($request); - self::assertEquals(2, $response->count()); + self::assertEquals(2, count($response)); self::assertTrue($response[0] instanceof User); } @@ -209,7 +209,7 @@ class ClientListTest extends TestCase $response = $client->dialogs($request); - self::assertEquals(2, $response->count()); + self::assertEquals(2, count($response)); self::assertTrue($response[0] instanceof Dialog); } @@ -230,7 +230,7 @@ class ClientListTest extends TestCase $response = $client->customers($request); - self::assertEquals(2, $response->count()); + self::assertEquals(2, count($response)); self::assertTrue($response[0] instanceof Customer); } }