10
10
use Magento \TestFramework \TestCase \GraphQlAbstract ;
11
11
use Magento \Store \Api \StoreRepositoryInterface ;
12
12
use Magento \TestFramework \Helper \Bootstrap ;
13
+ use Magento \TestFramework \ObjectManager ;
13
14
14
15
class SpecialPriceTest extends GraphQlAbstract
15
16
{
16
17
/**
17
- * @var \Magento\TestFramework\ ObjectManager
18
+ * @var ObjectManager
18
19
*/
19
20
private $ objectManager ;
20
21
@@ -28,14 +29,11 @@ protected function setUp(): void
28
29
*/
29
30
public function testSpecialPrice ()
30
31
{
31
- /** @var string $productSku */
32
32
$ productSku = 'simple ' ;
33
- /** @var string $query */
34
33
$ query = $ this ->getProductSearchQuery ($ productSku );
35
34
36
35
$ response = $ this ->graphQlQuery ($ query );
37
36
38
- /** @var float $specialPrice */
39
37
$ specialPrice = (float )$ response ['products ' ]['items ' ][0 ]['special_price ' ];
40
38
$ this ->assertEquals (5.99 , $ specialPrice );
41
39
}
@@ -46,17 +44,11 @@ public function testSpecialPrice()
46
44
*/
47
45
public function testSpecialPriceWithCurrencyRate ()
48
46
{
49
- /** @var string $storeViewCode */
50
47
$ storeViewCode = 'fixture_second_store ' ;
51
- /** @var StoreRepositoryInterface $storeRepository */
52
48
$ storeRepository = $ this ->objectManager ->get (StoreRepositoryInterface::class);
53
- /** @var float $rate */
54
49
$ rate = $ storeRepository ->get ($ storeViewCode )->getCurrentCurrencyRate ();
55
- /** @var string $productSku */
56
50
$ productSku = 'simple ' ;
57
- /** @var string $query */
58
51
$ query = $ this ->getProductSearchQuery ($ productSku );
59
- /** @var array $headers */
60
52
$ headers = $ this ->getHeaderStore ($ storeViewCode );
61
53
62
54
$ response = $ this ->graphQlQuery (
@@ -66,20 +58,21 @@ public function testSpecialPriceWithCurrencyRate()
66
58
$ headers
67
59
);
68
60
69
- /** @var float $specialPrice */
70
61
$ specialPrice = (float )$ response ['products ' ]['items ' ][0 ]['special_price ' ];
71
62
$ this ->assertEquals (round (5.99 * $ rate , 2 ), $ specialPrice );
72
63
}
73
64
74
65
/**
66
+ * Get a query which user filter for product sku and returns special_price
67
+ *
75
68
* @param string $productSku
76
69
* @return string
77
70
*/
78
71
private function getProductSearchQuery (string $ productSku ): string
79
72
{
80
73
return <<<QUERY
81
74
{
82
- products(search: " {$ productSku }") {
75
+ products(filter: {sku: {eq: " {$ productSku }"}} ) {
83
76
items {
84
77
special_price
85
78
}
@@ -89,6 +82,8 @@ private function getProductSearchQuery(string $productSku): string
89
82
}
90
83
91
84
/**
85
+ * Get array that would be used in request header
86
+ *
92
87
* @param string $storeViewCode
93
88
* @return array
94
89
*/
0 commit comments