@@ -14,18 +14,34 @@ class SkuTest extends \PHPUnit\Framework\TestCase
14
14
/**
15
15
* @magentoDataFixture Magento/Catalog/_files/product_simple.php
16
16
*/
17
- public function testGenerateUniqueSkuExistingProduct ()
17
+ public function testGenerateUniqueSkuExistingProductDuplication ()
18
18
{
19
19
$ repository = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ()->create (
20
20
\Magento \Catalog \Model \ProductRepository::class
21
21
);
22
22
$ product = $ repository ->get ('simple ' );
23
23
$ product ->setId (null );
24
+ $ product ->setIsDuplicate (true );
24
25
$ this ->assertEquals ('simple ' , $ product ->getSku ());
25
26
$ product ->getResource ()->getAttribute ('sku ' )->getBackend ()->beforeSave ($ product );
26
27
$ this ->assertEquals ('simple-1 ' , $ product ->getSku ());
27
28
}
28
29
30
+ /**
31
+ * @magentoDataFixture Magento/Catalog/_files/product_simple.php
32
+ */
33
+ public function testGenerateUniqueSkuExistingProductNoDuplication ()
34
+ {
35
+ $ repository = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ()->create (
36
+ \Magento \Catalog \Model \ProductRepository::class
37
+ );
38
+ $ product = $ repository ->get ('simple ' );
39
+ $ product ->setId (null );
40
+ $ this ->assertEquals ('simple ' , $ product ->getSku ());
41
+ $ product ->getResource ()->getAttribute ('sku ' )->getBackend ()->beforeSave ($ product );
42
+ $ this ->assertEquals ('simple ' , $ product ->getSku ());
43
+ }
44
+
29
45
/**
30
46
* @param $product \Magento\Catalog\Model\Product
31
47
* @dataProvider uniqueSkuDataProvider
@@ -54,10 +70,14 @@ public function testGenerateUniqueLongSku()
54
70
$ copier = \Magento \TestFramework \Helper \Bootstrap::getObjectManager ()->get (
55
71
\Magento \Catalog \Model \Product \Copier::class
56
72
);
57
- $ copier ->copy ($ product );
73
+ $ copy = $ copier ->copy ($ product );
58
74
$ this ->assertEquals ('0123456789012345678901234567890123456789012345678901234567890123 ' , $ product ->getSku ());
59
75
$ product ->getResource ()->getAttribute ('sku ' )->getBackend ()->beforeSave ($ product );
60
- $ this ->assertEquals ('01234567890123456789012345678901234567890123456789012345678901-1 ' , $ product ->getSku ());
76
+ $ this ->assertEquals ('0123456789012345678901234567890123456789012345678901234567890123 ' , $ product ->getSku ());
77
+ $ this ->assertEquals ('01234567890123456789012345678901234567890123456789012345678901-1 ' , $ copy ->getSku ());
78
+
79
+ $ copy ->getResource ()->getAttribute ('sku ' )->getBackend ()->beforeSave ($ copy );
80
+ $ this ->assertEquals ('01234567890123456789012345678901234567890123456789012345678901-2 ' , $ copy ->getSku ());
61
81
}
62
82
63
83
/**
0 commit comments