|
| 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\Reports\Test\Unit\Controller\Adminhtml\Report\Shopcart; |
| 9 | + |
| 10 | +use Magento\Framework\TestFramework\Unit\Helper\ObjectManager; |
| 11 | +use Magento\Reports\Block\Adminhtml\Shopcart\Abandoned\Grid; |
| 12 | +use Magento\Reports\Controller\Adminhtml\Report\Shopcart\ExportAbandonedCsv; |
| 13 | +use Magento\Reports\Test\Unit\Controller\Adminhtml\Report\AbstractControllerTest; |
| 14 | + |
| 15 | +class ExportAbandonedCsvTest extends AbstractControllerTest |
| 16 | +{ |
| 17 | + /** |
| 18 | + * @var ExportAbandonedCsv |
| 19 | + */ |
| 20 | + protected $exportAbandonedCsv; |
| 21 | + |
| 22 | + /** |
| 23 | + * {@inheritDoc} |
| 24 | + */ |
| 25 | + protected function setUp(): void |
| 26 | + { |
| 27 | + parent::setUp(); |
| 28 | + |
| 29 | + $objectManager = new ObjectManager($this); |
| 30 | + $this->exportAbandonedCsv = $objectManager->getObject( |
| 31 | + ExportAbandonedCsv::class, |
| 32 | + [ |
| 33 | + 'context' => $this->contextMock, |
| 34 | + 'fileFactory' => $this->fileFactoryMock, |
| 35 | + ] |
| 36 | + ); |
| 37 | + } |
| 38 | + |
| 39 | + /** |
| 40 | + * @return void |
| 41 | + */ |
| 42 | + public function testExecute() |
| 43 | + { |
| 44 | + $content = ['export']; |
| 45 | + |
| 46 | + $this->abstractBlockMock |
| 47 | + ->expects($this->once()) |
| 48 | + ->method('getCsv') |
| 49 | + ->willReturn($content); |
| 50 | + |
| 51 | + $this->layoutMock |
| 52 | + ->expects($this->once()) |
| 53 | + ->method('createBlock') |
| 54 | + ->with(Grid::class) |
| 55 | + ->willReturn($this->abstractBlockMock); |
| 56 | + |
| 57 | + $this->fileFactoryMock |
| 58 | + ->expects($this->once()) |
| 59 | + ->method('create') |
| 60 | + ->with('shopcart_abandoned.csv', $content); |
| 61 | + |
| 62 | + $this->exportAbandonedCsv->execute(); |
| 63 | + } |
| 64 | +} |
0 commit comments