![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/magento/module-import-export/Test/Unit/Model/ResourceModel/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ declare(strict_types=1); namespace Magento\ImportExport\Test\Unit\Model\ResourceModel; use Magento\Framework\DB\Adapter\Pdo\Mysql; use Magento\Framework\DB\Select; use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; use Magento\ImportExport\Model\ResourceModel\History; use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; class HistoryTest extends TestCase { /** * @var ObjectManagerHelper */ protected $objectManagerHelper; /** * @var History|MockObject */ protected $historyResourceModel; /** * Set up */ protected function setUp(): void { $this->historyResourceModel = $this->createPartialMock( History::class, ['getConnection', 'getMainTable', 'getIdFieldName'] ); $dbAdapterMock = $this->createPartialMock( Mysql::class, ['select', 'fetchOne'] ); $selectMock = $this->createPartialMock( Select::class, ['from', 'order', 'where', 'limit'] ); $selectMock->expects($this->any())->method('from')->willReturnSelf(); $selectMock->expects($this->any())->method('order')->willReturnSelf(); $selectMock->expects($this->any())->method('where')->willReturnSelf(); $selectMock->expects($this->any())->method('limit')->willReturnSelf(); $dbAdapterMock->expects($this->any())->method('select')->willReturn($selectMock); $dbAdapterMock->expects($this->any())->method('fetchOne')->willReturn('result'); $this->historyResourceModel->expects($this->any())->method('getConnection')->willReturn($dbAdapterMock); $this->historyResourceModel->expects($this->any())->method('getMainTable')->willReturn('mainTable'); $this->historyResourceModel->expects($this->any())->method('getIdFieldName')->willReturn('id'); } /** * Test getLastInsertedId() */ public function testGetLastInsertedId() { $id = 1; $this->assertEquals($this->historyResourceModel->getLastInsertedId($id), 'result'); } }