Skip to content

[Issue] Update frontend_label and apply_to in CategoryAttribute Fixture. #39942

Open
@m2-assistant

Description

@m2-assistant

This issue is automatically created based on existing pull request: #39936: Update frontend_label and apply_to in CategoryAttribute Fixture.


Description (*)

This PR aims to address issues discovered when trying to use the following fixture. app/code/Magento/Catalog/Test/Fixture/CategoryAttribute.php

  1. Using it without setting any values results in the following errror
Unable to apply fixture: Magento\Catalog\Test\Fixture\CategoryAttribute (attr)
Caused by
PHPUnit\Framework\Exception: Warning: Array to string conversion in /var/www/html/lib/internal/Magento/Framework/DB/Adapter/Pdo/Mysql.php:3337.
  1. Label does not get set as it's setting it to default_frontend_label when the value that it actually saves/loads from is frontend_label.

Changes

  1. Update apply_to to have a default of category which I took from dev/tests/api-functional/testsuite/Magento/GraphQl/CatalogGraphQl/AttributesMetadataTest.php
  2. Update default_frontend_label to frontend_label

Manual testing scenarios (*)

  1. Create an integration test with using the fixture app/code/Magento/Catalog/Test/Fixture/CategoryAttribute.php
  2. Confirm that you can create category attribute overriding any of the data such as apply_to and no errors should occur.
  3. Confirm that the test succeeds as label should not be null as it's set in the default data for given fixture.
<?php

namespace integration\testsuite\Magento\Catalog;

use Magento\Catalog\Test\Fixture\CategoryAttribute;
use Magento\TestFramework\Fixture\DataFixture;
use Magento\TestFramework\Fixture\DataFixtureStorageManager;
use PHPUnit\Framework\TestCase;

class CategoryLabelFixtureTest extends TestCase
{

    #[
        DataFixture(CategoryAttribute::class, [], as: "attr")
    ]
    public function testCategoryLabelFixture(): void
    {
        $fixture = DataFixtureStorageManager::getStorage();
        $categoryAttribute = $fixture->get('attr');
        $this->assertNotNull($categoryAttribute->getDefaultFrontendLabel());
    }
}

Questions or comments

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All new or changed code is covered with unit/integration tests (if applicable)
  • README.md files for modified modules are updated and included in the pull request if any README.md predefined sections require an update
  • All automated tests passed successfully (all builds are green)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue: ready for confirmationPriority: P3May be fixed according to the position in the backlog.Reported on 2.4.xIndicates original Magento version for the Issue report.Triage: Dev.ExperienceIssue related to Developer Experience and needs help with Triage to Confirm or Reject it

    Type

    No type

    Projects

    Status

    Ready for Development

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions