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

Fix break line with parameters PBX_SHOPPINGCART and PBX_BILLING #12

Merged
merged 1 commit into from
Mar 15, 2023
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
2 changes: 1 addition & 1 deletion src/Requests/Paybox/Authorization.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ public function getShoppingCartXml()
}
$dom->total->addChild("totalQuantity", $totalQuantity);

return $dom->asXML();
return str_replace(["\n", "\r"], "", $dom->asXML());
}

/**
Expand Down
18 changes: 9 additions & 9 deletions src/Services/Billing.php
Original file line number Diff line number Diff line change
Expand Up @@ -322,19 +322,19 @@ public function getXml(): string
'<?xml version="1.0" encoding="utf-8"?><Billing><Address></Address></Billing>'
);
if ($this->companyName) {
$dom->addChild("CompanyName", $this->companyName);
$dom->Address->addChild("CompanyName", $this->companyName);
}
$dom->addChild("FirstName", $this->firstName ?? "xxx");
$dom->addChild("LastName", $this->lastName ?? "xxx");
$dom->addChild("Address1", $this->address1 ?? "xxx");
$dom->Address->addChild("FirstName", $this->firstName ?? "xxx");
$dom->Address->addChild("LastName", $this->lastName ?? "xxx");
$dom->Address->addChild("Address1", $this->address1 ?? "xxx");
if ($this->address2) {
$dom->addChild("Address2", $this->address2);
$dom->Address->addChild("Address2", $this->address2);
}
$dom->addChild("ZipCode", $this->zipcode ?? "xxx");
$dom->addChild("City", $this->city ?? "xxx");
$dom->addChild("CountryCode", $this->countryCode ?? 250);
$dom->Address->addChild("ZipCode", $this->zipcode ?? "xxx");
$dom->Address->addChild("City", $this->city ?? "xxx");
$dom->Address->addChild("CountryCode", $this->countryCode ?? 250);

return $dom->asXML();
return str_replace(["\n", "\r"], "", $dom->asXML());
}

/**
Expand Down
20 changes: 4 additions & 16 deletions tests/Requests/AuthorizationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -524,10 +524,7 @@ public function testGetShoppingCartXmlWithTotalPriceAndWithTotalQuantity()
$this->request->setShoppingCartTotalQuantity(10);
$xml = $this->request->getShoppingCartXml();
$this->assertSame(
'<?xml version="1.0" encoding="utf-8"?>' .
PHP_EOL .
"<shoppingcart><total><totalPrice>50.1</totalPrice><totalQuantity>10</totalQuantity></total></shoppingcart>" .
PHP_EOL,
'<?xml version="1.0" encoding="utf-8"?><shoppingcart><total><totalPrice>50.1</totalPrice><totalQuantity>10</totalQuantity></total></shoppingcart>',
$xml
);
}
Expand All @@ -540,10 +537,7 @@ public function testGetShoppingCartXmlWithoutTotalPriceAndWithoutTotalQuantity()
$this->ignoreMissingMethods();
$xml = $this->request->getShoppingCartXml();
$this->assertSame(
'<?xml version="1.0" encoding="utf-8"?>' .
PHP_EOL .
"<shoppingcart><total><totalQuantity>1</totalQuantity></total></shoppingcart>" .
PHP_EOL,
'<?xml version="1.0" encoding="utf-8"?><shoppingcart><total><totalQuantity>1</totalQuantity></total></shoppingcart>',
$xml
);
}
Expand All @@ -557,10 +551,7 @@ public function testGetShoppingCartXmlWithTotalQuantityInf1()
$this->request->setShoppingCartTotalQuantity(-1);
$xml = $this->request->getShoppingCartXml();
$this->assertSame(
'<?xml version="1.0" encoding="utf-8"?>' .
PHP_EOL .
"<shoppingcart><total><totalQuantity>1</totalQuantity></total></shoppingcart>" .
PHP_EOL,
'<?xml version="1.0" encoding="utf-8"?><shoppingcart><total><totalQuantity>1</totalQuantity></total></shoppingcart>',
$xml
);
}
Expand All @@ -574,10 +565,7 @@ public function testGetShoppingCartXmlWithInvalidTotalQuantitySup99()
$this->request->setShoppingCartTotalQuantity(102);
$xml = $this->request->getShoppingCartXml();
$this->assertSame(
'<?xml version="1.0" encoding="utf-8"?>' .
PHP_EOL .
"<shoppingcart><total><totalQuantity>99</totalQuantity></total></shoppingcart>" .
PHP_EOL,
'<?xml version="1.0" encoding="utf-8"?><shoppingcart><total><totalQuantity>99</totalQuantity></total></shoppingcart>',
$xml
);
}
Expand Down
10 changes: 2 additions & 8 deletions tests/Services/BillingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ public function testValidBillingExportXml()
$service->setCity("Paris");
$service->setCountryCode(250);
$this->assertSame(
'<?xml version="1.0" encoding="utf-8"?>' .
PHP_EOL .
"<Billing><Address/><FirstName>John</FirstName><LastName>Doe</LastName><Address1>1 rue de la paix</Address1><ZipCode>75000</ZipCode><City>Paris</City><CountryCode>250</CountryCode></Billing>" .
PHP_EOL,
'<?xml version="1.0" encoding="utf-8"?><Billing><Address><FirstName>John</FirstName><LastName>Doe</LastName><Address1>1 rue de la paix</Address1><ZipCode>75000</ZipCode><City>Paris</City><CountryCode>250</CountryCode></Address></Billing>',
$service->getXml()
);
}
Expand All @@ -40,10 +37,7 @@ public function testBillingExportXmlWithoutData()
{
$service = new Billing();
$this->assertSame(
'<?xml version="1.0" encoding="utf-8"?>' .
PHP_EOL .
"<Billing><Address/><FirstName>xxx</FirstName><LastName>xxx</LastName><Address1>xxx</Address1><ZipCode>xxx</ZipCode><City>xxx</City><CountryCode>250</CountryCode></Billing>" .
PHP_EOL,
'<?xml version="1.0" encoding="utf-8"?><Billing><Address><FirstName>xxx</FirstName><LastName>xxx</LastName><Address1>xxx</Address1><ZipCode>xxx</ZipCode><City>xxx</City><CountryCode>250</CountryCode></Address></Billing>',
$service->getXml()
);
}
Expand Down