Compare commits
3 Commits
dev_2.x_da
...
dev_2.x
Author | SHA1 | Date | |
---|---|---|---|
b7bd1a0377
|
|||
c7042b5b0e | |||
dd54fd6b2c |
@ -27,27 +27,29 @@ use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingServ
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingServiceInterface;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
use Throwable;
|
||||
|
||||
class orderOverviewPdfGenerator
|
||||
{
|
||||
/**
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
* @throws noPdfHandlerFoundException
|
||||
*/
|
||||
public function generatePdf(Order $order, int $iSelLang = 0): void
|
||||
{
|
||||
$Pdf = $this->getPdfClass();
|
||||
try {
|
||||
$Pdf = $this->getPdfClass();
|
||||
|
||||
/** @var ModuleSettingService $settingsService */
|
||||
$settingsService = ContainerFactory::getInstance()->getContainer()->get(ModuleSettingServiceInterface::class);
|
||||
/** @var ModuleSettingService $settingsService */
|
||||
$settingsService = ContainerFactory::getInstance()->getContainer()->get(ModuleSettingServiceInterface::class);
|
||||
|
||||
$Pdf->setDevelopmentMode(
|
||||
$settingsService->getBoolean('d3PdfDocumentsbDev', Constants::OXID_MODULE_ID) &&
|
||||
Registry::getRequest()->getRequestEscapedParameter('devmode')
|
||||
);
|
||||
$Pdf->setOrder($order);
|
||||
$Pdf->downloadPdf($iSelLang);
|
||||
$Pdf->setDevelopmentMode(
|
||||
$settingsService->getBoolean('d3PdfDocumentsbDev', Constants::OXID_MODULE_ID) &&
|
||||
Registry::getRequest()->getRequestEscapedParameter('devmode')
|
||||
);
|
||||
$Pdf->setOrder($order);
|
||||
$Pdf->downloadPdf($iSelLang);
|
||||
// @codeCoverageIgnoreStart
|
||||
} catch (Throwable $exception) {
|
||||
Registry::getUtilsView()->addErrorToDisplay($exception);
|
||||
}
|
||||
// @codeCoverageIgnoreEnd
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -23,6 +23,8 @@ use OxidEsales\Eshop\Core\Base;
|
||||
use OxidEsales\Eshop\Core\Registry;
|
||||
use OxidEsales\Eshop\Core\UtilsView;
|
||||
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Exception\ModuleConfigurationNotFoundException;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Exception\ModuleSettingNotFountException;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingService;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingServiceInterface;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Templating\TemplateRenderer;
|
||||
@ -72,6 +74,8 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
|
||||
/**
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws Html2PdfException
|
||||
* @throws ModuleConfigurationNotFoundException
|
||||
* @throws ModuleSettingNotFountException
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function genPdf(string $filename, int $language = 0, string $target = self::PDF_DESTINATION_STDOUT): ?string
|
||||
@ -98,6 +102,8 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
|
||||
/**
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws Html2PdfException
|
||||
* @throws ModuleConfigurationNotFoundException
|
||||
* @throws ModuleSettingNotFountException
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function downloadPdf(int $language = 0): void
|
||||
@ -119,6 +125,8 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
|
||||
/**
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws Html2PdfException
|
||||
* @throws ModuleConfigurationNotFoundException
|
||||
* @throws ModuleSettingNotFountException
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function savePdfFile(string $path, int $language = 0): void
|
||||
@ -143,6 +151,8 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
|
||||
/**
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws Html2PdfException
|
||||
* @throws ModuleConfigurationNotFoundException
|
||||
* @throws ModuleSettingNotFountException
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function getPdfContent(int $language = 0): ?string
|
||||
@ -172,12 +182,15 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
|
||||
'oViewConf' => Registry::getConfig()->getActiveView()->getViewConfig(),
|
||||
'shop' => Registry::getConfig()->getActiveShop(),
|
||||
'lang' => Registry::getLang(),
|
||||
'utilsUrl' => Registry::getUtilsUrl(),
|
||||
'document' => $this,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws ModuleConfigurationNotFoundException
|
||||
* @throws ModuleSettingNotFountException
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function getHTMLContent(int $language = 0): string
|
||||
@ -202,8 +215,12 @@ abstract class pdfdocumentsGeneric extends Base implements genericInterface
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $content
|
||||
* @return string
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
* @throws ModuleConfigurationNotFoundException
|
||||
* @throws ModuleSettingNotFountException
|
||||
*/
|
||||
protected function addBasicAuth(string $content): string
|
||||
{
|
||||
|
@ -23,11 +23,9 @@ use OxidEsales\Eshop\Application\Model\Order;
|
||||
use OxidEsales\Eshop\Application\Model\Payment;
|
||||
use OxidEsales\Eshop\Application\Model\User;
|
||||
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Bridge\ModuleConfigurationDaoBridge;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Bridge\ModuleConfigurationDaoBridgeInterface;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Exception\ModuleSettingNotFountException;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingService;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingServiceInterface;
|
||||
use Throwable;
|
||||
|
||||
abstract class pdfdocumentsOrder extends pdfdocumentsGeneric implements orderInterface
|
||||
{
|
||||
@ -105,31 +103,18 @@ abstract class pdfdocumentsOrder extends pdfdocumentsGeneric implements orderInt
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
* @throws ModuleSettingNotFountException
|
||||
*/
|
||||
public function getPaymentTerm(): int
|
||||
{
|
||||
/** @var ModuleConfigurationDaoBridge $configurationBridge */
|
||||
$configurationBridge = ContainerFactory::getInstance()->getContainer()
|
||||
->get(ModuleConfigurationDaoBridgeInterface::class);
|
||||
$configuration = $configurationBridge->get(Constants::OXID_MODULE_ID);
|
||||
|
||||
return max(
|
||||
$configuration->hasModuleSetting('invoicePaymentTerm') ?
|
||||
(int)$configuration->getModuleSetting('invoicePaymentTerm')->getValue() :
|
||||
7,
|
||||
0
|
||||
);
|
||||
try {
|
||||
/** @var ModuleSettingService $settingService */
|
||||
$settingService = ContainerFactory::getInstance()->getContainer()
|
||||
->get(ModuleSettingServiceInterface::class);
|
||||
return $settingService->getInteger('invoicePaymentTerm', Constants::OXID_MODULE_ID);
|
||||
} catch (Throwable) {
|
||||
return 7;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws ModuleSettingNotFountException
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function getPayableUntilDate(): false|int
|
||||
{
|
||||
$startDate = $this->getOrder()->getFieldData('oxbilldate');
|
||||
|
@ -9,6 +9,8 @@ use D3\PdfDocuments\Application\Model\Documents\invoicePdf;
|
||||
use D3\PdfDocuments\Application\Model\Documents\invoicewithoutlogoPdf;
|
||||
use D3\PdfDocuments\Application\Model\Exceptions\wrongPdfGeneratorInterface;
|
||||
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Exception\ModuleConfigurationNotFoundException;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Exception\ModuleSettingNotFountException;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingService;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingServiceInterface;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
@ -19,6 +21,8 @@ trait registryTrait
|
||||
/**
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
* @throws ModuleConfigurationNotFoundException
|
||||
* @throws ModuleSettingNotFountException
|
||||
* @throws wrongPdfGeneratorInterface
|
||||
*/
|
||||
public function __construct()
|
||||
|
@ -17,12 +17,10 @@ use Assert\Assert;
|
||||
use Assert\InvalidArgumentException;
|
||||
use D3\PdfDocuments\Application\Controller\orderOverviewPdfGenerator;
|
||||
use D3\PdfDocuments\Application\Model\Constants;
|
||||
use D3\PdfDocuments\Application\Model\Exceptions\noPdfHandlerFoundException;
|
||||
use D3\PdfDocuments\Application\Model\Registries\registryOrderoverview;
|
||||
use D3\PdfDocuments\Application\Model\Registries\registryOrderoverviewInterface;
|
||||
use Doctrine\DBAL\Driver\Exception as DBALDriverException;
|
||||
use ErrorException;
|
||||
use Exception;
|
||||
use Doctrine\DBAL\Exception as DBALException;
|
||||
use Doctrine\DBAL\ParameterType;
|
||||
use Doctrine\DBAL\Query\QueryBuilder;
|
||||
@ -36,12 +34,16 @@ use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingServ
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingServiceInterface;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
use Throwable;
|
||||
|
||||
class d3_overview_controller_pdfdocuments extends d3_overview_controller_pdfdocuments_parent
|
||||
{
|
||||
protected ?string $generatorError = null;
|
||||
protected bool $doReload = false;
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
$this->addTplParam('d3PdfDocumentGeneratorList', $this->d3getGeneratorList());
|
||||
@ -76,15 +78,17 @@ class d3_overview_controller_pdfdocuments extends d3_overview_controller_pdfdocu
|
||||
return parent::render();
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function d3PdfDocsIsDevMode(): bool
|
||||
{
|
||||
/** @var ModuleSettingService $settingsService */
|
||||
$settingsService = ContainerFactory::getInstance()->getContainer()->get(ModuleSettingServiceInterface::class);
|
||||
return $settingsService->getBoolean('d3PdfDocumentsbDev', Constants::OXID_MODULE_ID);
|
||||
try {
|
||||
/** @var ModuleSettingService $settingsService */
|
||||
$settingsService = ContainerFactory::getInstance()->getContainer()->get(ModuleSettingServiceInterface::class);
|
||||
return $settingsService->getBoolean('d3PdfDocumentsbDev', Constants::OXID_MODULE_ID);
|
||||
} catch (Throwable $exception) {
|
||||
Registry::getUtilsView()->addErrorToDisplay($exception);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -116,11 +120,6 @@ class d3_overview_controller_pdfdocuments extends d3_overview_controller_pdfdocu
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws noPdfHandlerFoundException
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
*/
|
||||
public function d3CreatePDF(): void
|
||||
{
|
||||
try {
|
||||
@ -136,7 +135,7 @@ class d3_overview_controller_pdfdocuments extends d3_overview_controller_pdfdocu
|
||||
Assert::that($oOrder->load($soxId))->true();
|
||||
$generator = $this->d3PdfGetGeneratorController();
|
||||
$generator->generatePdf($oOrder, $language);
|
||||
} catch (Exception $exception) {
|
||||
} catch (Throwable $exception) {
|
||||
$this->doReload = true;
|
||||
Registry::getLogger()->error($exception->getMessage(), [ 'exception' => $exception ]);
|
||||
$this->generatorError = 'PDF documents: ' . $exception->getMessage();
|
||||
@ -162,15 +161,13 @@ class d3_overview_controller_pdfdocuments extends d3_overview_controller_pdfdocu
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws ContainerExceptionInterface
|
||||
* @throws NotFoundExceptionInterface
|
||||
* @codeCoverageIgnore
|
||||
*/
|
||||
public function d3getGeneratorList(): ?registryOrderoverview
|
||||
{
|
||||
try {
|
||||
return ContainerFactory::getInstance()->getContainer()->get( registryOrderoverviewInterface::class );
|
||||
} catch (Exception $exception) {
|
||||
} catch (Throwable $exception) {
|
||||
Registry::getUtilsView()->addErrorToDisplay($exception->getMessage());
|
||||
}
|
||||
|
||||
|
@ -13,37 +13,17 @@
|
||||
|
||||
namespace D3\PdfDocuments\Tests\Unit\Application\Controller;
|
||||
|
||||
use Assert\InvalidArgumentException;
|
||||
use D3\PdfDocuments\Application\Controller\orderOverviewPdfGenerator;
|
||||
use D3\PdfDocuments\Application\Model\AbstractClasses\pdfdocumentsGeneric;
|
||||
use D3\PdfDocuments\Application\Model\Constants;
|
||||
use D3\PdfDocuments\Application\Model\Documents\invoicePdf;
|
||||
use D3\PdfDocuments\Application\Model\Exceptions\noPdfHandlerFoundException;
|
||||
use D3\PdfDocuments\Application\Model\Interfaces\pdfdocumentsGenericInterface as genericInterface;
|
||||
use D3\PdfDocuments\Application\Model\Interfaces\pdfdocumentsOrderInterface;
|
||||
use D3\PdfDocuments\Application\Model\Registries\registryOrderoverview;
|
||||
use D3\PdfDocuments\Application\Model\Registries\registryOrderoverviewInterface;
|
||||
use D3\TestingTools\Development\CanAccessRestricted;
|
||||
use Generator;
|
||||
use OxidEsales\Eshop\Application\Model\Order;
|
||||
use OxidEsales\Eshop\Core\Base;
|
||||
use OxidEsales\Eshop\Core\Exception\StandardException;
|
||||
use OxidEsales\Eshop\Core\Registry;
|
||||
use OxidEsales\Eshop\Core\UtilsView;
|
||||
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingServiceInterface;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Templating\TemplateRenderer;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Templating\TemplateRendererBridgeInterface;
|
||||
use OxidEsales\Twig\Resolver\TemplateChain\TemplateNotInChainException;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
use ReflectionException;
|
||||
use Spipu\Html2Pdf\Exception\Html2PdfException;
|
||||
use Spipu\Html2Pdf\Html2Pdf;
|
||||
use Symfony\Component\String\UnicodeString;
|
||||
use Twig\Error\Error;
|
||||
|
||||
class orderOverviewPdfGeneratorTest extends TestCase
|
||||
{
|
||||
|
@ -15,12 +15,12 @@ namespace D3\PdfDocuments\Tests\Unit\Application\Model\AbstractClasses;
|
||||
|
||||
use Assert\InvalidArgumentException;
|
||||
use D3\PdfDocuments\Application\Model\Documents\deliverynotePdf;
|
||||
use Exception;
|
||||
use Generator;
|
||||
use OxidEsales\Eshop\Application\Model\Order;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Bridge\ModuleConfigurationDaoBridge;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Bridge\ModuleConfigurationDaoBridgeInterface;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\DataObject\ModuleConfiguration;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Setting\Setting;
|
||||
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingService;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingServiceInterface;
|
||||
use ReflectionException;
|
||||
|
||||
abstract class pdfDocumentsOrder extends pdfDocumentsGeneric
|
||||
@ -155,47 +155,64 @@ abstract class pdfDocumentsOrder extends pdfDocumentsGeneric
|
||||
* @test
|
||||
* @covers \D3\PdfDocuments\Application\Model\AbstractClasses\pdfdocumentsOrder::getPaymentTerm
|
||||
* @throws ReflectionException
|
||||
* @dataProvider getPaymentTermDataProvider
|
||||
*/
|
||||
public function testGetPaymentTerm(bool $settingExist, $settingValue, int $expected): void
|
||||
public function testGetPaymentTerm(): void
|
||||
{
|
||||
$setting = $this->getMockBuilder(Setting::class)
|
||||
->onlyMethods(['getValue'])
|
||||
->getMock();
|
||||
$setting->method('getValue')->willReturn($settingValue);
|
||||
|
||||
$configuration = $this->getMockBuilder(ModuleConfiguration::class)
|
||||
->onlyMethods(['hasModuleSetting', 'getModuleSetting'])
|
||||
->getMock();
|
||||
$configuration->method('hasModuleSetting')->willReturn($settingExist);
|
||||
$configuration->method('getModuleSetting')->willReturn($setting);
|
||||
|
||||
$configurationBridge = $this->getMockBuilder(ModuleConfigurationDaoBridge::class)
|
||||
$settingService = $this->getMockBuilder(ModuleSettingService::class)
|
||||
->disableOriginalConstructor()
|
||||
->onlyMethods(['get'])
|
||||
->onlyMethods(['getInteger'])
|
||||
->getMock();
|
||||
$configurationBridge->method('get')->willReturn($configuration);
|
||||
$settingService->method('getInteger')->willReturn(10);
|
||||
|
||||
$this->addServiceMocks([
|
||||
ModuleConfigurationDaoBridgeInterface::class => $configurationBridge,
|
||||
ModuleSettingServiceInterface::class => $settingService,
|
||||
]);
|
||||
|
||||
$sut = oxNew($this->sutClassName);
|
||||
|
||||
$this->assertSame(
|
||||
$expected,
|
||||
$this->callMethod(
|
||||
$sut,
|
||||
'getPaymentTerm'
|
||||
)
|
||||
);
|
||||
try {
|
||||
$this->assertSame(
|
||||
10,
|
||||
$this->callMethod(
|
||||
$sut,
|
||||
'getPaymentTerm'
|
||||
)
|
||||
);
|
||||
} finally {
|
||||
ContainerFactory::resetContainer();
|
||||
}
|
||||
}
|
||||
|
||||
public static function getPaymentTermDataProvider(): Generator
|
||||
/**
|
||||
* @test
|
||||
* @covers \D3\PdfDocuments\Application\Model\AbstractClasses\pdfdocumentsOrder::getPaymentTerm
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function testGetPaymentTermUnknownSetting(): void
|
||||
{
|
||||
yield 'setting exists' => [true, 10, 10];
|
||||
yield 'setting value to low' => [true, -1, 0];
|
||||
yield 'setting does not exist' => [false, null, 7];
|
||||
$settingService = $this->getMockBuilder(ModuleSettingService::class)
|
||||
->disableOriginalConstructor()
|
||||
->onlyMethods(['getInteger'])
|
||||
->getMock();
|
||||
$settingService->method('getInteger')->willThrowException(new Exception());
|
||||
|
||||
$this->addServiceMocks([
|
||||
ModuleSettingServiceInterface::class => $settingService,
|
||||
]);
|
||||
|
||||
$sut = oxNew($this->sutClassName);
|
||||
|
||||
try {
|
||||
$this->assertSame(
|
||||
7,
|
||||
$this->callMethod(
|
||||
$sut,
|
||||
'getPaymentTerm'
|
||||
)
|
||||
);
|
||||
} finally {
|
||||
ContainerFactory::resetContainer();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -22,7 +22,6 @@ use org\bovigo\vfs\vfsStream;
|
||||
use OxidEsales\Eshop\Core\Config;
|
||||
use OxidEsales\Eshop\Core\Registry;
|
||||
use OxidEsales\Eshop\Core\Utils;
|
||||
use OxidEsales\Eshop\Core\UtilsView;
|
||||
use OxidEsales\EshopCommunity\Internal\Container\ContainerFactory;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingService;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingServiceInterface;
|
||||
|
@ -13,7 +13,6 @@
|
||||
|
||||
namespace D3\PdfDocuments\Tests\Unit\Application\Model\Exceptions;
|
||||
|
||||
use D3\PdfDocuments\Application\Model\Exceptions\noPdfHandlerFoundException;
|
||||
use D3\PdfDocuments\Application\Model\Exceptions\wrongPdfGeneratorInterface;
|
||||
use D3\TestingTools\Development\CanAccessRestricted;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
@ -14,19 +14,13 @@
|
||||
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
|
||||
|
@ -70,9 +70,8 @@ class orderDocument implements pdfdocumentsOrderInterface
|
||||
return 'filenameExtension';
|
||||
}
|
||||
|
||||
public function setDevelopmentMode(bool $devMode)
|
||||
public function setDevelopmentMode(bool $devMode): void
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public function setOrder(Order $order): void
|
||||
|
@ -13,16 +13,7 @@
|
||||
|
||||
namespace D3\PdfDocuments\Tests\Unit\Modules\Application\Controller;
|
||||
|
||||
use Assert\InvalidArgumentException;
|
||||
use D3\PdfDocuments\Application\Controller\orderOverviewPdfGenerator;
|
||||
use D3\PdfDocuments\Application\Model\AbstractClasses\pdfdocumentsGeneric;
|
||||
use D3\PdfDocuments\Application\Model\Constants;
|
||||
use D3\PdfDocuments\Application\Model\Documents\invoicePdf;
|
||||
use D3\PdfDocuments\Application\Model\Exceptions\noPdfHandlerFoundException;
|
||||
use D3\PdfDocuments\Application\Model\Interfaces\pdfdocumentsGenericInterface as genericInterface;
|
||||
use D3\PdfDocuments\Application\Model\Interfaces\pdfdocumentsOrderInterface;
|
||||
use D3\PdfDocuments\Application\Model\Registries\registryOrderoverview;
|
||||
use D3\PdfDocuments\Application\Model\Registries\registryOrderoverviewInterface;
|
||||
use D3\PdfDocuments\Modules\Application\Controller\d3_overview_controller_pdfdocuments;
|
||||
use D3\TestingTools\Development\CanAccessRestricted;
|
||||
use Doctrine\DBAL\Exception;
|
||||
@ -31,8 +22,6 @@ use Doctrine\DBAL\Query\Expression\ExpressionBuilder;
|
||||
use Doctrine\DBAL\Query\QueryBuilder;
|
||||
use Generator;
|
||||
use OxidEsales\Eshop\Application\Model\Order;
|
||||
use OxidEsales\Eshop\Core\Base;
|
||||
use OxidEsales\Eshop\Core\Exception\StandardException;
|
||||
use OxidEsales\Eshop\Core\Registry;
|
||||
use OxidEsales\Eshop\Core\Utils;
|
||||
use OxidEsales\Eshop\Core\UtilsView;
|
||||
@ -41,19 +30,9 @@ use OxidEsales\EshopCommunity\Internal\Framework\Database\QueryBuilderFactory;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Database\QueryBuilderFactoryInterface;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingService;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Module\Facade\ModuleSettingServiceInterface;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Templating\TemplateRenderer;
|
||||
use OxidEsales\EshopCommunity\Internal\Framework\Templating\TemplateRendererBridgeInterface;
|
||||
use OxidEsales\Twig\Resolver\TemplateChain\TemplateNotInChainException;
|
||||
use PHPUnit\Framework\MockObject\MockObject;
|
||||
use PHPUnit\Framework\MockObject\Rule\InvocationOrder;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use Psr\Container\ContainerExceptionInterface;
|
||||
use Psr\Container\NotFoundExceptionInterface;
|
||||
use ReflectionException;
|
||||
use Spipu\Html2Pdf\Exception\Html2PdfException;
|
||||
use Spipu\Html2Pdf\Html2Pdf;
|
||||
use Symfony\Component\String\UnicodeString;
|
||||
use Twig\Error\Error;
|
||||
|
||||
class d3_overview_controller_pdfdocumentsTest extends TestCase
|
||||
{
|
||||
@ -144,6 +123,35 @@ class d3_overview_controller_pdfdocumentsTest extends TestCase
|
||||
yield 'is prod' => [false];
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @covers \D3\PdfDocuments\Modules\Application\Controller\d3_overview_controller_pdfdocuments::d3PdfDocsIsDevMode
|
||||
* @throws ReflectionException
|
||||
*/
|
||||
public function testPdfDocsIsDevModeUnknownSetting(): void
|
||||
{
|
||||
$settingService = $this->getMockBuilder(ModuleSettingService::class)
|
||||
->onlyMethods(['getBoolean'])
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$settingService->method('getBoolean')->willThrowException(new Exception());
|
||||
|
||||
$this->addServiceMocks([ModuleSettingServiceInterface::class => $settingService]);
|
||||
|
||||
$sut = oxNew(d3_overview_controller_pdfdocuments::class);
|
||||
|
||||
try {
|
||||
$this->assertFalse(
|
||||
$this->callMethod(
|
||||
$sut,
|
||||
'd3PdfDocsIsDevMode'
|
||||
)
|
||||
);
|
||||
} finally {
|
||||
ContainerFactory::resetContainer();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
* @covers \D3\PdfDocuments\Modules\Application\Controller\d3_overview_controller_pdfdocuments::d3CanExport
|
||||
|
Reference in New Issue
Block a user