From e6ae0ef11a9096b56f4706fefa6d92be319ba814 Mon Sep 17 00:00:00 2001 From: Oleksandr Kravchuk Date: Thu, 18 Nov 2021 19:44:37 +0200 Subject: [PATCH] run-as-root/magento2-prometheus-exporter#24: Fix code review notices. --- .../Category/CategoryCountAggregatorTest.php | 36 +++++++++---------- .../Shipment/ShipmentCountAggregatorTest.php | 18 +++++----- 2 files changed, 27 insertions(+), 27 deletions(-) diff --git a/Test/Unit/Aggregator/Category/CategoryCountAggregatorTest.php b/Test/Unit/Aggregator/Category/CategoryCountAggregatorTest.php index 63de4a6..3bb5a02 100644 --- a/Test/Unit/Aggregator/Category/CategoryCountAggregatorTest.php +++ b/Test/Unit/Aggregator/Category/CategoryCountAggregatorTest.php @@ -18,11 +18,11 @@ final class CategoryCountAggregatorTest extends TestCase { private const METRIC_CODE = 'magento_catalog_category_count_total'; - private const T_ATT = 'm2_eav_attribute'; - private const T_CAT_ENT_INT = 'm2_catalog_category_entity_int'; - private const T_CAT_ENT = 'm2_catalog_category_entity'; - private const T_STORE_GROUP = 'm2_store_group'; - private const T_STORE = 'm2_store'; + private const TABLE_ATT = 'm2_eav_attribute'; + private const TABLE_CAT_ENT_INT = 'm2_catalog_category_entity_int'; + private const TABLE_CAT_ENT = 'm2_catalog_category_entity'; + private const TABLE_STORE_GROUP = 'm2_store_group'; + private const TABLE_STORE = 'm2_store'; private const LINK_FIELD = 'row_id'; private const ATTR_ID = 77; @@ -90,7 +90,7 @@ private function getSelectMock(): MockObject $select = $this->createMock(Select::class); $select->expects($this->exactly(3))->method('from') - ->withConsecutive([self::T_ATT], [self::T_ATT], [["sg" => self::T_STORE_GROUP]])->willReturn($select); + ->withConsecutive([self::TABLE_ATT], [self::TABLE_ATT], [["sg" => self::TABLE_STORE_GROUP]])->willReturn($select); $select->expects($this->exactly(4))->method('where') ->withConsecutive( @@ -107,15 +107,15 @@ private function getSelectMock(): MockObject $select->expects($this->exactly(3))->method('joinInner') ->withConsecutive( [ - ['s' => self::T_STORE], + ['s' => self::TABLE_STORE], 'sg.group_id = s.group_id' ], [ - ['cce1' => self::T_CAT_ENT], + ['cce1' => self::TABLE_CAT_ENT], 'sg.root_category_id = cce1.entity_id' ], [ - ['cce2' => self::T_CAT_ENT], + ['cce2' => self::TABLE_CAT_ENT], "cce2.path like CONCAT(cce1.path, '%')" ] )->willReturn($select); @@ -123,7 +123,7 @@ private function getSelectMock(): MockObject $select->expects($this->exactly(4))->method('joinLeft') ->withConsecutive( [ - ['ccei1' => self::T_CAT_ENT_INT], + ['ccei1' => self::TABLE_CAT_ENT_INT], sprintf( "cce2.%s = ccei1.%s AND ccei1.attribute_id = %s AND ccei1.store_id = s.store_id", self::LINK_FIELD, @@ -132,7 +132,7 @@ private function getSelectMock(): MockObject ) ], [ - ['ccei2' => self::T_CAT_ENT_INT], + ['ccei2' => self::TABLE_CAT_ENT_INT], sprintf( "cce2.%s = ccei2.%s AND ccei2.attribute_id = %s AND ccei2.store_id = 0", self::LINK_FIELD, @@ -141,7 +141,7 @@ private function getSelectMock(): MockObject ) ], [ - ['ccei3' => self::T_CAT_ENT_INT], + ['ccei3' => self::TABLE_CAT_ENT_INT], sprintf( "cce2.%s = ccei3.%s AND ccei3.attribute_id = %s AND ccei3.store_id = s.store_id", self::LINK_FIELD, @@ -150,7 +150,7 @@ private function getSelectMock(): MockObject ) ], [ - ['ccei4' => self::T_CAT_ENT_INT], + ['ccei4' => self::TABLE_CAT_ENT_INT], sprintf( "cce2.%s = ccei4.%s AND ccei4.attribute_id = %s AND ccei4.store_id = 0", self::LINK_FIELD, @@ -206,11 +206,11 @@ private function getExpressionsMap(Expression $expressionMock): array private function getTableNamesMap(): array { return [ - ['eav_attribute', self::T_ATT], - ['catalog_category_entity_int', self::T_CAT_ENT_INT], - ['catalog_category_entity', self::T_CAT_ENT], - ['store', self::T_STORE], - ['store_group', self::T_STORE_GROUP], + ['eav_attribute', self::TABLE_ATT], + ['catalog_category_entity_int', self::TABLE_CAT_ENT_INT], + ['catalog_category_entity', self::TABLE_CAT_ENT], + ['store', self::TABLE_STORE], + ['store_group', self::TABLE_STORE_GROUP], ]; } diff --git a/Test/Unit/Aggregator/Shipment/ShipmentCountAggregatorTest.php b/Test/Unit/Aggregator/Shipment/ShipmentCountAggregatorTest.php index c37b31a..50eb373 100644 --- a/Test/Unit/Aggregator/Shipment/ShipmentCountAggregatorTest.php +++ b/Test/Unit/Aggregator/Shipment/ShipmentCountAggregatorTest.php @@ -13,9 +13,9 @@ final class ShipmentCountAggregatorTest extends TestCase { private const METRIC_CODE = 'magento_shipments_count_total'; - private const T_SHIP = 'm2_sales_shipment'; - private const T_INV_SHIP = 'm2_inventory_shipment_source'; - private const T_STORE = 'm2_store'; + private const TABLE_SHIP = 'm2_sales_shipment'; + private const TABLE_INV_SHIP = 'm2_inventory_shipment_source'; + private const TABLE_STORE = 'm2_store'; private ShipmentCountAggregator $subject; @@ -62,19 +62,19 @@ private function getSelectMock(): MockObject $select = $this->createMock(Select::class); $select->expects($this->once()) ->method('from') - ->with(['ss' => self::T_SHIP]) + ->with(['ss' => self::TABLE_SHIP]) ->willReturn($select); $select->expects($this->exactly(2)) ->method('joinInner') ->withConsecutive( [ - ['iss' => self::T_INV_SHIP], + ['iss' => self::TABLE_INV_SHIP], 'ss.entity_id = iss.shipment_id', ['source_code'] ], [ - ['s' => self::T_STORE], + ['s' => self::TABLE_STORE], 'ss.store_id = s.store_id', ['code'] ] @@ -110,9 +110,9 @@ public function testAggregate(): void ->method('getTableName') ->willReturnMap( [ - ['sales_shipment', self::T_SHIP], - ['inventory_shipment_source', self::T_INV_SHIP], - ['store', self::T_STORE] + ['sales_shipment', self::TABLE_SHIP], + ['inventory_shipment_source', self::TABLE_INV_SHIP], + ['store', self::TABLE_STORE] ] );