Skip to content

Commit 9676553

Browse files
authored
Revert "Revert "Add ability to run unit tests locally and add support for CDATA""
1 parent 0278220 commit 9676553

37 files changed

+81
-42
lines changed

Helper/ProductSync/XmlHelper.php

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,28 @@
2222
use Magento\Catalog\Api\Data\ProductInterface;
2323
use Magento\Framework\EntityManager\MetadataPool;
2424

25+
26+
class SimpleXMLElementExtended extends \SimpleXMLElement {
27+
28+
/**
29+
* https://stackoverflow.com/a/20511976
30+
* Adds a child with $value inside CDATA
31+
* @param unknown $name
32+
* @param unknown $value
33+
*/
34+
public function addChildWithCDATA($name, $value = NULL) {
35+
$new_child = $this->addChild($name);
36+
37+
if ($new_child !== NULL) {
38+
$node = dom_import_simplexml($new_child);
39+
$no = $node->ownerDocument;
40+
$node->appendChild($no->createCDATASection($value));
41+
}
42+
43+
return $new_child;
44+
}
45+
}
46+
2547
/**
2648
* Class XmlHelper
2749
* @package Ordergroove\Subscription\Helper\ProductSync
@@ -174,7 +196,7 @@ public function createWebsiteProductsXml($websiteId)
174196
$linkField = $metadata->getLinkField();
175197
try {
176198
$this->logger->info("In createWebsiteProductsXml for: ".$websiteId);
177-
$this->xml = new \SimpleXMLElement('<products/>');
199+
$this->xml = new SimpleXMLElementExtended('<products/>');
178200
$collection = $this->productFactory->create()->getCollection();
179201

180202
$entityType = $collection->getEntity()->getType();
@@ -273,7 +295,7 @@ public function processProductIntoXml($args)
273295
return;
274296
}
275297
$productXml = $this->xml->addChild('product');
276-
$productXml->addChild('name', str_replace($symbols["search"], $symbols["replace"], $productData['name']));
298+
$productXml->addChildWithCDATA('name', str_replace($symbols["search"], $symbols["replace"], $productData['name']));
277299
$productXml->addChild('product_id', $productData['entity_id']);
278300
$productXml->addChild('sku', $productData['sku']);
279301
$productXml->addChild('price', $productData['price']);

Test/Unit/Block/Catalog/GetProductDataTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class GetProductDataTest extends TestCase
4444
* setUp
4545
* @return void
4646
*/
47-
public function setUp()
47+
public function setUp() : void
4848
{
4949
$this->objectManager = new ObjectManager($this);
5050
$this->registry = $this->createPartialMock(Registry::class, ['registry']);

Test/Unit/Block/MainJsTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class MainJsTest extends TestCase
3434
/**
3535
* @return void
3636
*/
37-
public function setUp()
37+
public function setUp() : void
3838
{
3939
$this->objectManager = new ObjectManager($this);
4040

@@ -58,7 +58,7 @@ public function setUp()
5858
/**
5959
* @return void
6060
*/
61-
public function testGetMainJsUrl()
61+
public function testGetMainJsUrl() : void
6262
{
6363
$this->urlBuilder->expects($this->once())->method("getPublicIdUrl")->willReturn("https://test.com");
6464
$this->assertEquals("https://test.com", $this->mainJs->getMainJsUrl());

Test/Unit/Block/MsiJsTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class MsiJsTest extends TestCase
4141
*
4242
* @return void
4343
*/
44-
public function setUp()
44+
public function setUp() : void
4545
{
4646
$this->objectManager = new ObjectManager($this);
4747

Test/Unit/Block/System/Config/CheckConnectionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class CheckConnectionTest extends TestCase
3232
*/
3333
protected $layout;
3434

35-
protected function setUp()
35+
protected function setUp() : void
3636
{
3737
$objectManager = new ObjectManager($this);
3838
$this->objectManagerMock = $this->createMock(\Magento\Framework\ObjectManager\ObjectManager::class);
@@ -52,7 +52,7 @@ protected function setUp()
5252
);
5353
}
5454

55-
protected function tearDown()
55+
protected function tearDown() : void
5656
{
5757
}
5858

Test/Unit/Controller/Msi/IndexTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ class IndexTest extends TestCase
6060
*
6161
* @return void
6262
*/
63-
public function setUp()
63+
public function setUp() : void
6464
{
6565
$this->objectManagerMock = $this->createMock(\Magento\Framework\ObjectManager\ObjectManager::class);
6666
$this->request = $this->createMock(\Magento\Framework\App\Request\Http::class);

Test/Unit/Controller/Subscription/PlaceOrderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ class PlaceOrderTest extends TestCase
8484
*/
8585
protected $request;
8686

87-
public function setUp()
87+
public function setUp() : void
8888
{
8989
$objectManager = new ObjectManager($this);
9090
$this->context = $this->createMock(Context::class);

Test/Unit/Helper/ConfigHelperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ class ConfigHelperTest extends TestCase
3535
* setUp
3636
* @return void
3737
*/
38-
protected function setUp()
38+
protected function setUp() : void
3939
{
4040
$this->objectManager = new ObjectManager($this);
4141

Test/Unit/Helper/ProductSync/ProductSyncTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class ProductSyncTest extends TestCase
2929
* @var ObjectManager
3030
*/
3131
protected $objectManager;
32-
protected function setUp()
32+
protected function setUp() : void
3333
{
3434
$this->objectManager = new ObjectManager($this);
3535
$this->productSync = $this->objectManager->getObject(ProductSync::class);
@@ -50,7 +50,7 @@ protected function setUp()
5050
);
5151
}
5252

53-
protected function tearDown()
53+
protected function tearDown() : void
5454
{
5555
}
5656

Test/Unit/Helper/ProductSync/SftpHelperTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class SftpHelperTest extends TestCase
4343
*/
4444
protected $infoLogger;
4545

46-
protected function setUp()
46+
protected function setUp() : void
4747
{
4848
$this->objectManager = new ObjectManager($this);
4949

@@ -74,7 +74,7 @@ protected function setUp()
7474
);
7575
}
7676

77-
protected function tearDown()
77+
protected function tearDown() : void
7878
{
7979
}
8080

Test/Unit/Helper/ProductSync/XmlHelperTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class XmlHelperTest extends TestCase
5757
*/
5858
private $scopeConfig;
5959

60-
protected function setUp()
60+
protected function setUp() : void
6161
{
6262
$this->objectManager = new ObjectManager($this);
6363
$this->storeRepository = $this->getMockBuilder(StoreRepository::class)
@@ -109,7 +109,7 @@ protected function setUp()
109109
);
110110
}
111111

112-
protected function tearDown()
112+
protected function tearDown() : void
113113
{
114114
}
115115

Test/Unit/Helper/PurchasePost/DataMapper/DataMapHelperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ public function testGetAddressMappedData()
191191
* setUp
192192
* @return void
193193
*/
194-
protected function setUp()
194+
protected function setUp() : void
195195
{
196196
$this->objectManager = new ObjectManager($this);
197197

Test/Unit/Helper/PurchasePost/DataMapper/DataMapTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ class DataMapTest extends TestCase
4343
* setUp
4444
* @return void
4545
*/
46-
protected function setUp()
46+
protected function setUp() : void
4747
{
4848
$this->objectManager = new ObjectManager($this);
4949

Test/Unit/Helper/PurchasePost/SendPurchasePostDataTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ class SendPurchasePostDataTest extends TestCase
5555
* setUp
5656
* @return void
5757
*/
58-
protected function setUp()
58+
protected function setUp() : void
5959
{
6060
$this->objectManager = new ObjectManager($this);
6161

Test/Unit/Helper/RecurringOrderHelper/CreateRecurringOrderHelperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ class CreateRecurringOrderHelperTest extends TestCase
6969
/**
7070
* Constructor
7171
*/
72-
public function setUp()
72+
public function setUp() : void
7373
{
7474
$this->objectManager = new ObjectManager($this);
7575

Test/Unit/Helper/UrlBuilderHelperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class UrlBuilderHelperTest extends TestCase
2929
* setUp
3030
* @return void
3131
*/
32-
protected function setUp()
32+
protected function setUp() : void
3333
{
3434
$this->objectManager = new ObjectManager($this);
3535

Test/Unit/Model/Authentication/ValidateAuthorizationTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class ValidateAuthorizationTest extends TestCase
2929
*/
3030
protected $validateAuthorization;
3131

32-
public function setUp()
32+
public function setUp() : void
3333
{
3434
$this->objectManager = new ObjectManager($this);
3535

Test/Unit/Model/Config/ConfigProviderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class ConfigProviderTest extends TestCase
3939
* setUp
4040
* @return void
4141
*/
42-
protected function setUp()
42+
protected function setUp() : void
4343
{
4444
$this->objectManager = new ObjectManager($this);
4545

Test/Unit/Model/Config/Source/SyncSelectTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class SyncSelectTest extends TestCase
1919
*/
2020
protected $timeZoneInterface;
2121

22-
protected function setUp()
22+
protected function setUp() : void
2323
{
2424
$objectManager = new ObjectManager($this);
2525
$this->timeZoneInterface = $this->getMockBuilder(Timezone::class)
@@ -35,7 +35,7 @@ protected function setUp()
3535
);
3636
}
3737

38-
protected function tearDown()
38+
protected function tearDown() : void
3939
{
4040
}
4141

Test/Unit/Model/Config/TokenBuilderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class TokenBuilderTest extends TestCase
3131
* setUp
3232
* @return void
3333
*/
34-
protected function setUp()
34+
protected function setUp() : void
3535
{
3636
$this->objectManager = new ObjectManager($this);
3737

Test/Unit/Model/Config/UrlBuilderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ class UrlBuilderTest extends TestCase
3737
* setUp
3838
* @return void
3939
*/
40-
protected function setUp()
40+
protected function setUp() : void
4141
{
4242
$this->objectManager = new ObjectManager($this);
4343

Test/Unit/Model/Cookie/OgAuthCookieTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public function testSet()
165165
* setUp
166166
* @return void
167167
*/
168-
protected function setUp()
168+
protected function setUp() : void
169169
{
170170
$this->objectManager = new ObjectManager($this);
171171

Test/Unit/Model/Customer/UpdateDataApiHelper/UpdateDataApiHelperTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ class UpdateDataApiHelperTest extends TestCase
6767
*
6868
* @return void
6969
*/
70-
public function setUp()
70+
public function setUp() : void
7171
{
7272
$this->objectManager = new ObjectManager($this);
7373

Test/Unit/Model/Customer/UpdateDataApiTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ class UpdateDataApiTest extends TestCase
9090
*
9191
* @return void
9292
*/
93-
public function setUp()
93+
public function setUp() : void
9494
{
9595
$this->objectManager = new ObjectManager($this);
9696

Test/Unit/Model/RecurringOrder/CreateRecurringOrderTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ class CreateRecurringOrderTest extends TestCase
8383
*
8484
* @return void
8585
*/
86-
public function setUp()
86+
public function setUp() : void
8787
{
8888
$this->objectManager = new ObjectManager($this);
8989
$this->product = $this->getMockBuilder(Product::class)

Test/Unit/Model/Request/ValidateRequestTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class ValidateRequestTest extends TestCase
3131
/**
3232
* Set Up
3333
*/
34-
public function setUp()
34+
public function setUp() : void
3535
{
3636
$this->objectManager = new ObjectManager($this);
3737
$this->request = $this->getMockBuilder(Http::class)

Test/Unit/Model/Signature/SignatureTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class SignatureTest extends TestCase
3434
* setUp
3535
* @return void
3636
*/
37-
protected function setUp()
37+
protected function setUp() : void
3838
{
3939
$this->objectManager = new ObjectManager($this);
4040

Test/Unit/Observer/CustomerUpdate/ChangeInEmailTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ public function testExecuteEmailNoChange()
111111
* setUp
112112
* @return void
113113
*/
114-
protected function setUp()
114+
protected function setUp() : void
115115
{
116116
$this->objectManager = new ObjectManager($this);
117117

Test/Unit/Observer/DataAssignObserverTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class DataAssignObserverTest extends TestCase
2727
* @var ObjectManager
2828
*/
2929
private $objectManager;
30-
protected function setUp()
30+
protected function setUp() : void
3131
{
3232
$this->objectManager = new ObjectManager($this);
3333

Test/Unit/Observer/Sales/SendPurchasePostTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class SendPurchasePostTest extends Testcase
6363
* setUp
6464
* @return void
6565
*/
66-
protected function setUp()
66+
protected function setUp() : void
6767
{
6868
$this->objectManager = new ObjectManager($this);
6969

Test/Unit/Plugin/Account/Login/CreateCookieTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public function testAfterExecuteCustomerLoggedIn()
114114
* setUp
115115
* @return void
116116
*/
117-
protected function setUp()
117+
protected function setUp() : void
118118
{
119119
$this->objectManager = new ObjectManager($this);
120120

Test/Unit/Plugin/Account/Logout/DeleteCookieTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class DeleteCookieTest extends TestCase
5757
* setUp
5858
* @return void
5959
*/
60-
protected function setUp()
60+
protected function setUp() : void
6161
{
6262
$this->objectManager = new ObjectManager($this);
6363

Test/Unit/Plugin/Account/Telephone/ChangeInTelephoneTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public function testAroundExecute()
134134
* setUp
135135
* @return void
136136
*/
137-
protected function setUp()
137+
protected function setUp() : void
138138
{
139139
$this->objectManager = new ObjectManager($this);
140140
$this->customerSession = $this->getMockBuilder(Session::class)

Test/Unit/Plugin/Checkout/CustomerData/AbstractItemPluginTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class AbstractItemPluginTest extends TestCase
3232
* setUp
3333
* @return void
3434
*/
35-
protected function setUp()
35+
protected function setUp() : void
3636
{
3737
$this->objectManager = new ObjectManager($this);
3838

0 commit comments

Comments
 (0)