@@ -24,19 +24,24 @@ class SearchTest extends WebapiAbstract
24
24
*/
25
25
private $ product ;
26
26
27
+ /**
28
+ * @inheritDoc
29
+ */
27
30
protected function setUp (): void
28
31
{
29
32
$ productSku = 'simple ' ;
30
33
31
34
$ objectManager = Bootstrap::getObjectManager ();
32
- $ productRepository = $ objectManager ->create (ProductRepositoryInterface::class);
35
+ $ productRepository = $ objectManager ->get (ProductRepositoryInterface::class);
33
36
$ this ->product = $ productRepository ->get ($ productSku );
34
37
}
35
38
36
39
/**
37
- * @magentoApiDataFixture Magento/Catalog/_files/product_simple.php
40
+ * Tests that webapi call returns response when search criteria is valid.
41
+ *
42
+ * @magentoApiDataFixture Magento/Catalog/_files/products.php
38
43
*/
39
- public function testExistingProductSearch ()
44
+ public function testExistingProductSearch (): void
40
45
{
41
46
$ productName = $ this ->product ->getName ();
42
47
@@ -47,14 +52,16 @@ public function testExistingProductSearch()
47
52
48
53
self ::assertArrayHasKey ('search_criteria ' , $ response );
49
54
self ::assertArrayHasKey ('items ' , $ response );
50
- self ::assertGreaterThan (0 , count ($ response ['items ' ]));
55
+ self ::assertGreaterThan (1 , count ($ response ['items ' ]));
51
56
self ::assertGreaterThan (0 , $ response ['items ' ][0 ]['id ' ]);
52
57
}
53
58
54
59
/**
55
- * @magentoApiDataFixture Magento/Catalog/_files/product_simple.php
60
+ * Tests that response is empty if invalid data is provided.
61
+ *
62
+ * @magentoApiDataFixture Magento/Catalog/_files/products.php
56
63
*/
57
- public function testNonExistentProductSearch ()
64
+ public function testNonExistentProductSearch (): void
58
65
{
59
66
$ searchCriteria = $ this ->buildSearchCriteria ('nonExistentProduct ' );
60
67
$ serviceInfo = $ this ->buildServiceInfo ($ searchCriteria );
0 commit comments