Skip to content

Commit 1c1c706

Browse files
committed
MAGETWO-62648: [Github] Parameters from website configuration isn't applied to the corresponding store view
1 parent 40fd024 commit 1c1c706

File tree

2 files changed

+92
-0
lines changed

2 files changed

+92
-0
lines changed
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
<?php
2+
3+
namespace Magento\Review\Block;
4+
5+
use Magento\Framework\App\Area;
6+
use Magento\Framework\App\Config\Value;
7+
use Magento\Framework\App\ReinitableConfig;
8+
use Magento\Framework\App\State;
9+
use Magento\TestFramework\ObjectManager;
10+
11+
class FormTest extends \PHPUnit_Framework_TestCase
12+
{
13+
/**
14+
* @var ObjectManager;
15+
*/
16+
private $objectManager;
17+
18+
protected function setUp()
19+
{
20+
$this->objectManager = $this->getObjectManager();
21+
22+
parent::setUp();
23+
}
24+
25+
/**
26+
* @magentoDbIsolation enabled
27+
* @magentoDataFixture Magento/Review/_files/config.php
28+
* @dataProvider getCorrectFlagDataProvider
29+
*/
30+
public function testGetCorrectFlag(
31+
$path,
32+
$scope,
33+
$scopeId,
34+
$value,
35+
$expectedResult
36+
) {
37+
/** @var State $appState */
38+
$appState = $this->objectManager->get(State::class);
39+
$appState->setAreaCode(Area::AREA_FRONTEND);
40+
41+
/** @var Value $config */
42+
$config = $this->objectManager->create(Value::class);
43+
$config->setPath($path);
44+
$config->setScope($scope);
45+
$config->setScopeId($scopeId);
46+
$config->setValue($value);
47+
$config->save();
48+
/** @var ReinitableConfig $reinitableConfig */
49+
$reinitableConfig = $this->objectManager->create(ReinitableConfig::class);
50+
$reinitableConfig->reinit();
51+
52+
/** @var \Magento\Review\Block\Form $form */
53+
$form = $this->objectManager->create(\Magento\Review\Block\Form::class);
54+
$result = $form->getAllowWriteReviewFlag();
55+
$this->assertEquals($result, $expectedResult);
56+
}
57+
58+
public function getCorrectFlagDataProvider()
59+
{
60+
return [
61+
[
62+
'path' => 'catalog/review/allow_guest',
63+
'scope' => 'websites',
64+
'scopeId' => '1',
65+
'value' => 0,
66+
'expectedResult' => false,
67+
],
68+
[
69+
'path' => 'catalog/review/allow_guest',
70+
'scope' => 'websites',
71+
'scopeId' => '1',
72+
'value' => 1,
73+
'expectedResult' => true
74+
]
75+
];
76+
}
77+
78+
private function getObjectManager()
79+
{
80+
return \Magento\TestFramework\Helper\Bootstrap::getObjectManager();
81+
}
82+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
/** @var Value $config */
3+
use Magento\Framework\App\Config\Value;
4+
5+
$config = \Magento\TestFramework\Helper\Bootstrap::getObjectManager()->create(Value::class);
6+
$config->setPath('catalog/review/allow_guest');
7+
$config->setScope('default');
8+
$config->setScopeId(0);
9+
$config->setValue(1);
10+
$config->save();

0 commit comments

Comments
 (0)