Skip to content

Commit 5257492

Browse files
committed
Made code compatible with PHP 5.6 and with older version of PHPUnit.
1 parent 4c45cd8 commit 5257492

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

app/code/Magento/Ui/Model/UiComponentTypeResolver.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@ public function __construct(array $uiComponentTypeMap)
3838
* @param UiComponentContext $componentContext
3939
* @return string
4040
*/
41-
public function resolve(UiComponentContext $componentContext): string
41+
public function resolve(UiComponentContext $componentContext)
4242
{
4343
$acceptType = $componentContext->getAcceptType();
44-
return $this->uiComponentTypeMap[$acceptType] ?? static::DEFAULT_CONTENT_TYPE;
44+
return isset($this->uiComponentTypeMap[$acceptType])
45+
? $this->uiComponentTypeMap[$acceptType]
46+
: static::DEFAULT_CONTENT_TYPE;
4547
}
4648
}

app/code/Magento/Ui/Test/Unit/Controller/Adminhtml/Index/RenderTest.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ public function testExecuteAjaxRequest()
143143
true,
144144
['render']
145145
);
146-
$contextMock = $this->createMock(ContextInterface::class);
146+
$contextMock = $this->getMock(ContextInterface::class);
147147

148148
$viewMock->expects($this->once())
149149
->method('render')
@@ -197,6 +197,8 @@ public function testExecuteAjaxRequestWithoutPermissions($acl, $isAllowed)
197197
true,
198198
['render']
199199
);
200+
$contextMock = $this->getMock(ContextInterface::class);
201+
200202
$componentMock->expects($this->any())
201203
->method('render')
202204
->willReturn($renderedData);
@@ -207,6 +209,9 @@ public function testExecuteAjaxRequestWithoutPermissions($acl, $isAllowed)
207209
->method('getData')
208210
->with('acl')
209211
->willReturn($acl);
212+
$componentMock->expects($this->any())
213+
->method('getContext')
214+
->willReturn($contextMock);
210215
$this->uiFactoryMock->expects($this->once())
211216
->method('create')
212217
->willReturn($componentMock);

app/code/Magento/Ui/Test/Unit/Model/UiComponentTypeResolverTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
use Magento\Ui\Model\UiComponentTypeResolver;
99
use Magento\Framework\View\Element\UiComponent\ContextInterface;
1010

11-
class UiComponentTypeResolverTest extends \PHPUnit\Framework\TestCase
11+
class UiComponentTypeResolverTest extends \PHPUnit_Framework_TestCase
1212
{
1313
/**
1414
* @var UiComponentTypeResolver
@@ -35,9 +35,9 @@ protected function setUp()
3535
* @param string $contentType
3636
* @dataProvider resolveDataProvider
3737
*/
38-
public function testResolve(string $acceptType, string $contentType)
38+
public function testResolve($acceptType, $contentType)
3939
{
40-
$uiComponentContextMock = $this->createMock(ContextInterface::class);
40+
$uiComponentContextMock = $this->getMock(ContextInterface::class);
4141
$uiComponentContextMock->expects($this->atLeastOnce())->method('getAcceptType')->willReturn($acceptType);
4242

4343
$this->assertEquals($contentType, $this->model->resolve($uiComponentContextMock));
@@ -46,7 +46,7 @@ public function testResolve(string $acceptType, string $contentType)
4646
/**
4747
* @return array
4848
*/
49-
public function resolveDataProvider(): array
49+
public function resolveDataProvider()
5050
{
5151
return [
5252
['json', 'application/json'],

0 commit comments

Comments
 (0)