Skip to content

Commit 6b93033

Browse files
author
Vitaliy Boyko
committed
graphQl-309: fixed tests
1 parent f90a620 commit 6b93033

File tree

2 files changed

+45
-27
lines changed

2 files changed

+45
-27
lines changed

composer.lock

Lines changed: 32 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dev/tests/api-functional/testsuite/Magento/GraphQl/CheckoutAgreements/Api/CheckoutAgreementsListTest.php

Lines changed: 13 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
use Magento\Framework\App\Config\ScopeConfigInterface;
1717
use Magento\Framework\ObjectManagerInterface;
1818
use Magento\Store\Api\Data\StoreInterface;
19-
use Magento\Store\Model\ScopeInterface;
2019
use Magento\Store\Model\StoreManagerInterface;
2120
use Magento\TestFramework\Helper\Bootstrap;
2221
use Magento\TestFramework\TestCase\GraphQlAbstract;
@@ -40,6 +39,8 @@ protected function setUp()
4039
parent::setUp();
4140

4241
$this->objectManager = Bootstrap::getObjectManager();
42+
43+
// TODO: remove usage of the Config, use ConfigFixture instead https://github.com/magento/graphql-ce/issues/167
4344
$this->config = $this->objectManager->get(Config::class);
4445
$this->saveAgreementConfig(1);
4546
}
@@ -124,29 +125,17 @@ public function testGetAgreementNotSet()
124125
/**
125126
* @magentoApiDataFixture Magento/CheckoutAgreements/_files/agreement_active_with_html_content.php
126127
* @magentoApiDataFixture Magento/CheckoutAgreements/_files/agreement_inactive_with_text_content.php
127-
* @magentoApiDataFixture Magento/Store/_files/second_store.php
128128
*/
129129
public function testDisabledAgreements()
130130
{
131-
$secondStoreCode = 'fixture_second_store';
132-
$agreementsName = 'Checkout Agreement (active)';
133-
134131
$query = $this->getQuery();
135-
$this->assignAgreementsToStore($secondStoreCode, $agreementsName);
132+
$this->saveAgreementConfig(0);
136133

137-
/** @var StoreManagerInterface $storeManager */
138-
$storeManager = $this->objectManager->get(StoreManagerInterface::class);
139-
$store = $storeManager->getStore($secondStoreCode);
140-
$this->saveAgreementConfig(0, $store);
141-
142-
$headerMap['Store'] = $secondStoreCode;
143-
$response = $this->graphQlQuery($query, [], '', $headerMap);
134+
$response = $this->graphQlQuery($query);
144135

145136
$this->assertArrayHasKey('checkoutAgreements', $response);
146137
$agreements = $response['checkoutAgreements'];
147138
$this->assertCount(0, $agreements);
148-
149-
$this->deleteAgreementConfig($store);
150139
}
151140

152141
/**
@@ -200,31 +189,29 @@ protected function tearDown()
200189
* @param int $value
201190
* @param StoreInterface $store
202191
*/
203-
private function saveAgreementConfig(int $value, ?StoreInterface $store = null): void
192+
private function saveAgreementConfig(int $value): void
204193
{
205-
$scopeId = $store ? $store->getId() : 0;
206-
$scope = $store ? ScopeInterface::SCOPE_STORE : ScopeConfigInterface::SCOPE_TYPE_DEFAULT;
207194
$this->config->saveConfig(
208195
$this->agreementsXmlConfigPath,
209196
$value,
210-
$scope,
211-
$scopeId
197+
ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
198+
0
212199
);
213200

214201
$this->reinitConfig();
215202
}
216203

217204
/**
218-
* @param StoreInterface $store
205+
* Delete config
206+
*
207+
* @return void
219208
*/
220-
private function deleteAgreementConfig(?StoreInterface $store = null): void
209+
private function deleteAgreementConfig(): void
221210
{
222-
$scopeId = $store ? $store->getId() : 0;
223-
$scope = $store ? ScopeInterface::SCOPE_STORE : ScopeConfigInterface::SCOPE_TYPE_DEFAULT;
224211
$this->config->deleteConfig(
225212
$this->agreementsXmlConfigPath,
226-
$scope,
227-
$scopeId
213+
ScopeConfigInterface::SCOPE_TYPE_DEFAULT,
214+
0
228215
);
229216

230217
$this->reinitConfig();

0 commit comments

Comments
 (0)