Skip to content

Magento\Catalog\Model\Category\AttributeRepository does not fulfill its service contract #5992

Open
@schmengler

Description

@schmengler

Preconditions

  1. Magento 2.1.0 ans seems still actual for 2.4-develop

Steps to reproduce

  1. Write an integration test case as follows:
public function testCategoryAttributeExists($attributeCode)
{
    $categoryAttributesRepository = \Magento\TestFramework\ObjectManager::getInstance()->get(
        \Magento\Catalog\Api\CategoryAttributeRepositoryInterface::class
    );
    $this->assertInstanceOf(
        \Magento\Catalog\Api\Data\CategoryAttributeInterface::class,
        $categoryAttributesRepository->get($attributeCode)
    );
}
  1. Pass an existing attribute code via data provider
  2. Run the test

Expected result

  1. The test passes, because the contract of Magento\Catalog\Api\CategoryAttributeRepositoryInterface states:
    /**
     * Retrieve specific attribute
     *
     * @param string $attributeCode
     * @return \Magento\Catalog\Api\Data\CategoryAttributeInterface
     */
    public function get($attributeCode);

Actual result

  1. The test fails with a message like this

Failed asserting that Magento\Catalog\Model\ResourceModel\Eav\Attribute\Interceptor Object (...) is an instance of interface "Magento\Catalog\Api\Data\CategoryAttributeInterface".

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area: CatalogComponent: CatalogIssue: ConfirmedGate 3 Passed. Manual verification of the issue completed. Issue is confirmedPriority: P2A defect with this priority could have functionality issues which are not to expectations.Progress: ready for devReproduced on 2.4.xThe issue has been reproduced on latest 2.4-develop branchSeverity: S2Major restrictions or short-term circumventions are required until a fix is available.Triage: Dev.ExperienceIssue related to Developer Experience and needs help with Triage to Confirm or Reject itbug report

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions