102 lines
3.8 KiB
PHP
102 lines
3.8 KiB
PHP
<?php
|
|
|
|
/**
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*
|
|
* https://www.d3data.de
|
|
*
|
|
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
|
* @author D3 Data Development - Daniel Seifert <info@shopmodule.com>
|
|
* @link https://www.oxidmodule.com
|
|
*/
|
|
|
|
namespace D3\PdfDocuments\Tests\Unit\Application\Model\Registries;
|
|
|
|
use D3\PdfDocuments\Application\Model\Constants;
|
|
use D3\PdfDocuments\Application\Model\Documents\invoicePdf;
|
|
use D3\PdfDocuments\Application\Model\Exceptions\wrongPdfGeneratorInterface;
|
|
use D3\PdfDocuments\Application\Model\Registries\registryOrderoverview;
|
|
use D3\PdfDocuments\Tests\Unit\Helpers\nonOrderDocument;
|
|
use D3\PdfDocuments\Tests\Unit\Helpers\orderDocument;
|
|
use D3\TestingTools\Development\CanAccessRestricted;
|
|
use Exception;
|
|
use Generator;
|
|
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
|
|
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingService;
|
|
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingServiceInterface;
|
|
use PHPUnit\Framework\MockObject\Rule\InvocationOrder;
|
|
use PHPUnit\Framework\TestCase;
|
|
use ReflectionException;
|
|
|
|
class registryOrderOverviewTest extends registryAbstract
|
|
{
|
|
/**
|
|
* @test
|
|
* @throws ReflectionException
|
|
* @covers \D3\PdfDocuments\Application\Model\Registries\registryOrderoverview::__construct
|
|
* @dataProvider constructDataProvider
|
|
*/
|
|
public function testConstructor(bool $inv, bool $deln, bool $invNL, bool $delnNL, int $expectedCount): void
|
|
{
|
|
$settingService = $this->getMockBuilder(ModuleSettingService::class)
|
|
->onlyMethods(['getBoolean'])
|
|
->disableOriginalConstructor()
|
|
->getMock();
|
|
$settingService->method('getBoolean')->willReturnMap([
|
|
['d3PdfDocumentsDocInvoice', Constants::OXID_MODULE_ID, $inv],
|
|
['d3PdfDocumentsDocDeliveryNote', Constants::OXID_MODULE_ID, $deln],
|
|
['d3PdfDocumentsDocInvoiceNoLogo', Constants::OXID_MODULE_ID, $invNL],
|
|
['d3PdfDocumentsDocDeliveryNoteNoLogo', Constants::OXID_MODULE_ID, $delnNL],
|
|
]);
|
|
|
|
try {
|
|
$this->addServiceMocks([ModuleSettingServiceInterface::class => $settingService]);
|
|
|
|
$sut = $this->getMockBuilder(registryOrderoverview::class)
|
|
->disableOriginalConstructor()
|
|
->onlyMethods(['addGenerator'])
|
|
->getMock();
|
|
$sut->expects($this->exactly($expectedCount))->method('addGenerator');
|
|
|
|
$this->callMethod(
|
|
$sut,
|
|
'__construct'
|
|
);
|
|
} finally {
|
|
ContainerFactory::resetContainer();
|
|
}
|
|
}
|
|
|
|
public static function constructDataProvider(): Generator
|
|
{
|
|
yield 'nothing' => [false, false, false, false, 0];
|
|
yield 'invoice only' => [true, false, false, false, 1];
|
|
yield 'invoice + delnote' => [true, true, false, false, 2];
|
|
yield 'invoice + NoLogo + delnote' => [true, true, true, false, 3];
|
|
yield 'invoice + NoLogo + delnote + NoLogo' => [true, true, true, true, 4];
|
|
yield 'invNoLogo + delnote + NoLogo' => [false, true, true, true, 3];
|
|
}
|
|
|
|
/**
|
|
* @test
|
|
* @throws ReflectionException
|
|
* @throws wrongPdfGeneratorInterface
|
|
* @covers \D3\PdfDocuments\Application\Model\Registries\registryOrderoverview::getGenerator
|
|
*/
|
|
public function testGetGenerator(): void
|
|
{
|
|
$sut = oxNew(registryOrderoverview::class);
|
|
$sut->addGenerator(orderDocument::class);
|
|
|
|
$this->assertInstanceOf(
|
|
orderDocument::class,
|
|
$this->callMethod(
|
|
$sut,
|
|
'getGenerator',
|
|
[orderDocument::class]
|
|
)
|
|
);
|
|
}
|
|
}
|