Spaces:
No application file
No application file
File size: 2,162 Bytes
d2897cd |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
<?php
namespace Mautic\ReportBundle\Tests\Adapter;
use Mautic\CoreBundle\Helper\CoreParametersHelper;
use Mautic\ReportBundle\Adapter\ReportDataAdapter;
use Mautic\ReportBundle\Entity\Report;
use Mautic\ReportBundle\Model\ReportExportOptions;
use Mautic\ReportBundle\Model\ReportModel;
use Mautic\ReportBundle\Tests\Fixtures;
class ReportDataAdapterTest extends \PHPUnit\Framework\TestCase
{
public function testNoEmailsProvided(): void
{
$reportModelMock = $this->getMockBuilder(ReportModel::class)
->disableOriginalConstructor()
->getMock();
$coreParametersHelperMock = $this->getMockBuilder(CoreParametersHelper::class)
->disableOriginalConstructor()
->getMock();
$coreParametersHelperMock->expects($this->once())
->method('get')
->with('report_export_batch_size')
->willReturn(11);
$reportDataAdapter = new ReportDataAdapter($reportModelMock);
$report = new Report();
$reportExportOptions = new ReportExportOptions($coreParametersHelperMock);
$options = [
'paginate' => true,
'limit' => 11,
'ignoreGraphData' => true,
'page' => 1,
'dateTo' => null,
'dateFrom' => null,
];
$reportModelMock->expects($this->once())
->method('getReportData')
->with($report, null, $options)
->willReturn(Fixtures::getValidReportResult());
$result = $reportDataAdapter->getReportData($report, $reportExportOptions);
$this->assertSame(Fixtures::getValidReportData(), $result->getData());
$this->assertSame(Fixtures::getValidReportHeaders(), $result->getHeaders());
$this->assertSame(Fixtures::getValidReportTotalResult(), $result->getTotalResults());
$this->assertSame(Fixtures::getStringType(), $result->getType('city'));
$this->assertSame(Fixtures::getDateType(), $result->getType('date_identified'));
$this->assertSame(Fixtures::getEmailType(), $result->getType('email'));
}
}
|