Skip to content

Commit d10e52f

Browse files
committed
MAGETWO-71024: [Tech Debt] Skipped unit/integration tests needs to be re-examined.
- Fix unit tests in framework - Fix failing code style checks
1 parent e77b31e commit d10e52f

File tree

9 files changed

+32
-61
lines changed

9 files changed

+32
-61
lines changed

app/code/Magento/CatalogImportExport/Test/Unit/Model/Import/Product/Type/VirtualTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,10 @@ class VirtualTest extends \PHPUnit\Framework\TestCase
1313
*/
1414
public function testPrepareAttributesWithDefaultValueForSave()
1515
{
16-
$virtualModelMock = $this->createPartialMock(\Magento\CatalogImportExport\Model\Import\Product\Type\Virtual::class, []);
16+
$virtualModelMock = $this->createPartialMock(
17+
\Magento\CatalogImportExport\Model\Import\Product\Type\Virtual::class,
18+
[]
19+
);
1720

1821
$this->setPropertyValue(
1922
$virtualModelMock,

app/code/Magento/Cron/Test/Unit/Observer/ProcessCronQueueObserverTest.php

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,6 @@ class ProcessCronQueueObserverTest extends \PHPUnit\Framework\TestCase
8888
*/
8989
protected $scheduleResource;
9090

91-
/**
92-
* @var \Magento\Framework\DB\Adapter\AdapterInterface|\PHPUnit_Framework_MockObject_MockObject
93-
*/
94-
protected $connection;
95-
9691
/**
9792
* Prepare parameters
9893
*/
@@ -151,12 +146,12 @@ protected function setUp()
151146
$this->scheduleResource = $this->getMockBuilder(\Magento\Cron\Model\ResourceModel\Schedule::class)
152147
->disableOriginalConstructor()
153148
->getMock();
154-
$this->connection = $this->getMockBuilder(\Magento\Framework\DB\Adapter\AdapterInterface::class)
149+
$connection = $this->getMockBuilder(\Magento\Framework\DB\Adapter\AdapterInterface::class)
155150
->disableOriginalConstructor()
156151
->getMock();
157152

158-
$this->scheduleResource->method('getConnection')->willReturn($this->connection);
159-
$this->connection->method('delete')->willReturn(1);
153+
$this->scheduleResource->method('getConnection')->willReturn($connection);
154+
$connection->method('delete')->willReturn(1);
160155

161156
$this->_observer = new ProcessCronQueueObserver(
162157
$this->_objectManager,

app/code/Magento/ImportExport/Test/Unit/Model/ImportTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,6 @@ public function testUploadSource()
429429
*/
430430
public function testValidateSource()
431431
{
432-
$this->markTestSkipped('Test needs to be refacotred,');
433432
$validationStrategy = ProcessingErrorAggregatorInterface::VALIDATION_STRATEGY_STOP_ON_ERROR;
434433
$allowedErrorCount = 1;
435434

app/code/Magento/Sales/Test/Unit/Model/Order/Invoice/Total/ShippingTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,10 @@ private function getInvoiceCollection(array $invoicesData)
134134
$arguments['data'] = $oneInvoiceData;
135135
$arguments = $objectManagerHelper->getConstructArguments($className, $arguments);
136136
/** @var $prevInvoice \Magento\Sales\Model\Order\Invoice */
137-
$prevInvoice = $this->getMockBuilder($className)->setMethods(['_init'])->setConstructorArgs($arguments)->getMock();
137+
$prevInvoice = $this->getMockBuilder($className)
138+
->setMethods(['_init'])
139+
->setConstructorArgs($arguments)
140+
->getMock();
138141
$result->addItem($prevInvoice);
139142
}
140143
return $result;

app/code/Magento/Sitemap/Test/Unit/Model/SitemapTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -227,9 +227,9 @@ public static function sitemapDataProvider()
227227
];
228228

229229
return [
230-
[50000, 10485760, $expectedSingleFile, 1],
231-
[1, 10485760, $expectedMultiFile, 5],
232-
[50000, 264, $expectedMultiFile, 5]
230+
[50000, 10485760, $expectedSingleFile, 6],
231+
[1, 10485760, $expectedMultiFile, 18],
232+
[50000, 264, $expectedMultiFile, 18]
233233
];
234234
}
235235

@@ -289,7 +289,7 @@ public static function robotsDataProvider()
289289
50000,
290290
10485760,
291291
$expectedSingleFile,
292-
2,
292+
6,
293293
[
294294
'robotsStart' => '',
295295
'robotsFinish' => 'Sitemap: http://store.com/sitemap.xml',
@@ -300,7 +300,7 @@ public static function robotsDataProvider()
300300
50000,
301301
10485760,
302302
$expectedSingleFile,
303-
2,
303+
6,
304304
[
305305
'robotsStart' => "User-agent: *",
306306
'robotsFinish' => "User-agent: *" . PHP_EOL . 'Sitemap: http://store.com/sitemap.xml',
@@ -311,7 +311,7 @@ public static function robotsDataProvider()
311311
1,
312312
10485760,
313313
$expectedMultiFile,
314-
6,
314+
18,
315315
[
316316
'robotsStart' => "User-agent: *\r\n",
317317
'robotsFinish' => "User-agent: *\r\n\r\nSitemap: http://store.com/sitemap.xml",
@@ -322,7 +322,7 @@ public static function robotsDataProvider()
322322
50000,
323323
264,
324324
$expectedMultiFile,
325-
6,
325+
18,
326326
[
327327
'robotsStart' => "User-agent: *\n",
328328
'robotsFinish' => "User-agent: *\n\nSitemap: http://store.com/sitemap.xml",
@@ -333,7 +333,7 @@ public static function robotsDataProvider()
333333
50000,
334334
10485760,
335335
$expectedSingleFile,
336-
1,
336+
6,
337337
['robotsStart' => '', 'robotsFinish' => '', 'pushToRobots' => 0]
338338
] // empty robots file
339339
];
@@ -395,7 +395,7 @@ protected function _prepareSitemapModelMock(
395395

396396
// Check that all expected lines were written
397397
$this->_fileMock->expects(
398-
$this->any()
398+
$this->exactly($expectedWrites)
399399
)->method(
400400
'write'
401401
)->will(

lib/internal/Magento/Framework/App/Test/Unit/ObjectManagerFactoryTest.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ public static function tearDownAfterClass()
4545
*/
4646
public function testCreateObjectManagerFactoryCouldBeOverridden()
4747
{
48-
$this->markTestSkipped('Test needs to be refactored.');
4948
$rootPath = __DIR__ . '/_files/';
5049
$factory = Bootstrap::createObjectManagerFactory($rootPath, []);
5150
$factory->create([], false);

lib/internal/Magento/Framework/Data/Test/Unit/Collection/DbTest.php

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,6 @@ protected function tearDown()
5858
unset($this->collection);
5959
}
6060

61-
/**
62-
* @return \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\DB\Adapter\Pdo\Mysql
63-
*/
6461
public function testSetAddOrder()
6562
{
6663
$adapter = $this->createPartialMock(\Magento\Framework\DB\Adapter\Pdo\Mysql::class, ['fetchAll', 'select']);
@@ -87,17 +84,11 @@ public function testSetAddOrder()
8784
$this->assertEquals('some_field ASC', (string)array_shift($selectOrders));
8885
$this->assertEquals('other_field DESC', (string)array_shift($selectOrders));
8986
$this->assertEmpty(array_shift($selectOrders));
90-
91-
return $adapter;
9287
}
9388

94-
/**
95-
* @param \PHPUnit_Framework_MockObject_MockObject|\Magento\Framework\DB\Adapter\Pdo\Mysql $adapter
96-
* @depends testSetAddOrder
97-
*/
98-
public function testUnshiftOrder($adapter)
89+
public function testUnshiftOrder()
9990
{
100-
$this->markTestSkipped('Test needs to be refacotred.');
91+
$adapter = $this->createPartialMock(\Magento\Framework\DB\Adapter\Pdo\Mysql::class, ['fetchAll', 'select']);
10192
$renderer = $this->getSelectRenderer($this->objectManager);
10293
$select = new \Magento\Framework\DB\Select($adapter, $renderer);
10394
$adapter

lib/internal/Magento/Framework/View/Test/Unit/Element/Text/TextList/ItemTest.php

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -42,35 +42,27 @@ public function testSetLink()
4242
* @dataProvider toHtmlDataProvider
4343
*
4444
* @param array $liParams
45-
* @param string $attrName
46-
* @param string $attrValue
4745
* @param string $innerText
4846
*/
49-
public function testToHtml($liParams, $attrName, $attrValue, $innerText)
47+
public function testToHtml($liParams, $innerText, $expectedHtml)
5048
{
51-
$this->markTestSkipped('Test needs to be refactored.');
5249
$this->item->setLink($liParams, $innerText);
53-
$this->assertTag([
54-
'tag' => 'li',
55-
'attributes' => [$attrName => $attrValue],
56-
'content' => $innerText,
57-
], $this->item->toHtml());
50+
51+
$this->assertEquals($expectedHtml, $this->item->toHtml());
5852
}
5953

6054
public function toHtmlDataProvider()
6155
{
6256
return [
6357
[
6458
'liParams' => ['class' => 'some-css-class'],
65-
'attrName' => 'class',
66-
'attrValue' => 'some-css-class',
6759
'innerText' => 'text',
60+
'expectedHtml' => '<li class="some-css-class">text</li>' . "\r\n"
6861
],
6962
[
7063
'liParams' => 'class="some-css-class"',
71-
'attrName' => 'class',
72-
'attrValue' => 'some-css-class',
7364
'innerText' => 'text',
65+
'expectedHtml' => '<li class="some-css-class">text</li>' . "\r\n"
7466
]
7567
];
7668
}

lib/internal/Magento/Framework/View/Test/Unit/Element/Text/TextList/LinkTest.php

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -47,40 +47,29 @@ public function testSetLink()
4747
/**
4848
* @dataProvider toHtmlDataProvider
4949
*/
50-
public function testToHtml($liParams, $liAttr, $aParams, $aAttr, $innerText, $afterText)
50+
public function testToHtml($liParams, $aParams, $innerText, $afterText, $expectedHtml)
5151
{
52-
$this->markTestSkipped('Test needs to be refactored.');
5352
$this->link->setLink($liParams, $aParams, $innerText, $afterText);
54-
$this->assertTag([
55-
'tag' => 'li',
56-
'attributes' => [$liAttr['name'] => $liAttr['value']],
57-
'child' => [
58-
'tag' => 'a',
59-
'attributes' => [$aAttr['name'] => $aAttr['value']],
60-
'content' => $innerText,
61-
],
62-
'content' => $afterText,
63-
], $this->link->toHtml());
53+
54+
$this->assertEquals($expectedHtml, $this->link->toHtml());
6455
}
6556

6657
public function toHtmlDataProvider()
6758
{
6859
return [
6960
[
7061
'liParams' => ['class' => 'some-css-class'],
71-
'liAttr' => ['name' => 'class', 'value' => 'some-css-class'],
7262
'aParams' => ['href' => 'url'],
73-
'aAttr' => ['name' => 'href', 'value' => 'url'],
7463
'innerText' => 'text',
7564
'afterText' => 'afterText',
65+
'expectedHtml' => '<li class="some-css-class"><a href="url">text</a>afterText</li>' . "\r\n"
7666
],
7767
[
7868
'liParams' => 'class="some-css-class"',
79-
'liAttr' => ['name' => 'class', 'value' => 'some-css-class'],
8069
'aParams' => 'href="url"',
81-
'aAttr' => ['name' => 'href', 'value' => 'url'],
8270
'innerText' => 'text',
8371
'afterText' => 'afterText',
72+
'expectedHtml' => '<li class="some-css-class"><a href="url">text</a>afterText</li>' . "\r\n"
8473
]
8574
];
8675
}

0 commit comments

Comments
 (0)