ConfigurableProductFrontendLabelAttributeTest.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. declare(strict_types=1);
  7. namespace Magento\GraphQl\ConfigurableProduct;
  8. use Magento\TestFramework\TestCase\GraphQlAbstract;
  9. /**
  10. * Class ConfigurableProductFrontendLabelAttributeTest
  11. *
  12. * @package Magento\GraphQl\ConfigurableProduct
  13. */
  14. class ConfigurableProductFrontendLabelAttributeTest extends GraphQlAbstract
  15. {
  16. /**
  17. * @magentoApiDataFixture Magento/ConfigurableProduct/_files/product_configurable_with_frontend_label_attribute.php
  18. */
  19. public function testGetFrontendLabelAttribute()
  20. {
  21. $expectLabelValue = 'Default Store View label';
  22. $productSku = 'configurable';
  23. $query = <<<QUERY
  24. {
  25. products(filter: {sku: {eq: "{$productSku}"}}) {
  26. items {
  27. name
  28. ... on ConfigurableProduct{
  29. configurable_options{
  30. id
  31. label
  32. }
  33. }
  34. }
  35. }
  36. }
  37. QUERY;
  38. $response = $this->graphQlQuery($query);
  39. $this->assertArrayHasKey('products', $response);
  40. $this->assertArrayHasKey('items', $response['products']);
  41. $this->assertArrayHasKey(0, $response['products']['items']);
  42. $product = $response['products']['items'][0];
  43. $this->assertArrayHasKey('configurable_options', $product);
  44. $this->assertArrayHasKey(0, $product['configurable_options']);
  45. $this->assertArrayHasKey('label', $product['configurable_options'][0]);
  46. $option = $product['configurable_options'][0];
  47. $this->assertEquals($expectLabelValue, $option['label']);
  48. }
  49. }