Skip to content

Commit

Permalink
Merge pull request #548 from zendesk/cgoddard/red-2643/fix-issue-when…
Browse files Browse the repository at this point in the history
…-iterating-over-help-center-categories

[RED-2643] Fix issue when iterating over help center categories
  • Loading branch information
Zendesk-NathanBellette authored Jan 15, 2025
2 parents 638625c + 80cffd1 commit d06ad95
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 3 deletions.
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.PHONY: test all

test:
composer test:unit

all: test
9 changes: 6 additions & 3 deletions src/Zendesk/API/Resources/HelpCenter/Articles.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,15 @@ class Articles extends ResourceAbstract
use Search;

/**
* @{inheritdoc}
* {@inheritdoc}
*/
protected $objectName = 'article';

/**
* @{inheritdoc}
* {@inheritdoc}
*/
protected $objectNamePlural = 'articles';
/**
* {@inheritdoc}
*/
protected function setupRoutes()
{
Expand Down
4 changes: 4 additions & 0 deletions src/Zendesk/API/Resources/HelpCenter/Categories.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ class Categories extends ResourceAbstract
* {@inheritdoc}
*/
protected $objectName = 'category';
/**
* {@inheritdoc}
*/
protected $objectNamePlural = 'categories';

/**
* {@inheritdoc}
Expand Down
4 changes: 4 additions & 0 deletions src/Zendesk/API/Resources/HelpCenter/Sections.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ class Sections extends ResourceAbstract
* {@inheritdoc}
*/
protected $objectName = 'section';
/**
* {@inheritdoc}
*/
protected $objectNamePlural = 'sections';

/**
* @inheritdoc
Expand Down
39 changes: 39 additions & 0 deletions tests/Zendesk/API/LiveTests/HelpCenterTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?php

namespace Zendesk\API\LiveTests;

class HelpCenterTest extends BasicTest
{
/**
* @throws \Zendesk\API\Exceptions\MissingParametersException
*/
public function testIterateOverHelpCenterArticles()
{
$iterator = $this->client->helpCenter->articles()->iterator();

$actual = iterator_to_array($iterator);

// Generally, there should be at least one article in the help center, even if these are just the default articles.
$this->assertTrue(is_array($actual) && count($actual) > 0, 'Should return a non-empty array of articles.');
}

public function testIterateOverHelpCenterSections()
{
$iterator = $this->client->helpCenter->sections()->iterator();

$actual = iterator_to_array($iterator);

// Generally, there should be at least one section in the help center, even if these are just the default sections.
$this->assertTrue(is_array($actual) && count($actual) > 0, 'Should return a non-empty array of sections.');
}

public function testIterateOverHelpCenterCategories()
{
$iterator = $this->client->helpCenter->categories()->iterator();

$actual = iterator_to_array($iterator);

// Generally, there should be at least one category in the help center, even if these are just the default categories.
$this->assertTrue(is_array($actual) && count($actual) > 0, 'Should return a non-empty array of categories.');
}
}

0 comments on commit d06ad95

Please sign in to comment.