Skip to content

Commit

Permalink
Add MacrosTest testIterator
Browse files Browse the repository at this point in the history
  • Loading branch information
ecoologic committed Oct 30, 2023
1 parent 72737d8 commit 4af18e5
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ services:
command: vendor/bin/phpunit --testsuite "Zendesk API Unit Test Suites"
# command: vendor/bin/phpunit tests/Zendesk/API/UnitTests/Traits/Utility/PaginationTest.php
# command: vendor/bin/phpunit tests/Zendesk/API/UnitTests/Core/TicketsTest.php
# command: vendor/bin/phpunit tests/Zendesk/API/UnitTests/Core/CustomRolesTest.php
# command: vendor/bin/phpunit tests/Zendesk/API/UnitTests/Core/MacrosTest.php

volumes:
vendor:
38 changes: 38 additions & 0 deletions tests/Zendesk/API/UnitTests/Core/MacrosTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace Zendesk\API\UnitTests\Core;

use GuzzleHttp\Psr7\Response;
use Zendesk\API\UnitTests\BasicTest;

/**
Expand All @@ -10,6 +11,43 @@
*/
class MacrosTest extends BasicTest
{
protected $testResource0;
protected $testResource1;
protected $testResource2;

public function setUp()
{
$this->testResource0 = ['anyField' => 'Any field 0'];
$this->testResource1 = ['anyField' => 'Any field 1'];
$this->testResource2 = ['anyField' => 'Any field 2'];
parent::setUp();
}

public function testIterator()
{
// CBP
$this->mockApiResponses([
new Response(200, [], json_encode([
'macros' => [$this->testResource0, $this->testResource1],
'meta' => ['after_cursor' => '<after_cursor>', 'has_more' => true],

])),
new Response(200, [], json_encode([
'macros' => [$this->testResource2],
'meta' => ['has_more' => false],

])),
]);

$iterator = $this->client->macros()->iterator();

$actual = iterator_to_array($iterator);
$this->assertCount(3, $actual);
$this->assertEquals($this->testResource0['anyField'], $actual[0]->anyField);
$this->assertEquals($this->testResource1['anyField'], $actual[1]->anyField);
$this->assertEquals($this->testResource2['anyField'], $actual[2]->anyField);
}

/**
* Test the `GET /api/v2/macros/active.json` endpoint
* Lists active macros for the current user
Expand Down

0 comments on commit 4af18e5

Please sign in to comment.