selectMock = $this->createMock(\Magento\Framework\DB\Select::class); $this->selectMock->expects($this->any())->method('from')->will($this->returnSelf()); $this->selectMock->expects($this->any())->method('where'); $this->adapterMock = $this->createMock(\Magento\Framework\DB\Adapter\Pdo\Mysql::class); $this->adapterMock->expects($this->any())->method('select')->will($this->returnValue($this->selectMock)); $this->resourceMock = $this->createMock(\Magento\Sales\Model\ResourceModel\Order::class); $this->resourceMock->expects($this->any())->method('getConnection')->willReturn($this->adapterMock); $this->model = $objectManagerHelper->getObject( \Magento\Sales\Model\OrderIncrementIdChecker::class, [ 'resourceModel' => $this->resourceMock, ] ); } /** * Unit test to verify if isOrderIncrementIdUsed method works with different types increment ids. * * @param string|int $value * @return void * @dataProvider isOrderIncrementIdUsedDataProvider */ public function testIsIncrementIdUsed($value): void { $expectedBind = [':increment_id' => $value]; $this->adapterMock->expects($this->once())->method('fetchOne')->with($this->selectMock, $expectedBind); $this->model->isIncrementIdUsed($value); } /** * @return array */ public function isOrderIncrementIdUsedDataProvider(): array { return [[100000001], ['10000000001'], ['M10000000001']]; } }