12
12
13
13
class ProductTest extends TestCase
14
14
{
15
+ /**
16
+ * @var ProductRepositoryInterface
17
+ */
18
+ private $ productRepository ;
19
+
15
20
/**
16
21
* @var Product
17
22
*/
@@ -29,7 +34,8 @@ protected function setUp()
29
34
{
30
35
$ this ->objectManager = Bootstrap::getObjectManager ();
31
36
32
- $ this ->model = $ this ->objectManager ->get (Product::class);
37
+ $ this ->productRepository = $ this ->objectManager ->create (ProductRepositoryInterface::class);
38
+ $ this ->model = $ this ->objectManager ->create (Product::class);
33
39
}
34
40
35
41
/**
@@ -42,11 +48,29 @@ public function testGetAttributeRawValue()
42
48
$ sku = 'simple ' ;
43
49
$ attribute = 'name ' ;
44
50
45
- /** @var ProductRepositoryInterface $productRepository */
46
- $ productRepository = $ this ->objectManager ->get (ProductRepositoryInterface::class);
47
- $ product = $ productRepository ->get ($ sku );
48
-
51
+ $ product = $ this ->productRepository ->get ($ sku );
49
52
$ actual = $ this ->model ->getAttributeRawValue ($ product ->getId (), $ attribute , null );
50
53
self ::assertEquals ($ product ->getName (), $ actual );
51
54
}
55
+
56
+ /**
57
+ * @magentoAppArea adminhtml
58
+ * @magentoDataFixture Magento/Catalog/_files/product_special_price.php
59
+ * @magentoAppIsolation enabled
60
+ * @magentoConfigFixture default_store catalog/price/scope 1
61
+ */
62
+ public function testUpdateStoreSpecificSpecialPrice ()
63
+ {
64
+ /** @var \Magento\Catalog\Model\Product $product */
65
+ $ product = $ this ->productRepository ->get ('simple ' , true , 1 );
66
+ $ this ->assertEquals (5.99 , $ product ->getSpecialPrice ());
67
+
68
+ $ product ->setSpecialPrice ('' );
69
+ $ this ->model ->save ($ product );
70
+ $ product = $ this ->productRepository ->get ('simple ' , false , 1 , true );
71
+ $ this ->assertEmpty ($ product ->getSpecialPrice ());
72
+
73
+ $ product = $ this ->productRepository ->get ('simple ' , false , 0 , true );
74
+ $ this ->assertEquals (5.99 , $ product ->getSpecialPrice ());
75
+ }
52
76
}
0 commit comments