Skip to content

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

@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

    Type

    No type

    Projects

    Status

    No status

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions