|
8 | 8 |
|
9 | 9 | namespace Magento\Catalog\Model;
|
10 | 10 |
|
11 |
| -use Magento\Eav\Model\Config as EavConfig; |
12 |
| -use Magento\Catalog\Model\Product; |
13 |
| -use Magento\Framework\App\Filesystem\DirectoryList; |
14 |
| -use Magento\TestFramework\ObjectManager; |
15 | 11 | use Magento\Catalog\Api\ProductRepositoryInterface;
|
16 | 12 | use Magento\Catalog\Model\Product\Attribute\Source\Status;
|
| 13 | +use Magento\Catalog\Model\Product\Visibility; |
| 14 | +use Magento\Framework\App\Filesystem\DirectoryList; |
| 15 | +use Magento\Framework\Exception\CouldNotSaveException; |
| 16 | +use Magento\Framework\Exception\InputException; |
| 17 | +use Magento\Framework\Exception\LocalizedException; |
| 18 | +use Magento\Framework\Exception\NoSuchEntityException; |
| 19 | +use Magento\Framework\Exception\StateException; |
| 20 | +use Magento\Framework\Math\Random; |
17 | 21 | use Magento\Framework\ObjectManagerInterface;
|
18 | 22 | use Magento\TestFramework\Helper\Bootstrap;
|
| 23 | +use Magento\TestFramework\ObjectManager; |
19 | 24 |
|
20 | 25 | /**
|
21 | 26 | * Tests product model:
|
@@ -119,14 +124,62 @@ public function testCRUD()
|
119 | 124 | )->setMetaDescription(
|
120 | 125 | 'meta description'
|
121 | 126 | )->setVisibility(
|
122 |
| - \Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH |
| 127 | + Visibility::VISIBILITY_BOTH |
123 | 128 | )->setStatus(
|
124 |
| - \Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED |
| 129 | + Status::STATUS_ENABLED |
125 | 130 | );
|
126 | 131 | $crud = new \Magento\TestFramework\Entity($this->_model, ['sku' => uniqid()]);
|
127 | 132 | $crud->testCrud();
|
128 | 133 | }
|
129 | 134 |
|
| 135 | + /** |
| 136 | + * Test for Product Description field to be able to contain >64kb of data |
| 137 | + * |
| 138 | + * @magentoDbIsolation enabled |
| 139 | + * @magentoAppIsolation enabled |
| 140 | + * @magentoAppArea adminhtml |
| 141 | + * @throws NoSuchEntityException |
| 142 | + * @throws CouldNotSaveException |
| 143 | + * @throws InputException |
| 144 | + * @throws StateException |
| 145 | + * @throws LocalizedException |
| 146 | + */ |
| 147 | + public function testMaximumDescriptionLength() |
| 148 | + { |
| 149 | + $sku = uniqid(); |
| 150 | + $random = Bootstrap::getObjectManager()->get(Random::class); |
| 151 | + $longDescription = $random->getRandomString(70000); |
| 152 | + |
| 153 | + $this->_model->setTypeId( |
| 154 | + 'simple' |
| 155 | + )->setAttributeSetId( |
| 156 | + 4 |
| 157 | + )->setName( |
| 158 | + 'Simple Product With Long Description' |
| 159 | + )->setDescription( |
| 160 | + $longDescription |
| 161 | + )->setSku( |
| 162 | + $sku |
| 163 | + )->setPrice( |
| 164 | + 10 |
| 165 | + )->setMetaTitle( |
| 166 | + 'meta title' |
| 167 | + )->setMetaKeyword( |
| 168 | + 'meta keyword' |
| 169 | + )->setMetaDescription( |
| 170 | + 'meta description' |
| 171 | + )->setVisibility( |
| 172 | + Visibility::VISIBILITY_BOTH |
| 173 | + )->setStatus( |
| 174 | + Status::STATUS_ENABLED |
| 175 | + ); |
| 176 | + |
| 177 | + $this->productRepository->save($this->_model); |
| 178 | + $product = $this->productRepository->get($sku); |
| 179 | + |
| 180 | + $this->assertEquals($longDescription, $product->getDescription()); |
| 181 | + } |
| 182 | + |
130 | 183 | /**
|
131 | 184 | * Test clean cache
|
132 | 185 | *
|
@@ -219,7 +272,7 @@ public function testDuplicate()
|
219 | 272 | $this->assertNotEquals($duplicate->getId(), $this->_model->getId());
|
220 | 273 | $this->assertNotEquals($duplicate->getSku(), $this->_model->getSku());
|
221 | 274 | $this->assertEquals(
|
222 |
| - \Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_DISABLED, |
| 275 | + Status::STATUS_DISABLED, |
223 | 276 | $duplicate->getStatus()
|
224 | 277 | );
|
225 | 278 | $this->assertEquals(\Magento\Store\Model\Store::DEFAULT_STORE_ID, $duplicate->getStoreId());
|
@@ -275,35 +328,35 @@ protected function _undo($duplicate)
|
275 | 328 | public function testVisibilityApi()
|
276 | 329 | {
|
277 | 330 | $this->assertEquals(
|
278 |
| - [\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED], |
| 331 | + [Status::STATUS_ENABLED], |
279 | 332 | $this->_model->getVisibleInCatalogStatuses()
|
280 | 333 | );
|
281 | 334 | $this->assertEquals(
|
282 |
| - [\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED], |
| 335 | + [Status::STATUS_ENABLED], |
283 | 336 | $this->_model->getVisibleStatuses()
|
284 | 337 | );
|
285 | 338 |
|
286 |
| - $this->_model->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_DISABLED); |
| 339 | + $this->_model->setStatus(Status::STATUS_DISABLED); |
287 | 340 | $this->assertFalse($this->_model->isVisibleInCatalog());
|
288 | 341 |
|
289 |
| - $this->_model->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED); |
| 342 | + $this->_model->setStatus(Status::STATUS_ENABLED); |
290 | 343 | $this->assertTrue($this->_model->isVisibleInCatalog());
|
291 | 344 |
|
292 | 345 | $this->assertEquals(
|
293 | 346 | [
|
294 |
| - \Magento\Catalog\Model\Product\Visibility::VISIBILITY_IN_SEARCH, |
295 |
| - \Magento\Catalog\Model\Product\Visibility::VISIBILITY_IN_CATALOG, |
296 |
| - \Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH, |
| 347 | + Visibility::VISIBILITY_IN_SEARCH, |
| 348 | + Visibility::VISIBILITY_IN_CATALOG, |
| 349 | + Visibility::VISIBILITY_BOTH, |
297 | 350 | ],
|
298 | 351 | $this->_model->getVisibleInSiteVisibilities()
|
299 | 352 | );
|
300 | 353 |
|
301 | 354 | $this->assertFalse($this->_model->isVisibleInSiteVisibility());
|
302 |
| - $this->_model->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_IN_SEARCH); |
| 355 | + $this->_model->setVisibility(Visibility::VISIBILITY_IN_SEARCH); |
303 | 356 | $this->assertTrue($this->_model->isVisibleInSiteVisibility());
|
304 |
| - $this->_model->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_IN_CATALOG); |
| 357 | + $this->_model->setVisibility(Visibility::VISIBILITY_IN_CATALOG); |
305 | 358 | $this->assertTrue($this->_model->isVisibleInSiteVisibility());
|
306 |
| - $this->_model->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH); |
| 359 | + $this->_model->setVisibility(Visibility::VISIBILITY_BOTH); |
307 | 360 | $this->assertTrue($this->_model->isVisibleInSiteVisibility());
|
308 | 361 | }
|
309 | 362 |
|
@@ -509,9 +562,9 @@ public function testValidate()
|
509 | 562 | )->setMetaDescription(
|
510 | 563 | 'meta description'
|
511 | 564 | )->setVisibility(
|
512 |
| - \Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH |
| 565 | + Visibility::VISIBILITY_BOTH |
513 | 566 | )->setStatus(
|
514 |
| - \Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED |
| 567 | + Status::STATUS_ENABLED |
515 | 568 | )->setCollectExceptionMessages(
|
516 | 569 | true
|
517 | 570 | );
|
@@ -551,9 +604,9 @@ public function testValidateUniqueInputAttributeValue()
|
551 | 604 | $attribute->getAttributeCode(),
|
552 | 605 | 'unique value'
|
553 | 606 | )->setVisibility(
|
554 |
| - \Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH |
| 607 | + Visibility::VISIBILITY_BOTH |
555 | 608 | )->setStatus(
|
556 |
| - \Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED |
| 609 | + Status::STATUS_ENABLED |
557 | 610 | )->setCollectExceptionMessages(
|
558 | 611 | true
|
559 | 612 | );
|
@@ -600,9 +653,9 @@ public function testValidateUniqueInputAttributeOnTheSameProduct()
|
600 | 653 | $attribute->getAttributeCode(),
|
601 | 654 | 'unique value'
|
602 | 655 | )->setVisibility(
|
603 |
| - \Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH |
| 656 | + Visibility::VISIBILITY_BOTH |
604 | 657 | )->setStatus(
|
605 |
| - \Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED |
| 658 | + Status::STATUS_ENABLED |
606 | 659 | )->setCollectExceptionMessages(
|
607 | 660 | true
|
608 | 661 | );
|
@@ -675,10 +728,10 @@ public function testSaveWithBackordersEnabled(int $qty, int $stockStatus, bool $
|
675 | 728 | * @magentoDataFixture Magento/Catalog/_files/product_simple.php
|
676 | 729 | *
|
677 | 730 | * @return void
|
678 |
| - * @throws \Magento\Framework\Exception\CouldNotSaveException |
679 |
| - * @throws \Magento\Framework\Exception\InputException |
680 |
| - * @throws \Magento\Framework\Exception\NoSuchEntityException |
681 |
| - * @throws \Magento\Framework\Exception\StateException |
| 731 | + * @throws CouldNotSaveException |
| 732 | + * @throws InputException |
| 733 | + * @throws NoSuchEntityException |
| 734 | + * @throws StateException |
682 | 735 | */
|
683 | 736 | public function testProductStatusWhenCatalogFlatProductIsEnabled()
|
684 | 737 | {
|
|
0 commit comments