Skip to content

Commit

Permalink
Add AutomationsTest testIterator
Browse files Browse the repository at this point in the history
  • Loading branch information
ecoologic committed Oct 30, 2023
1 parent 3191160 commit 5994a59
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Zendesk/API/Traits/Utility/Pagination/CbpStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public function getPage()
$response = $this->resourcesRoot->findAll($params);

// TODO: remove
// print_r( $response);
// echo "\npage ids: ";
// foreach ($response->tickets as $ticket) {
// echo $ticket->id . " ";
Expand Down
31 changes: 31 additions & 0 deletions tests/Zendesk/API/UnitTests/Core/AutomationsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,44 @@

namespace Zendesk\API\UnitTests\Core;

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

/**
* Automations test class
*/
class AutomationsTest extends BasicTest
{
protected $testResource0;
protected $testResource1;
protected $testResource2;

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

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

]))
]);

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

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


/**
* Test we can use endpoint to get active automations
Expand Down

0 comments on commit 5994a59

Please sign in to comment.