Definition at line 11 of file LinkTest.php.
◆ setUp()
Definition at line 33 of file LinkTest.php.
35 $this->resource = $this->createMock(\
Magento\Framework\
App\ResourceConnection::class);
37 $this->createMock(\
Magento\Framework\DB\Adapter\AdapterInterface::class);
38 $this->dbSelect = $this->getMockBuilder(\
Magento\Framework\Db\Select::class)
39 ->disableOriginalConstructor()
41 $this->connection->expects($this->any())
43 ->willReturn($this->dbSelect);
44 $this->resource->expects($this->any())
45 ->method(
'getConnection')
46 ->willReturn($this->connection);
47 $this->resource->expects($this->atLeastOnce())
48 ->method(
'getTableName')
49 ->with(
'catalog_product_website')
50 ->willReturn(
'catalog_product_website');
51 $this->model =
new Link($this->resource);
◆ testGetWebsiteIdByProductId()
testGetWebsiteIdByProductId |
( |
| ) |
|
Definition at line 54 of file LinkTest.php.
58 $this->dbSelect->expects($this->once())
60 ->with(
'catalog_product_website',
'website_id')
61 ->willReturn($this->dbSelect);
62 $this->dbSelect->expects($this->once())
65 $this->connection->expects($this->once())
◆ testSaveWebsiteIds()
Definition at line 72 of file LinkTest.php.
74 $newWebsiteIds = [2,3];
77 $product = $this->createMock(ProductInterface::class);
78 $product->expects($this->atLeastOnce())
81 $this->dbSelect->expects($this->once())
83 ->with(
'catalog_product_website',
'website_id')
84 ->willReturn($this->dbSelect);
85 $this->dbSelect->expects($this->once())
88 $this->connection->expects($this->once())
92 $this->connection->expects($this->once())
93 ->method(
'insertMultiple')
94 ->with(
'catalog_product_website', [
95 [
'product_id' =>
$productId,
'website_id' => 3]
98 $this->connection->expects($this->once())
100 ->with(
'catalog_product_website', [
'product_id = ?' =>
$productId,
'website_id = ?' => 1]);
102 $this->assertTrue($this->model->saveWebsiteIds(
$product, $newWebsiteIds));
◆ $connection
◆ $dbSelect
◆ $model
◆ $resource
The documentation for this class was generated from the following file:
- vendor/magento/module-catalog/Test/Unit/Model/ResourceModel/Product/Website/LinkTest.php