Skip to content

Commit 0678748

Browse files
author
Roman Lytvynenko
committed
Merge branch 'MC-36227' of https://github.com/magento-tango/magento2ce into TANGO-PR-09-01-2020_24
2 parents e66a51e + 4fcd2ce commit 0678748

File tree

3 files changed

+107
-29
lines changed

3 files changed

+107
-29
lines changed

app/code/Magento/Catalog/etc/db_schema.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@
154154
default="0" comment="Store ID"/>
155155
<column xsi:type="int" name="entity_id" unsigned="true" nullable="false" identity="false"
156156
default="0" comment="Entity ID"/>
157-
<column xsi:type="text" name="value" nullable="true" comment="Value"/>
157+
<column xsi:type="mediumtext" name="value" nullable="true" comment="Value"/>
158158
<constraint xsi:type="primary" referenceId="PRIMARY">
159159
<column name="value_id"/>
160160
</constraint>
@@ -408,7 +408,7 @@
408408
default="0" comment="Store ID"/>
409409
<column xsi:type="int" name="entity_id" unsigned="true" nullable="false" identity="false"
410410
default="0" comment="Entity ID"/>
411-
<column xsi:type="text" name="value" nullable="true" comment="Value"/>
411+
<column xsi:type="mediumtext" name="value" nullable="true" comment="Value"/>
412412
<constraint xsi:type="primary" referenceId="PRIMARY">
413413
<column name="value_id"/>
414414
</constraint>

dev/tests/integration/testsuite/Magento/Catalog/Model/CategoryTest.php

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@
1515
use Magento\Catalog\Model\ResourceModel\Category\Tree;
1616
use Magento\Catalog\Model\ResourceModel\Product\Collection as ProductCollection;
1717
use Magento\Eav\Model\Entity\Attribute\Exception as AttributeException;
18+
use Magento\Framework\Exception\NoSuchEntityException;
19+
use Magento\Framework\Math\Random;
1820
use Magento\Framework\Url;
1921
use Magento\Store\Api\StoreRepositoryInterface;
2022
use Magento\Store\Model\Store;
@@ -419,6 +421,29 @@ public function testCategoryCreateWithDifferentFields(array $data): void
419421
$this->assertSame($data, $categoryData);
420422
}
421423

424+
/**
425+
* Test for Category Description field to be able to contain >64kb of data
426+
*
427+
* @throws NoSuchEntityException
428+
* @throws \Exception
429+
*/
430+
public function testMaximumDescriptionLength(): void
431+
{
432+
$random = Bootstrap::getObjectManager()->get(Random::class);
433+
$longDescription = $random->getRandomString(70000);
434+
435+
$requiredData = [
436+
'name' => 'Test Category',
437+
'attribute_set_id' => '3',
438+
'parent_id' => 2,
439+
'description' => $longDescription
440+
];
441+
$this->_model->setData($requiredData);
442+
$this->categoryResource->save($this->_model);
443+
$category = $this->categoryRepository->get($this->_model->getId());
444+
$this->assertEquals($longDescription, $category->getDescription());
445+
}
446+
422447
/**
423448
* @return array
424449
*/

dev/tests/integration/testsuite/Magento/Catalog/Model/ProductTest.php

Lines changed: 80 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,19 @@
88

99
namespace Magento\Catalog\Model;
1010

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;
1511
use Magento\Catalog\Api\ProductRepositoryInterface;
1612
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;
1721
use Magento\Framework\ObjectManagerInterface;
1822
use Magento\TestFramework\Helper\Bootstrap;
23+
use Magento\TestFramework\ObjectManager;
1924

2025
/**
2126
* Tests product model:
@@ -119,14 +124,62 @@ public function testCRUD()
119124
)->setMetaDescription(
120125
'meta description'
121126
)->setVisibility(
122-
\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH
127+
Visibility::VISIBILITY_BOTH
123128
)->setStatus(
124-
\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED
129+
Status::STATUS_ENABLED
125130
);
126131
$crud = new \Magento\TestFramework\Entity($this->_model, ['sku' => uniqid()]);
127132
$crud->testCrud();
128133
}
129134

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+
130183
/**
131184
* Test clean cache
132185
*
@@ -219,7 +272,7 @@ public function testDuplicate()
219272
$this->assertNotEquals($duplicate->getId(), $this->_model->getId());
220273
$this->assertNotEquals($duplicate->getSku(), $this->_model->getSku());
221274
$this->assertEquals(
222-
\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_DISABLED,
275+
Status::STATUS_DISABLED,
223276
$duplicate->getStatus()
224277
);
225278
$this->assertEquals(\Magento\Store\Model\Store::DEFAULT_STORE_ID, $duplicate->getStoreId());
@@ -275,35 +328,35 @@ protected function _undo($duplicate)
275328
public function testVisibilityApi()
276329
{
277330
$this->assertEquals(
278-
[\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED],
331+
[Status::STATUS_ENABLED],
279332
$this->_model->getVisibleInCatalogStatuses()
280333
);
281334
$this->assertEquals(
282-
[\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED],
335+
[Status::STATUS_ENABLED],
283336
$this->_model->getVisibleStatuses()
284337
);
285338

286-
$this->_model->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_DISABLED);
339+
$this->_model->setStatus(Status::STATUS_DISABLED);
287340
$this->assertFalse($this->_model->isVisibleInCatalog());
288341

289-
$this->_model->setStatus(\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED);
342+
$this->_model->setStatus(Status::STATUS_ENABLED);
290343
$this->assertTrue($this->_model->isVisibleInCatalog());
291344

292345
$this->assertEquals(
293346
[
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,
297350
],
298351
$this->_model->getVisibleInSiteVisibilities()
299352
);
300353

301354
$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);
303356
$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);
305358
$this->assertTrue($this->_model->isVisibleInSiteVisibility());
306-
$this->_model->setVisibility(\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH);
359+
$this->_model->setVisibility(Visibility::VISIBILITY_BOTH);
307360
$this->assertTrue($this->_model->isVisibleInSiteVisibility());
308361
}
309362

@@ -509,9 +562,9 @@ public function testValidate()
509562
)->setMetaDescription(
510563
'meta description'
511564
)->setVisibility(
512-
\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH
565+
Visibility::VISIBILITY_BOTH
513566
)->setStatus(
514-
\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED
567+
Status::STATUS_ENABLED
515568
)->setCollectExceptionMessages(
516569
true
517570
);
@@ -551,9 +604,9 @@ public function testValidateUniqueInputAttributeValue()
551604
$attribute->getAttributeCode(),
552605
'unique value'
553606
)->setVisibility(
554-
\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH
607+
Visibility::VISIBILITY_BOTH
555608
)->setStatus(
556-
\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED
609+
Status::STATUS_ENABLED
557610
)->setCollectExceptionMessages(
558611
true
559612
);
@@ -600,9 +653,9 @@ public function testValidateUniqueInputAttributeOnTheSameProduct()
600653
$attribute->getAttributeCode(),
601654
'unique value'
602655
)->setVisibility(
603-
\Magento\Catalog\Model\Product\Visibility::VISIBILITY_BOTH
656+
Visibility::VISIBILITY_BOTH
604657
)->setStatus(
605-
\Magento\Catalog\Model\Product\Attribute\Source\Status::STATUS_ENABLED
658+
Status::STATUS_ENABLED
606659
)->setCollectExceptionMessages(
607660
true
608661
);
@@ -675,10 +728,10 @@ public function testSaveWithBackordersEnabled(int $qty, int $stockStatus, bool $
675728
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
676729
*
677730
* @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
682735
*/
683736
public function testProductStatusWhenCatalogFlatProductIsEnabled()
684737
{

0 commit comments

Comments
 (0)