Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RED-2643] Fix issue when iterating over help center categories #548

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.');
}
}
Loading