|
| 1 | +<?php |
| 2 | +/** |
| 3 | + * Copyright © Magento, Inc. All rights reserved. |
| 4 | + * See COPYING.txt for license details. |
| 5 | + */ |
| 6 | +declare(strict_types=1); |
| 7 | + |
| 8 | +namespace Magento\Paypal\Test\Unit\Model\Report; |
| 9 | + |
| 10 | +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager as ObjectManagerHelper; |
| 11 | +use Magento\Paypal\Model\Report\Settlement; |
| 12 | +use Magento\Framework\Filesystem\Io\Sftp; |
| 13 | +use Magento\Framework\Filesystem\Directory\WriteInterface; |
| 14 | +use PHPUnit\Framework\MockObject\MockObject; |
| 15 | +use PHPUnit\Framework\TestCase; |
| 16 | + |
| 17 | +/** |
| 18 | + * Test for paypal settlement |
| 19 | + */ |
| 20 | +class SettlementTest extends TestCase |
| 21 | +{ |
| 22 | + /** |
| 23 | + * @var Settlement |
| 24 | + */ |
| 25 | + private $settlement; |
| 26 | + |
| 27 | + /** |
| 28 | + * @var WriteInterface|MockObject |
| 29 | + */ |
| 30 | + private $tmpDirectory; |
| 31 | + |
| 32 | + /** |
| 33 | + * @inheritDoc |
| 34 | + */ |
| 35 | + protected function setUp(): void |
| 36 | + { |
| 37 | + $objectManagerHelper = new ObjectManagerHelper($this); |
| 38 | + $this->tmpDirectory = $this->getMockBuilder(WriteInterface::class) |
| 39 | + ->disableOriginalConstructor() |
| 40 | + ->getMock(); |
| 41 | + $this->settlement = $objectManagerHelper->getObject( |
| 42 | + Settlement::class, |
| 43 | + [ |
| 44 | + '_tmpDirectory' => $this->tmpDirectory |
| 45 | + ] |
| 46 | + ); |
| 47 | + } |
| 48 | + |
| 49 | + /** |
| 50 | + * Test for filter report list |
| 51 | + * |
| 52 | + * @return void |
| 53 | + */ |
| 54 | + public function testFilterReportList(): void |
| 55 | + { |
| 56 | + $this->tmpDirectory->method('getAbsolutePath') |
| 57 | + ->willReturn(''); |
| 58 | + /** @var Sftp|MockObject $connection */ |
| 59 | + $connection = $this->getMockBuilder(Sftp::class) |
| 60 | + ->onlyMethods(['rawls', 'read']) |
| 61 | + ->disableOriginalConstructor() |
| 62 | + ->getMock(); |
| 63 | + $connection->method('rawls') |
| 64 | + ->willReturn( |
| 65 | + [ |
| 66 | + 'STL-20201221.01.009.CSV' => 'Single account', |
| 67 | + 'STL-20201221.H.01.01.009.CSV' => 'Multiple account', |
| 68 | + ] |
| 69 | + ); |
| 70 | + $connection->expects($this->exactly(2))->method('read')->willReturn(false); |
| 71 | + $this->settlement->fetchAndSave($connection); |
| 72 | + } |
| 73 | +} |
0 commit comments