Skip to content

Commit cca9488

Browse files
author
Igor Melnikov
committed
MAGETWO-69137: upgrading Magento2 Project PHPUnit version to latest
- refactor tests
1 parent c8d1e66 commit cca9488

File tree

14 files changed

+67
-155
lines changed

14 files changed

+67
-155
lines changed

dev/tests/integration/framework/Magento/TestFramework/TestCase/AbstractController.php

Lines changed: 1 addition & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* @SuppressWarnings(PHPMD.NumberOfChildren)
1818
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1919
*/
20-
abstract class AbstractController extends \PHPUnit\Framework\DOMTestCase
20+
abstract class AbstractController extends \PHPUnit\Framework\TestCase
2121
{
2222
protected $_runCode = '';
2323

@@ -289,56 +289,4 @@ protected function getCookieMessages($messageType = null)
289289

290290
return $actualMessages;
291291
}
292-
293-
/**
294-
* Assert count of elements found by XPath in XML/HTML string
295-
*
296-
* @param string $xpath
297-
* @param int $count
298-
* @param string $html
299-
* @param string|null $message
300-
*/
301-
public function assertXpathCount($xpath, $count, $html, $message = '')
302-
{
303-
$this->assertEquals(
304-
$count,
305-
$this->getElementsCountForXpath($xpath, $html),
306-
$message
307-
);
308-
}
309-
310-
/**
311-
* Assert count of elements found by XPath in XML/HTML string greater or equal to specified value
312-
*
313-
* @param string $xpath
314-
* @param int $count
315-
* @param string $html
316-
* @param string|null $message
317-
*/
318-
public function assertXpathCountGreaterThanOrEqual($xpath, $count, $html, $message = '')
319-
{
320-
$this->assertGreaterThanOrEqual(
321-
$count,
322-
$this->getElementsCountForXpath($xpath, $html),
323-
$message
324-
);
325-
}
326-
327-
/**
328-
* Get elements count for XPath
329-
*
330-
* @param string $xpath
331-
* @param string $html
332-
* @return int
333-
*/
334-
private function getElementsCountForXpath($xpath, $html)
335-
{
336-
$domDocument = new \DOMDocument('1.0', 'UTF-8');
337-
libxml_use_internal_errors(true);
338-
$domDocument->loadHTML($html);
339-
libxml_use_internal_errors(false);
340-
$domXpath = new \DOMXPath($domDocument);
341-
$nodes = $domXpath->query($xpath);
342-
return $nodes->length;
343-
}
344292
}

dev/tests/integration/testsuite/Magento/Catalog/Pricing/Render/FinalPriceBox/RenderingBasedOnIsProductListFlagTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
/**
1717
* Test price rendering according to is_product_list flag
1818
*/
19-
class RenderingBasedOnIsProductListFlagTest extends \PHPUnit\Framework\DOMTestCase
19+
class RenderingBasedOnIsProductListFlagTest extends \PHPUnit\Framework\TestCase
2020
{
2121
/**
2222
* @var ProductInterface

dev/tests/integration/testsuite/Magento/Config/Block/System/Config/FormTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* @magentoAppArea adminhtml
1212
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
1313
*/
14-
class FormTest extends \PHPUnit\Framework\DOMTestCase
14+
class FormTest extends \PHPUnit\Framework\TestCase
1515
{
1616
/**
1717
* @var \Magento\Framework\ObjectManagerInterface

dev/tests/integration/testsuite/Magento/ConfigurableProduct/Pricing/Render/FinalPriceBox/RenderingBasedOnIsProductListFlagTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
/**
1818
* Test price rendering according to is_product_list flag for Configurable product
1919
*/
20-
class RenderingBasedOnIsProductListFlagTest extends \PHPUnit\Framework\DOMTestCase
20+
class RenderingBasedOnIsProductListFlagTest extends \PHPUnit\Framework\TestCase
2121
{
2222
/**
2323
* @var ProductInterface

dev/tests/integration/testsuite/Magento/Multishipping/Block/Checkout/OverviewTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
/**
1212
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
1313
*/
14-
class OverviewTest extends \PHPUnit\Framework\DOMTestCase
14+
class OverviewTest extends \PHPUnit\Framework\TestCase
1515
{
1616
/**
1717
* @var \Magento\Multishipping\Block\Checkout\Overview

dev/tests/integration/testsuite/Magento/Paypal/Block/Adminhtml/Billing/Agreement/View/Tab/InfoTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,12 @@ public function testCustomerGridAction()
2929
'Response for billing agreement info doesn\'t contain billing agreement info tab'
3030
);
3131

32-
$this->assertXpathCount(
33-
'//a[contains(text(), "customer@example.com")]',
32+
$this->assertEquals(
3433
1,
35-
$this->getResponse()->getBody(),
34+
\Magento\TestFramework\Helper\Xpath::getElementsCountForXpath(
35+
'//a[contains(text(), "customer@example.com")]',
36+
$this->getResponse()->getBody()
37+
),
3638
'Response for billing agreement info doesn\'t contain Customer info'
3739
);
3840
}

dev/tests/integration/testsuite/Magento/Paypal/Controller/Adminhtml/Billing/Agreement/ViewTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,12 @@ public function testAclHasAccess()
4343
"Response for billing agreement info doesn't contain billing agreement info tab"
4444
);
4545

46-
$this->assertXpathCount(
47-
'//a[contains(text(), "customer@example.com")]',
46+
$this->assertEquals(
4847
1,
49-
$this->getResponse()->getBody(),
48+
\Magento\TestFramework\Helper\Xpath::getElementsCountForXpath(
49+
'//a[contains(text(), "customer@example.com")]',
50+
$this->getResponse()->getBody()
51+
),
5052
"Response for billing agreement info doesn't contain Customer info"
5153
);
5254
}

dev/tests/integration/testsuite/Magento/Paypal/Controller/Adminhtml/Billing/AgreementTest.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,12 @@ public function testCustomerGrid()
2929
),
3030
"Response for billing agreement orders doesn't contain billing agreement customers grid"
3131
);
32-
$this->assertXpathCount(
33-
'//td[contains(text(), "REF-ID-TEST-678")]',
32+
$this->assertEquals(
3433
1,
35-
$this->getResponse()->getBody(),
34+
\Magento\TestFramework\Helper\Xpath::getElementsCountForXpath(
35+
'//td[contains(text(), "REF-ID-TEST-678")]',
36+
$this->getResponse()->getBody()
37+
),
3638
"Response for billing agreement info doesn't contain reference ID"
3739
);
3840
}

dev/tests/integration/testsuite/Magento/Sales/Block/Adminhtml/Order/Create/Form/AddressTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
*
1111
* @magentoAppArea adminhtml
1212
*/
13-
class AddressTest extends \PHPUnit\Framework\DOMTestCase
13+
class AddressTest extends \PHPUnit\Framework\TestCase
1414
{
1515
/** @var \Magento\Framework\ObjectManagerInterface */
1616
protected $_objectManager;

dev/tests/integration/testsuite/Magento/Sales/Controller/Adminhtml/Order/CreateTest.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,10 +113,12 @@ public function testIndexAction()
113113
$html
114114
)
115115
);
116-
$this->assertXpathCountGreaterThanOrEqual(
117-
'//*[@data-grid-id="sales_order_create_customer_grid"]',
116+
$this->assertGreaterThanOrEqual(
118117
1,
119-
$html
118+
\Magento\TestFramework\Helper\Xpath::getElementsCountForXpath(
119+
'//*[@data-grid-id="sales_order_create_customer_grid"]',
120+
$html
121+
)
120122
);
121123
$this->assertGreaterThanOrEqual(
122124
1,
@@ -140,10 +142,9 @@ public function testIndexAction()
140142
)
141143
);
142144

143-
$this->assertXpathCountGreaterThanOrEqual(
144-
'//*[@id="coupons:code"]',
145+
$this->assertGreaterThanOrEqual(
145146
1,
146-
$html
147+
\Magento\TestFramework\Helper\Xpath::getElementsCountForXpath('//*[@id="coupons:code"]', $html)
147148
);
148149
}
149150

0 commit comments

Comments
 (0)