Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
UpdateAttributesFlushCacheTest.php
Go to the documentation of this file.
1 <?php
7 
9 
10 class UpdateAttributesFlushCacheTest extends \PHPUnit\Framework\TestCase
11 {
15  private $model;
16 
17  protected function setUp()
18  {
19  $cacheContextMock = $this->createMock(\Magento\Framework\Indexer\CacheContext::class);
20 
21  $eventManagerMock = $this->createMock(\Magento\Framework\Event\ManagerInterface::class);
22  $eventManagerMock->expects($this->once())
23  ->method('dispatch')
24  ->with('clean_cache_by_tags', ['object' => $cacheContextMock]);
25 
26  $objectManager = new \Magento\Framework\TestFramework\Unit\Helper\ObjectManager($this);
27  $this->model = $objectManager->getObject(
28  \Magento\Catalog\Plugin\Model\Product\Action\UpdateAttributesFlushCache::class,
29  [
30  'cacheContext' => $cacheContextMock,
31  'eventManager' => $eventManagerMock,
32  ]
33  );
34  }
35 
36  public function testAroundUpdateAttributes()
37  {
39  $productActionMock = $this->createMock(\Magento\Catalog\Model\Product\Action::class);
40  $this->model->afterUpdateAttributes($productActionMock, $productActionMock);
41  }
42 
43  public function testAroundUpdateWebsites()
44  {
46  $productActionMock = $this->createMock(\Magento\Catalog\Model\Product\Action::class);
47  $this->model->afterUpdateWebsites($productActionMock, $productActionMock);
48  }
49 }
$objectManager
Definition: bootstrap.php:17