Open
Description
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
- 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.
- Label does not get set as it's setting it to
default_frontend_label
when the value that it actually saves/loads from isfrontend_label
.
Changes
- Update
apply_to
to have a default ofcategory
which I took fromdev/tests/api-functional/testsuite/Magento/GraphQl/CatalogGraphQl/AttributesMetadataTest.php
- Update
default_frontend_label
tofrontend_label
Manual testing scenarios (*)
- Create an integration test with using the fixture
app/code/Magento/Catalog/Test/Fixture/CategoryAttribute.php
- Confirm that you can create category attribute overriding any of the data such as
apply_to
and no errors should occur. - 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 purposeAll commits are accompanied by meaningful commit messagesAll 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 updateAll automated tests passed successfully (all builds are green)
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Ready for Development
Activity