dateTimeMock = $this->createMock(\Magento\Framework\Stdlib\DateTime::class); $this->resourceMock = $this->createMock(\Magento\Framework\App\ResourceConnection::class); $this->dbAdapterMock = $this->createMock(\Magento\Framework\DB\Adapter\AdapterInterface::class); $this->model = $objectManager->getObject( \Magento\Security\Model\ResourceModel\PasswordResetRequestEvent::class, [ 'resource' => $this->resourceMock, 'dateTime' => $this->dateTimeMock ] ); } /** * @return void */ public function testDeleteRecordsOlderThen() { $timestamp = 12345; $this->resourceMock->expects($this->once()) ->method('getConnection') ->willReturn($this->dbAdapterMock); $this->dbAdapterMock->expects($this->once()) ->method('delete') ->with($this->model->getMainTable(), ['created_at < ?' => $this->dateTimeMock->formatDate($timestamp)]) ->willReturnSelf(); $this->assertEquals($this->model, $this->model->deleteRecordsOlderThen($timestamp)); } }