Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
QuoteItemsCleanerTest.php
Go to the documentation of this file.
1 <?php
7 
8 class QuoteItemsCleanerTest extends \PHPUnit\Framework\TestCase
9 {
13  private $model;
14 
18  private $itemResourceMock;
19 
20  protected function setUp()
21  {
22  $this->itemResourceMock = $this->createMock(\Magento\Quote\Model\ResourceModel\Quote\Item::class);
23  $this->model = new \Magento\Quote\Model\Product\QuoteItemsCleaner($this->itemResourceMock);
24  }
25 
26  public function testExecute()
27  {
28  $tableName = 'table_name';
29  $productMock = $this->createMock(\Magento\Catalog\Api\Data\ProductInterface::class);
30  $productMock->expects($this->once())->method('getId')->willReturn(1);
31 
32  $connectionMock = $this->createMock(\Magento\Framework\DB\Adapter\AdapterInterface::class);
33  $this->itemResourceMock->expects($this->once())->method('getConnection')->willReturn($connectionMock);
34  $this->itemResourceMock->expects($this->once())->method('getMainTable')->willReturn($tableName);
35 
36  $connectionMock->expects($this->once())->method('delete')->with($tableName, 'product_id = 1');
37  $this->model->execute($productMock);
38  }
39 }
$tableName
Definition: trigger.php:13