11
11
use Magento \Catalog \Api \Data \ProductInterfaceFactory ;
12
12
use Magento \Catalog \Api \ProductRepositoryInterface ;
13
13
use Magento \Catalog \Model \ResourceModel \Product as ProductResource ;
14
+ use Magento \Catalog \Model \ResourceModel \Product \Gallery ;
14
15
use Magento \Framework \EntityManager \MetadataPool ;
15
16
use Magento \Store \Api \StoreRepositoryInterface ;
16
17
use Magento \Store \Model \Store ;
19
20
20
21
/**
21
22
* Provide tests for loading gallery images on product load.
23
+ *
24
+ * @SuppressWarnings(PHPMD.CouplingBetweenObjects)
22
25
*/
23
26
class ReadHandlerTest extends \PHPUnit \Framework \TestCase
24
27
{
@@ -47,6 +50,11 @@ class ReadHandlerTest extends \PHPUnit\Framework\TestCase
47
50
*/
48
51
private $ productResource ;
49
52
53
+ /**
54
+ * @var Gallery
55
+ */
56
+ private $ galleryResource ;
57
+
50
58
/**
51
59
* @var StoreRepositoryInterface
52
60
*/
@@ -67,6 +75,7 @@ protected function setUp()
67
75
$ this ->productRepository = $ this ->objectManager ->get (ProductRepositoryInterface::class);
68
76
$ this ->productFactory = $ this ->objectManager ->get (ProductInterfaceFactory::class);
69
77
$ this ->productResource = $ this ->objectManager ->get (ProductResource::class);
78
+ $ this ->galleryResource = $ this ->objectManager ->create (Gallery::class);
70
79
$ this ->storeRepository = $ this ->objectManager ->create (StoreRepositoryInterface::class);
71
80
$ this ->productLinkField = $ this ->objectManager ->get (MetadataPool::class)
72
81
->getMetadata (ProductInterface::class)
@@ -261,6 +270,20 @@ public function executeOnStoreViewDataProvider(): array
261
270
];
262
271
}
263
272
273
+ /**
274
+ * @inheritdoc
275
+ */
276
+ protected function tearDown ()
277
+ {
278
+ parent ::tearDown ();
279
+ $ this ->galleryResource ->getConnection ()
280
+ ->delete ($ this ->galleryResource ->getTable (Gallery::GALLERY_TABLE ));
281
+ $ this ->galleryResource ->getConnection ()
282
+ ->delete ($ this ->galleryResource ->getTable (Gallery::GALLERY_VALUE_TABLE ));
283
+ $ this ->galleryResource ->getConnection ()
284
+ ->delete ($ this ->galleryResource ->getTable (Gallery::GALLERY_VALUE_TO_ENTITY_TABLE ));
285
+ }
286
+
264
287
/**
265
288
* Returns product for testing.
266
289
*
0 commit comments