Skip to content

Commit 53bd990

Browse files
author
Dmytro Poperechnyy
committed
MAGETWO-33060: Refactor __() to return Phrase object
- Unit & integration tests modified; - Framework DataObjectProcessor updated;
1 parent 655576d commit 53bd990

File tree

14 files changed

+29
-24
lines changed

14 files changed

+29
-24
lines changed

app/code/Magento/ImportExport/Model/Import/Entity/AbstractEntity.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ public function getErrorMessages()
465465
$messages = [];
466466
foreach ($this->_errors as $errorCode => $errorRows) {
467467
if (isset($this->_messageTemplates[$errorCode])) {
468-
$errorCode = __($this->_messageTemplates[$errorCode]);
468+
$errorCode = (string)__($this->_messageTemplates[$errorCode]);
469469
}
470470
foreach ($errorRows as $errorRowData) {
471471
$key = $errorRowData[1] ? sprintf($errorCode, $errorRowData[1]) : $errorCode;

dev/tests/integration/testsuite/Magento/Captcha/Model/ObserverTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function testBackendLoginActionWithInvalidCaptchaReturnsError()
3232
];
3333
$this->getRequest()->setPost($post);
3434
$this->dispatch('backend/admin');
35-
$this->assertContains(__('Incorrect CAPTCHA'), $this->getResponse()->getBody());
35+
$this->assertContains((string)__('Incorrect CAPTCHA'), $this->getResponse()->getBody());
3636
}
3737

3838
/**

dev/tests/integration/testsuite/Magento/Checkout/Model/Type/OnepageTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ public function testSaveBillingNewAddressErrorExistingEmail()
482482
$this->assertArrayHasKey('message', $result, 'Error message was expected to be set');
483483
$this->assertStringStartsWith(
484484
'There is already a registered customer using this email address',
485-
$result['message'],
485+
(string)$result['message'],
486486
'Validation error is invalid.'
487487
);
488488
}

dev/tests/integration/testsuite/Magento/Framework/Data/Argument/Interpreter/StringTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function ($input) {
4848
public function testEvaluate($input, $expected)
4949
{
5050
$actual = $this->_model->evaluate($input);
51-
$this->assertSame($expected, $actual);
51+
$this->assertSame($expected, (string)$actual);
5252
}
5353

5454
public function evaluateDataProvider()

dev/tests/integration/testsuite/Magento/Indexer/Model/ShellTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function testRunIndexList()
6565
);
6666
foreach ($indexerCollection->getItems() as $indexer) {
6767
/** @var \Magento\Indexer\Model\IndexerInterface $indexer */
68-
$this->assertContains($indexer->getTitle(), $result);
68+
$this->assertContains((string)$indexer->getTitle(), $result);
6969
}
7070
}
7171

dev/tests/unit/testsuite/Magento/Bundle/Model/Product/Attribute/Source/Price/ViewTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ public function testGetOptionTextForExistLabel()
7474
{
7575
$existValue = 1;
7676

77-
$this->assertInternalType('string', $this->model->getOptionText($existValue));
77+
$this->assertInstanceOf('Magento\Framework\Phrase', $this->model->getOptionText($existValue));
7878
}
7979

8080
/**

dev/tests/unit/testsuite/Magento/CatalogWidget/Model/Rule/Condition/CombineTest.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ protected function setUp()
4444

4545
public function testGetNewChildSelectOptions()
4646
{
47-
$options = [
47+
$expectedOptions = [
4848
['value' => '', 'label' => 'Please choose a condition to add.'],
4949
['value' => 'Magento\CatalogWidget\Model\Rule\Condition\Combine', 'label' => 'Conditions Combination'],
5050
['label' => 'Product Attribute', 'value' => [
@@ -65,9 +65,14 @@ public function testGetNewChildSelectOptions()
6565
$productCondition->expects($this->any())->method('getAttributeOption')
6666
->will($this->returnValue($attributeOptions));
6767

68-
$this->conditionFactory->expects($this->once())->method('create')->will($this->returnValue($productCondition));
68+
$this->conditionFactory->expects($this->atLeastOnce())->method('create')->willReturn($productCondition);
6969

70-
$this->assertSame($options, $this->condition->getNewChildSelectOptions());
70+
$actualOptions = $this->condition->getNewChildSelectOptions();
71+
foreach ($actualOptions as $key => $option) {
72+
$actualOptions[$key]['label'] = (string)$option['label'];
73+
}
74+
75+
$this->assertSame($expectedOptions, $actualOptions);
7176
}
7277

7378
public function testCollectValidatedAttributes()

dev/tests/unit/testsuite/Magento/Cms/Block/Adminhtml/Block/EditTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public function testGetHeaderText($modelBlockId)
8484
->with($title)
8585
->willReturn($escapedTitle);
8686

87-
$this->assertInternalType('string', $this->this->getHeaderText());
87+
$this->assertInstanceOf('Magento\Framework\Phrase', $this->this->getHeaderText());
8888
}
8989

9090
public function getHeaderTextDataProvider()

dev/tests/unit/testsuite/Magento/Core/Model/Layout/MergeTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,12 @@ public function testGetAllDesignAbstractions()
331331
],
332332
];
333333

334-
$this->assertSame($expected, $this->_model->getAllDesignAbstractions());
334+
$actualAbstractions = $this->_model->getAllDesignAbstractions();
335+
foreach ($actualAbstractions as $key => $abstraction) {
336+
$actualAbstractions[$key]['label'] = (string)$abstraction['label'];
337+
}
338+
339+
$this->assertSame($expected, $actualAbstractions);
335340
}
336341

337342
public function testIsPageLayoutDesignAbstractions()

dev/tests/unit/testsuite/Magento/Customer/Block/Widget/NameTest.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -367,13 +367,7 @@ public function getContainerClassNameProvider()
367367
*/
368368
public function testGetStoreLabel($attributeCode, $storeLabel, $expectedValue)
369369
{
370-
$this->attribute->expects(
371-
$this->once()
372-
)->method(
373-
'getStoreLabel'
374-
)->will(
375-
$this->returnValue($storeLabel)
376-
);
370+
$this->attribute->expects($this->atLeastOnce())->method('getStoreLabel')->willReturn($storeLabel);
377371
$this->assertEquals($expectedValue, $this->_block->getStoreLabel($attributeCode));
378372
}
379373

@@ -405,7 +399,7 @@ public function testGetStoreLabelWithException()
405399
)
406400
)
407401
);
408-
$this->assertSame('', $this->_block->getStoreLabel('attributeCode'));
402+
$this->assertSame('', (string)$this->_block->getStoreLabel('attributeCode'));
409403
}
410404

411405
/**

0 commit comments

Comments
 (0)