Skip to content

Commit

Permalink
Resolved test failures
Browse files Browse the repository at this point in the history
  • Loading branch information
Graham Wharton committed Mar 10, 2019
1 parent abf66b8 commit 36395ef
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
3 changes: 2 additions & 1 deletion app/code/Magento/Email/Model/AbstractTemplate.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,8 @@ public function __construct(
$this->templateFactory = $templateFactory;
$this->filterManager = $filterManager;
$this->urlModel = $urlModel;
$this->fileStorageDatabase = $fileStorageDatabase ?: \Magento\Framework\App\ObjectManager::getInstance()->get(Database::class);
$this->fileStorageDatabase = $fileStorageDatabase ?:
\Magento\Framework\App\ObjectManager::getInstance()->get(Database::class);
parent::__construct($context, $registry, null, null, $data);
}

Expand Down
20 changes: 18 additions & 2 deletions app/code/Magento/Email/Test/Unit/Model/BackendTemplateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ class BackendTemplateTest extends \PHPUnit\Framework\TestCase
*/
private $serializerMock;

/**
* @var \Magento\MediaStorage\Helper\File\Storage\Database|\PHPUnit_Framework_MockObject_MockObject
*/
private $databaseHelperMock;

protected function setUp()
{
$helper = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
Expand All @@ -58,14 +63,25 @@ protected function setUp()
$this->structureMock = $this->createMock(\Magento\Config\Model\Config\Structure::class);
$this->structureMock->expects($this->any())->method('getFieldPathsByAttribute')->willReturn(['path' => 'test']);

$this->databaseHelperMock = $this->createMock(\Magento\MediaStorage\Helper\File\Storage\Database::class);
$this->resourceModelMock = $this->createMock(\Magento\Email\Model\ResourceModel\Template::class);
$this->resourceModelMock->expects($this->any())->method('getSystemConfigByPathsAndTemplateId')->willReturn(['test_config' => 2015]);
/** @var ObjectManagerInterface|\PHPUnit_Framework_MockObject_MockObject $objectManagerMock*/
$objectManagerMock = $this->createMock(\Magento\Framework\ObjectManagerInterface::class);
$objectManagerMock->expects($this->any())
->method('get')
->with(\Magento\Email\Model\ResourceModel\Template::class)
->will($this->returnValue($this->resourceModelMock));
->willReturnCallback(
function ($value) {
switch($value) {
case \Magento\MediaStorage\Helper\File\Storage\Database::class:
return ($this->databaseHelperMock);
case \Magento\Email\Model\ResourceModel\Template::class:
return ($this->resourceModelMock);
default:
return(NULL);
}
}
);

\Magento\Framework\App\ObjectManager::setInstance($objectManagerMock);

Expand Down
1 change: 1 addition & 0 deletions app/code/Magento/Email/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"magento/module-cms": "102.0.*",
"magento/module-backend": "100.2.*",
"magento/module-variable": "100.2.*",
"magento/module-media-storage": "100.2.*",
"magento/framework": "101.0.*"
},
"suggest": {
Expand Down

0 comments on commit 36395ef

Please sign in to comment.