Skip to content

Commit f80d876

Browse files
committed
Fixed failed in the Unit Test
1 parent a707031 commit f80d876

File tree

3 files changed

+11
-15
lines changed

3 files changed

+11
-15
lines changed

app/code/Magento/Customer/Model/Metadata/Form/Text.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ private function validateLength($value, AttributeMetadataInterface $attribute, a
124124
// validate length
125125
$label = __($attribute->getStoreLabel());
126126

127-
$length = is_string($value) ? $this->_string->strlen(trim($value)) : 0;
127+
$length = $value ? $this->_string->strlen(trim($value)) : 0;
128128

129129
$validateRules = $attribute->getValidationRules();
130130

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

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,7 @@ class MaintenanceModeTest extends TestCase
3737
*/
3838
protected function setup(): void
3939
{
40-
$this->flagDir = $this->getMockForAbstractClass(
41-
WriteInterface::class,
42-
[],
43-
'',
44-
false,
45-
true,
46-
true,
47-
['readFile']
48-
);
49-
$this->flagDir->method('readFile')->willReturn('');
40+
$this->flagDir = $this->getMockForAbstractClass(WriteInterface::class);
5041
$filesystem = $this->createMock(Filesystem::class);
5142
$filesystem->method('getDirectoryWrite')
5243
->willReturn($this->flagDir);
@@ -104,6 +95,10 @@ public function testisOnWithIP()
10495
$this->flagDir->expects($this->exactly(2))
10596
->method('isExist')
10697
->willReturnMap($mapisExist);
98+
$this->flagDir->expects($this->once())
99+
->method('readFile')
100+
->with(MaintenanceMode::IP_FILENAME)
101+
->willReturn('');
107102
$this->assertFalse($this->model->isOn());
108103
}
109104

lib/internal/Magento/Framework/View/Test/Unit/Element/Html/Link/CurrentTest.php

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,9 @@ public function testGetUrl(): void
7979
public function testIsCurrentIfIsset(): void
8080
{
8181
$pathStub = '';
82-
$this->_urlBuilderMock
83-
->method('getUrl')
82+
$this->_urlBuilderMock->method('getUrl')
8483
->with($pathStub)
85-
->will($this->returnValue('http://example.com/'));
84+
->willReturn('http://example.com/');
8685
$this->currentLink->setPath($pathStub);
8786
$this->currentLink->setCurrent(true);
8887
$this->assertTrue($this->currentLink->isCurrent());
@@ -120,10 +119,12 @@ public function testIsCurrent($pathStub, $urlStub, $request, $expected): void
120119
$willReturnArgs[] = $this->returnValue($urlStub);
121120
$withArgs[] = [$request['mcaStub']];
122121
$willReturnArgs[] = $this->returnValue($request['getUrl']);
122+
$withArgs[] = ['*/*/*', ['_current' => false, '_use_rewrite' => true]];
123123

124124
if ($request['mcaStub'] == '') {
125-
$withArgs[] = ['*/*/*', ['_current' => false, '_use_rewrite' => true]];
126125
$willReturnArgs[] = $this->returnValue($urlStub);
126+
} else {
127+
$willReturnArgs[] = $this->returnValue('');
127128
}
128129
$this->_urlBuilderMock
129130
->method('getUrl')

0 commit comments

Comments
 (0)