Skip to content

Commit

Permalink
fix ListRequest for IntParam
Browse files Browse the repository at this point in the history
  • Loading branch information
segy committed Nov 27, 2019
1 parent 7487c46 commit cf44380
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
9 changes: 9 additions & 0 deletions spec/Pohoda/ListRequestSpec.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,15 @@ public function it_creates_correct_xml_for_address_book()
$this->getXML()->asXML()->shouldReturn('<lAdb:listAddressBookRequest version="2.0" addressBookVersion="2.0"><lAdb:requestAddressBook/></lAdb:listAddressBookRequest>');
}

public function it_creates_correct_xml_for_int_params()
{
$this->beConstructedWith([
'type' => 'IntParam'
], '123');

$this->getXML()->asXML()->shouldReturn('<lst:listIntParamRequest version="2.0"><lst:requestIntParam/></lst:listIntParamRequest>');
}

public function it_creates_correct_xml_for_invoice_with_user_filter_name()
{
$this->beConstructedWith([
Expand Down
6 changes: 5 additions & 1 deletion src/Pohoda/ListRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,11 @@ public function getXML(): \SimpleXMLElement
{
$xml = $this->_createXML()->addChild($this->_data['namespace'] . ':list' . $this->_data['type'] . 'Request', null, $this->_namespace($this->_data['namespace']));
$xml->addAttribute('version', '2.0');
$xml->addAttribute($this->_getLcFirstType() . 'Version', '2.0');

// IntParam doesn't have the version attribute
if ($this->_data['type'] != 'IntParam') {
$xml->addAttribute($this->_getLcFirstType() . 'Version', '2.0');
}

if (isset($this->_data[$this->_getLcFirstType() . 'Type'])) {
$xml->addAttribute($this->_getLcFirstType() . 'Type', $this->_data[$this->_getLcFirstType() . 'Type']);
Expand Down

0 comments on commit cf44380

Please sign in to comment.