|
10 | 10 | use Magento\Customer\Api\AddressMetadataInterface;
|
11 | 11 | use Magento\Customer\Test\Fixture\CustomerAttribute;
|
12 | 12 | use Magento\Eav\Api\Data\AttributeInterface;
|
| 13 | +use Magento\Store\Api\Data\StoreInterface; |
| 14 | +use Magento\Store\Test\Fixture\Group as StoreGroupFixture; |
| 15 | +use Magento\Store\Test\Fixture\Store as StoreFixture; |
| 16 | +use Magento\Store\Test\Fixture\Website as WebsiteFixture; |
13 | 17 | use Magento\TestFramework\Fixture\DataFixture;
|
14 | 18 | use Magento\TestFramework\Fixture\DataFixtureStorageManager;
|
15 | 19 | use Magento\TestFramework\TestCase\GraphQlAbstract;
|
@@ -123,4 +127,58 @@ public function testAttributesFormDoesNotExist(): void
|
123 | 127 | $this->graphQlQuery(sprintf(self::QUERY, 'not_existing_form'))
|
124 | 128 | );
|
125 | 129 | }
|
| 130 | + |
| 131 | + #[ |
| 132 | + DataFixture(WebsiteFixture::class, as: 'website2'), |
| 133 | + DataFixture(StoreGroupFixture::class, ['website_id' => '$website2.id$'], 'store_group2'), |
| 134 | + DataFixture(StoreFixture::class, ['store_group_id' => '$store_group2.id$'], 'store2'), |
| 135 | + DataFixture( |
| 136 | + CustomerAttribute::class, |
| 137 | + [ |
| 138 | + 'entity_type_id' => AddressMetadataInterface::ATTRIBUTE_SET_ID_ADDRESS, |
| 139 | + 'used_in_forms' => ['customer_register_address'], |
| 140 | + 'website_id' => '$website2.id$', |
| 141 | + 'scope_is_visible' => 1, |
| 142 | + 'is_visible' => 0, |
| 143 | + ], |
| 144 | + 'attribute_1' |
| 145 | + ), |
| 146 | + ] |
| 147 | + public function testAttributesFormScope(): void |
| 148 | + { |
| 149 | + /** @var AttributeInterface $attribute1 */ |
| 150 | + $attribute1 = DataFixtureStorageManager::getStorage()->get('attribute_1'); |
| 151 | + |
| 152 | + $result = $this->graphQlQuery(sprintf(self::QUERY, 'customer_register_address')); |
| 153 | + |
| 154 | + foreach ($result['attributesForm']['items'] as $item) { |
| 155 | + if (array_contains($item, $attribute1->getAttributeCode())) { |
| 156 | + $this->fail( |
| 157 | + sprintf("Attribute '%s' found in query response in global scope", $attribute1->getAttributeCode()) |
| 158 | + ); |
| 159 | + } |
| 160 | + } |
| 161 | + |
| 162 | + /** @var StoreInterface $store */ |
| 163 | + $store = DataFixtureStorageManager::getStorage()->get('store2'); |
| 164 | + |
| 165 | + $result = $this->graphQlQuery( |
| 166 | + sprintf(self::QUERY, 'customer_register_address'), |
| 167 | + [], |
| 168 | + '', |
| 169 | + ['Store' => $store->getCode()] |
| 170 | + ); |
| 171 | + |
| 172 | + foreach ($result['attributesForm']['items'] as $item) { |
| 173 | + if (array_contains($item, $attribute1->getAttributeCode())) { |
| 174 | + return; |
| 175 | + } |
| 176 | + } |
| 177 | + $this->fail( |
| 178 | + sprintf( |
| 179 | + "Attribute '%s' not found in query response in website scope", |
| 180 | + $attribute1->getAttributeCode() |
| 181 | + ) |
| 182 | + ); |
| 183 | + } |
126 | 184 | }
|
0 commit comments