|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +namespace Meta\BusinessExtension\Test\Unit\Api; |
| 6 | + |
| 7 | +use PHPUnit\Framework\TestCase; |
| 8 | +use Meta\BusinessExtension\Model\Api\CoreConfig; |
| 9 | + |
| 10 | +class CoreConfigTest extends TestCase |
| 11 | +{ |
| 12 | + /** |
| 13 | + * @var CoreConfig |
| 14 | + */ |
| 15 | + private $metaCoreConfig; |
| 16 | + |
| 17 | + /** |
| 18 | + * Class setup function |
| 19 | + * |
| 20 | + * @return void |
| 21 | + */ |
| 22 | + protected function setup(): void |
| 23 | + { |
| 24 | + parent::setup(); |
| 25 | + |
| 26 | + $this->metaCoreConfig = $this->getMockBuilder(CoreConfig::class) |
| 27 | + ->disableOriginalConstructor() |
| 28 | + ->getMock(); |
| 29 | + } |
| 30 | + |
| 31 | + /** |
| 32 | + * Validate if the external business ID is empty |
| 33 | + * |
| 34 | + * @return void |
| 35 | + */ |
| 36 | + public function testGetExternalBusinessId(): void |
| 37 | + { |
| 38 | + $this->metaCoreConfig->method('getExternalBusinessId') |
| 39 | + ->willReturn(''); |
| 40 | + |
| 41 | + $this->assertEmpty($this->metaCoreConfig->getExternalBusinessId()); |
| 42 | + } |
| 43 | + |
| 44 | + /** |
| 45 | + * Validate if the external business ID is set |
| 46 | + * |
| 47 | + * @return void |
| 48 | + */ |
| 49 | + public function testSetExternalBusinessId(): void |
| 50 | + { |
| 51 | + $businessId = 'ZmJfaWRfMQ=='; |
| 52 | + $this->metaCoreConfig->setExternalBusinessId($businessId); |
| 53 | + $this->metaCoreConfig->method('getExternalBusinessId') |
| 54 | + ->willReturn($businessId); |
| 55 | + |
| 56 | + $this->assertSame($businessId, $this->metaCoreConfig->getExternalBusinessId()); |
| 57 | + } |
| 58 | + |
| 59 | + /** |
| 60 | + * Validate if the order sync is enabled |
| 61 | + * |
| 62 | + * @return void |
| 63 | + */ |
| 64 | + public function testSetIsOrderSyncEnabled(): void |
| 65 | + { |
| 66 | + $isOrderSyncEnabled = true; |
| 67 | + $this->metaCoreConfig->setIsOrderSyncEnabled($isOrderSyncEnabled); |
| 68 | + |
| 69 | + $this->metaCoreConfig->method('isOrderSyncEnabled') |
| 70 | + ->willReturn($isOrderSyncEnabled); |
| 71 | + |
| 72 | + $this->assertSame($isOrderSyncEnabled, $this->metaCoreConfig->isOrderSyncEnabled()); |
| 73 | + } |
| 74 | + |
| 75 | + /** |
| 76 | + * Validate if the catalog sync is enabled |
| 77 | + * |
| 78 | + * @return void |
| 79 | + */ |
| 80 | + public function testSetIsCatalogSyncEnabled(): void |
| 81 | + { |
| 82 | + $isCatalogSyncEnabled = true; |
| 83 | + $this->metaCoreConfig->setIsCatalogSyncEnabled($isCatalogSyncEnabled); |
| 84 | + |
| 85 | + $this->metaCoreConfig->method('isCatalogSyncEnabled') |
| 86 | + ->willReturn($isCatalogSyncEnabled); |
| 87 | + |
| 88 | + $this->assertSame($isCatalogSyncEnabled, $this->metaCoreConfig->isCatalogSyncEnabled()); |
| 89 | + } |
| 90 | + |
| 91 | + /** |
| 92 | + * Validate if the Promotion sync is enabled |
| 93 | + * |
| 94 | + * @return void |
| 95 | + */ |
| 96 | + public function testSetIsPromotionsSyncEnabled(): void |
| 97 | + { |
| 98 | + $isPromotionsSyncEnabled = true; |
| 99 | + $this->metaCoreConfig->setIsPromotionsSyncEnabled($isPromotionsSyncEnabled); |
| 100 | + |
| 101 | + $this->metaCoreConfig->method('isPromotionsSyncEnabled') |
| 102 | + ->willReturn($isPromotionsSyncEnabled); |
| 103 | + |
| 104 | + $this->assertSame($isPromotionsSyncEnabled, $this->metaCoreConfig->isPromotionsSyncEnabled()); |
| 105 | + } |
| 106 | + |
| 107 | + /** |
| 108 | + * Validate if the extension is active |
| 109 | + * |
| 110 | + * @return void |
| 111 | + */ |
| 112 | + public function testSetIsActiveExtension(): void |
| 113 | + { |
| 114 | + $isActiveExtension = true; |
| 115 | + $this->metaCoreConfig->setIsActiveExtension($isActiveExtension); |
| 116 | + |
| 117 | + $this->metaCoreConfig->method('isActiveExtension') |
| 118 | + ->willReturn($isActiveExtension); |
| 119 | + |
| 120 | + $this->assertSame($isActiveExtension, $this->metaCoreConfig->isActiveExtension()); |
| 121 | + } |
| 122 | + |
| 123 | + /** |
| 124 | + * Validate if the product identifier attribute is set |
| 125 | + * |
| 126 | + * @return void |
| 127 | + */ |
| 128 | + public function testSetProductIdentifierAttr(): void |
| 129 | + { |
| 130 | + $productIdentifierAttr = 'sku'; |
| 131 | + $this->metaCoreConfig->setProductIdentifierAttr($productIdentifierAttr); |
| 132 | + |
| 133 | + $this->metaCoreConfig->method('getProductIdentifierAttr') |
| 134 | + ->willReturn($productIdentifierAttr); |
| 135 | + |
| 136 | + $this->assertSame($productIdentifierAttr, $this->metaCoreConfig->getProductIdentifierAttr()); |
| 137 | + } |
| 138 | + |
| 139 | + /** |
| 140 | + * Validate if the product stock threashold is set |
| 141 | + * |
| 142 | + * @return void |
| 143 | + */ |
| 144 | + public function testSetOutOfStockThreshold(): void |
| 145 | + { |
| 146 | + $outOfStockThreshold = '10'; |
| 147 | + $this->metaCoreConfig->setOutOfStockThreshold($outOfStockThreshold); |
| 148 | + |
| 149 | + $this->metaCoreConfig->method('getOutOfStockThreshold') |
| 150 | + ->willReturn($outOfStockThreshold); |
| 151 | + |
| 152 | + $this->assertSame($outOfStockThreshold, $this->metaCoreConfig->getOutOfStockThreshold()); |
| 153 | + } |
| 154 | + |
| 155 | + /** |
| 156 | + * Validate if the feed ID is set |
| 157 | + * |
| 158 | + * @return void |
| 159 | + */ |
| 160 | + public function testSetFeedId(): void |
| 161 | + { |
| 162 | + $feedId = 'feed-id'; |
| 163 | + $this->metaCoreConfig->setFeedId($feedId); |
| 164 | + |
| 165 | + $this->metaCoreConfig->method('getFeedId') |
| 166 | + ->willReturn($feedId); |
| 167 | + |
| 168 | + $this->assertSame($feedId, $this->metaCoreConfig->getFeedId()); |
| 169 | + } |
| 170 | + |
| 171 | + /** |
| 172 | + * Validate if the installed meta extension version is set |
| 173 | + * |
| 174 | + * @return void |
| 175 | + */ |
| 176 | + public function testSetInstalledMetaExtensionVersion(): void |
| 177 | + { |
| 178 | + $version = '1.0.0'; |
| 179 | + $this->metaCoreConfig->setInstalledMetaExtensionVersion($version); |
| 180 | + |
| 181 | + $this->metaCoreConfig->method('getInstalledMetaExtensionVersion') |
| 182 | + ->willReturn($version); |
| 183 | + |
| 184 | + $this->assertSame($version, $this->metaCoreConfig->getInstalledMetaExtensionVersion()); |
| 185 | + } |
| 186 | + |
| 187 | + /** |
| 188 | + * Validate if the Graph API version is set |
| 189 | + * |
| 190 | + * @return void |
| 191 | + */ |
| 192 | + public function testSetGraphApiVersion(): void |
| 193 | + { |
| 194 | + $graphApiVersion = 'v1.0'; |
| 195 | + $this->metaCoreConfig->setGraphApiVersion($graphApiVersion); |
| 196 | + |
| 197 | + $this->metaCoreConfig->method('getGraphApiVersion') |
| 198 | + ->willReturn($graphApiVersion); |
| 199 | + |
| 200 | + $this->assertSame($graphApiVersion, $this->metaCoreConfig->getGraphApiVersion()); |
| 201 | + } |
| 202 | + |
| 203 | + /** |
| 204 | + * Validate if the Graph API version is set |
| 205 | + * |
| 206 | + * @return void |
| 207 | + */ |
| 208 | + public function testSetMagentoVersion(): void |
| 209 | + { |
| 210 | + $magentoVersion = '2.4.5'; |
| 211 | + $this->metaCoreConfig->setMagentoVersion($magentoVersion); |
| 212 | + |
| 213 | + $this->metaCoreConfig->method('getMagentoVersion') |
| 214 | + ->willReturn($magentoVersion); |
| 215 | + |
| 216 | + $this->assertSame($magentoVersion, $this->metaCoreConfig->getMagentoVersion()); |
| 217 | + } |
| 218 | +} |
0 commit comments