Skip to content

Commit

Permalink
III-2454: Fix parsing of consumer groups
Browse files Browse the repository at this point in the history
  • Loading branch information
bertramakers committed Apr 13, 2018
1 parent 5d96da2 commit 8b944e4
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
7 changes: 6 additions & 1 deletion CultureFeed/CultureFeed.php
Original file line number Diff line number Diff line change
Expand Up @@ -2008,10 +2008,15 @@ protected function parseServiceConsumer(CultureFeed_SimpleXMLElement $element) {
$consumer->logo = $element->xpath_str('logo');
$consumer->name = $element->xpath_str('name');
$consumer->status = $element->xpath_str('status');
$consumer->group = $element->xpath_int('group', true);
$consumer->apiKeySapi3 = $element->xpath_str('apiKeySapi3');
$consumer->searchPrefixSapi3 = $element->xpath_str('searchPrefixSapi3');

$consumer->group = $element->xpath_int('groups/group/id', true);
if (empty($consumer->group)) {
// Try the deprecated/obsolete format just to make sure.
$consumer->group = $element->xpath_int('group', true);
}

return $consumer;
}

Expand Down
24 changes: 24 additions & 0 deletions CultureFeed/test/CultureFeedTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,30 @@ public function setUp() {
$this->cultureFeed = new CultureFeed($this->oauthClient);
}

/**
* @dataProvider getConsumerMethodDataProvider
*
* @param string $method
* @param string $identifier
* @param string $expectedPath
*/
public function testGetConsumerWithGroups(
$method,
$identifier,
$expectedPath
) {
$xml = file_get_contents(__DIR__ . '/data/consumer_with_api_key_sapi3.xml');

$this->oauthClient->expects($this->once())
->method('consumerGetAsXml')
->with($expectedPath)
->willReturn($xml);

$consumer = $this->cultureFeed->{$method}($identifier);

$this->assertEquals([744, 22074], $consumer->group);
}

/**
* @dataProvider getConsumerMethodDataProvider
*
Expand Down

0 comments on commit 8b944e4

Please sign in to comment.