8 use Symfony\Component\Console\Tester\CommandTester;
25 private $objectManager;
30 private $attributeResource;
32 public function setUp()
35 $this->command = $this->objectManager->create(\
Magento\Catalog\Console\Command\ProductAttributesCleanUp::class);
36 $this->attributeResource = $this->objectManager->create(\
Magento\Catalog\Model\
ResourceModel\Attribute::class);
37 $this->tester =
new CommandTester($this->command);
40 $store = $this->prepareAdditionalStore();
44 $product->setName(
'Simple fixture store');
58 $attribute = $this->getUnusedProductAttribute();
61 $this->assertArrayHasKey(
'value_id',
$attribute);
62 $this->assertEquals(
$attribute[
'value'],
'Simple fixture store');
65 $this->tester->execute([]);
68 $this->assertContains(
'Unused product attributes successfully cleaned up', $this->tester->getDisplay());
69 $attribute = $this->getUnusedProductAttribute();
76 private function getUnusedProductAttribute()
78 $connection = $this->attributeResource->getConnection();
80 $select->from($this->attributeResource->getTable(
'catalog_product_entity_varchar'));
81 $select->where(
'value = ?',
'Simple fixture store');
88 private function prepareAdditionalStore()
91 $website = $this->objectManager->create(\
Magento\Store\Model\Website::class);
95 $store = $this->objectManager->create(\
Magento\Store\Model\Store::class);
96 $store->load(
'fixturestore');
static getObjectManager()