2024-09-03 14:13:47 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
|
|
|
|
*
|
|
|
|
* 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\Ordermanager\tests\integration\Requirements;
|
|
|
|
|
|
|
|
use D3\ModCfg\Application\Model\Exception\d3_cfg_mod_exception;
|
|
|
|
use D3\ModCfg\Application\Model\Exception\d3ShopCompatibilityAdapterException;
|
|
|
|
use D3\Ordermanager\Application\Model\d3ordermanager;
|
|
|
|
use D3\Ordermanager\Application\Model\Exceptions\d3ordermanager_requirementException;
|
2024-12-11 15:29:52 +01:00
|
|
|
use D3\Ordermanager\Application\Model\Requirements\d3ordermanager_requirement_orderfield;
|
2024-09-03 14:13:47 +02:00
|
|
|
use Doctrine\DBAL\Exception as DBALException;
|
|
|
|
use Exception;
|
|
|
|
use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException;
|
|
|
|
use OxidEsales\Eshop\Core\Exception\DatabaseErrorException;
|
|
|
|
use OxidEsales\Eshop\Core\Exception\StandardException;
|
|
|
|
use PHPUnit\Framework\MockObject\MockObject;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @coversNothing
|
|
|
|
*/
|
|
|
|
class requirementOrderFieldTest extends d3OrdermanagerRequirementIntegrationTestCase
|
|
|
|
{
|
|
|
|
public $sManagerId = 'managerTestId';
|
|
|
|
public $aOrderIdList = [
|
|
|
|
'orderTestIdNo1',
|
|
|
|
'orderTestIdNo2',
|
2024-12-11 15:29:52 +01:00
|
|
|
'orderTestIdNo3',
|
|
|
|
'orderTestIdNo4',
|
2024-09-03 14:13:47 +02:00
|
|
|
];
|
|
|
|
public $aOrderArticleIdList = [
|
|
|
|
'orderTestIdNo1Article1',
|
|
|
|
'orderTestIdNo2Article1',
|
|
|
|
];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Set up fixture.
|
|
|
|
* @throws Exception
|
|
|
|
*/
|
|
|
|
public function setUp(): void
|
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
|
|
|
|
$this->createTestData();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Tear down fixture.
|
|
|
|
* @throws DBALException
|
|
|
|
* @throws DatabaseConnectionException
|
|
|
|
* @throws DatabaseErrorException
|
|
|
|
*/
|
|
|
|
public function tearDown(): void
|
|
|
|
{
|
|
|
|
$this->cleanTestData();
|
|
|
|
|
|
|
|
parent::tearDown();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @throws Exception
|
|
|
|
*/
|
|
|
|
public function createTestData()
|
|
|
|
{
|
|
|
|
$this->createManager(
|
|
|
|
$this->sManagerId
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->createOrder(
|
|
|
|
$this->aOrderIdList[0],
|
|
|
|
[
|
|
|
|
'oxorderdate' => '2018-01-01 00:00:00',
|
|
|
|
'oxbillcompany' => __CLASS__,
|
|
|
|
'oxcardid' => 'testContent',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
$this->aOrderArticleIdList[0] => [
|
|
|
|
'oxtitle' => __CLASS__,
|
|
|
|
],
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->createOrder(
|
|
|
|
$this->aOrderIdList[1],
|
|
|
|
[
|
|
|
|
'oxorderdate' => '2018-01-01 00:00:00',
|
|
|
|
'oxbillcompany' => __CLASS__,
|
|
|
|
'oxcardid' => null,
|
|
|
|
],
|
|
|
|
[
|
|
|
|
$this->aOrderArticleIdList[1] => [
|
|
|
|
'oxtitle' => __CLASS__,
|
|
|
|
],
|
|
|
|
]
|
|
|
|
);
|
2024-12-11 15:29:52 +01:00
|
|
|
|
|
|
|
$this->createOrder(
|
|
|
|
$this->aOrderIdList[2],
|
|
|
|
[
|
|
|
|
'oxorderdate' => '2018-01-01 00:00:00',
|
|
|
|
'oxbillcompany' => __CLASS__,
|
|
|
|
'oxcardid' => 0,
|
|
|
|
],
|
|
|
|
[
|
|
|
|
$this->aOrderArticleIdList[1] => [
|
|
|
|
'oxtitle' => __CLASS__,
|
|
|
|
],
|
|
|
|
]
|
|
|
|
);
|
|
|
|
|
|
|
|
$this->createOrder(
|
|
|
|
$this->aOrderIdList[3],
|
|
|
|
[
|
|
|
|
'oxorderdate' => '2018-01-01 00:00:00',
|
|
|
|
'oxbillcompany' => __CLASS__,
|
|
|
|
'oxcardid' => '0000-00-00',
|
|
|
|
],
|
|
|
|
[
|
|
|
|
$this->aOrderArticleIdList[1] => [
|
|
|
|
'oxtitle' => __CLASS__,
|
|
|
|
],
|
|
|
|
]
|
|
|
|
);
|
2024-09-03 14:13:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @throws DBALException
|
|
|
|
*/
|
|
|
|
public function cleanTestData()
|
|
|
|
{
|
|
|
|
$this->deleteManager($this->sManagerId);
|
|
|
|
|
|
|
|
foreach ($this->aOrderIdList as $sOrderId) {
|
|
|
|
$this->deleteOrder($sOrderId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return d3ordermanager
|
|
|
|
* @throws Exception
|
|
|
|
*/
|
|
|
|
public function getConfiguredManagerContent()
|
|
|
|
{
|
|
|
|
$oManager = $this->getManagerMock($this->sManagerId);
|
|
|
|
|
|
|
|
$oManager->setValue('blCheckOrderField_status', true);
|
|
|
|
$oManager->setValue('sOrderField_FieldName', ' oxcardid');
|
2024-12-11 15:29:52 +01:00
|
|
|
$oManager->setValue('sCheckOrderFieldType', d3ordermanager_requirement_orderfield::TYPE_CONTENT);
|
2024-09-03 14:13:47 +02:00
|
|
|
$oManager->setValue('sOrderField_FieldValue', 'testContent');
|
2024-12-11 15:29:52 +01:00
|
|
|
$oManager->setValue('sOrderField_FieldNoValue', '');
|
2024-09-03 14:13:47 +02:00
|
|
|
|
|
|
|
return $oManager;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
* @throws DBALException
|
|
|
|
* @throws DatabaseConnectionException
|
|
|
|
* @throws DatabaseErrorException
|
|
|
|
* @throws StandardException
|
|
|
|
* @throws d3ShopCompatibilityAdapterException
|
|
|
|
* @throws d3_cfg_mod_exception
|
|
|
|
* @throws Exception
|
|
|
|
*/
|
|
|
|
public function requirementsSelectsRightOrdersContent()
|
|
|
|
{
|
|
|
|
$oListGenerator = $this->getListGenerator($this->getConfiguredManagerContent());
|
|
|
|
$oOrderList = $oListGenerator->getConcernedItems();
|
|
|
|
|
2024-12-11 15:29:52 +01:00
|
|
|
$this->assertTrue($oOrderList->count() >= 1);
|
|
|
|
$this->assertTrue($oOrderList->offsetExists($this->aOrderIdList[0]));
|
|
|
|
$this->assertFalse($oOrderList->offsetExists($this->aOrderIdList[1]));
|
|
|
|
$this->assertFalse($oOrderList->offsetExists($this->aOrderIdList[2]));
|
|
|
|
$this->assertFalse($oOrderList->offsetExists($this->aOrderIdList[3]));
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return d3ordermanager
|
|
|
|
* @throws Exception
|
|
|
|
*/
|
|
|
|
public function getConfiguredManagerNoContent()
|
|
|
|
{
|
|
|
|
$oManager = $this->getManagerMock($this->sManagerId);
|
|
|
|
|
|
|
|
$oManager->setValue('blCheckOrderField_status', true);
|
|
|
|
$oManager->setValue('sOrderField_FieldName', ' oxcardid');
|
|
|
|
$oManager->setValue('sCheckOrderFieldType', d3ordermanager_requirement_orderfield::TYPE_NOCONTENT);
|
|
|
|
$oManager->setValue('sOrderField_FieldValue', '');
|
|
|
|
$oManager->setValue('sOrderField_FieldNoValue', 'testContent');
|
|
|
|
|
|
|
|
return $oManager;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
* @throws DBALException
|
|
|
|
* @throws DatabaseConnectionException
|
|
|
|
* @throws DatabaseErrorException
|
|
|
|
* @throws StandardException
|
|
|
|
* @throws d3ShopCompatibilityAdapterException
|
|
|
|
* @throws d3_cfg_mod_exception
|
|
|
|
* @throws Exception
|
|
|
|
*/
|
|
|
|
public function requirementsSelectsRightOrdersNoContent()
|
|
|
|
{
|
|
|
|
$oListGenerator = $this->getListGenerator($this->getConfiguredManagerNoContent());
|
|
|
|
$oOrderList = $oListGenerator->getConcernedItems();
|
|
|
|
|
|
|
|
$this->assertTrue($oOrderList->count() >= 3, $oOrderList->count().' orders found');
|
|
|
|
$this->assertFalse($oOrderList->offsetExists($this->aOrderIdList[0]));
|
|
|
|
$this->assertTrue($oOrderList->offsetExists($this->aOrderIdList[1]));
|
|
|
|
$this->assertTrue($oOrderList->offsetExists($this->aOrderIdList[2]));
|
|
|
|
$this->assertTrue($oOrderList->offsetExists($this->aOrderIdList[3]));
|
2024-09-03 14:13:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return d3ordermanager
|
|
|
|
* @throws Exception
|
|
|
|
*/
|
|
|
|
public function getConfiguredManagerNotEmpty()
|
|
|
|
{
|
|
|
|
$oManager = $this->getManagerMock($this->sManagerId);
|
|
|
|
|
|
|
|
$oManager->setValue('blCheckOrderField_status', true);
|
|
|
|
$oManager->setValue('sOrderField_FieldName', ' oxcardid');
|
2024-12-11 15:29:52 +01:00
|
|
|
$oManager->setValue('sCheckOrderFieldType', d3ordermanager_requirement_orderfield::TYPE_NOTEMPTY);
|
2024-09-03 14:13:47 +02:00
|
|
|
$oManager->setValue('sOrderField_FieldValue', '');
|
2024-12-11 15:29:52 +01:00
|
|
|
$oManager->setValue('sOrderField_FieldNoValue', '');
|
2024-09-03 14:13:47 +02:00
|
|
|
|
|
|
|
return $oManager;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
* @throws DBALException
|
|
|
|
* @throws DatabaseConnectionException
|
|
|
|
* @throws DatabaseErrorException
|
|
|
|
* @throws StandardException
|
|
|
|
* @throws d3ShopCompatibilityAdapterException
|
|
|
|
* @throws d3_cfg_mod_exception
|
|
|
|
* @throws Exception
|
|
|
|
*/
|
2024-12-11 15:29:52 +01:00
|
|
|
public function requirementsSelectsRightOrdersNotEmpty()
|
2024-09-03 14:13:47 +02:00
|
|
|
{
|
|
|
|
$oListGenerator = $this->getListGenerator($this->getConfiguredManagerNotEmpty());
|
|
|
|
$oOrderList = $oListGenerator->getConcernedItems();
|
|
|
|
|
2024-12-11 15:29:52 +01:00
|
|
|
$this->assertTrue($oOrderList->count() >= 3, $oOrderList->count().' orders found');
|
|
|
|
$this->assertTrue($oOrderList->offsetExists($this->aOrderIdList[0]));
|
|
|
|
$this->assertFalse($oOrderList->offsetExists($this->aOrderIdList[1]));
|
|
|
|
$this->assertTrue($oOrderList->offsetExists($this->aOrderIdList[2]));
|
|
|
|
$this->assertTrue($oOrderList->offsetExists($this->aOrderIdList[3]));
|
2024-09-03 14:13:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return d3ordermanager
|
|
|
|
* @throws Exception
|
|
|
|
*/
|
|
|
|
public function getConfiguredManagerEmpty()
|
|
|
|
{
|
|
|
|
$oManager = $this->getManagerMock($this->sManagerId);
|
|
|
|
|
|
|
|
$oManager->setValue('blCheckOrderField_status', true);
|
|
|
|
$oManager->setValue('sOrderField_FieldName', ' oxcardid');
|
2024-12-11 15:29:52 +01:00
|
|
|
$oManager->setValue('sCheckOrderFieldType', d3ordermanager_requirement_orderfield::TYPE_EMPTY);
|
2024-09-03 14:13:47 +02:00
|
|
|
$oManager->setValue('sOrderField_FieldValue', '');
|
2024-12-11 15:29:52 +01:00
|
|
|
$oManager->setValue('sOrderField_FieldNoValue', '');
|
2024-09-03 14:13:47 +02:00
|
|
|
|
|
|
|
return $oManager;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
* @throws DBALException
|
|
|
|
* @throws DatabaseConnectionException
|
|
|
|
* @throws DatabaseErrorException
|
|
|
|
* @throws StandardException
|
|
|
|
* @throws d3ShopCompatibilityAdapterException
|
|
|
|
* @throws d3_cfg_mod_exception
|
|
|
|
* @throws Exception
|
|
|
|
*/
|
|
|
|
public function requirementsSelectsRightOrdersEmpty()
|
|
|
|
{
|
|
|
|
$oListGenerator = $this->getListGenerator($this->getConfiguredManagerEmpty());
|
|
|
|
$oOrderList = $oListGenerator->getConcernedItems();
|
|
|
|
|
2024-12-11 15:29:52 +01:00
|
|
|
$this->assertTrue($oOrderList->count() >= 1, $oOrderList->count().' orders found');
|
|
|
|
$this->assertFalse($oOrderList->offsetExists($this->aOrderIdList[0]));
|
|
|
|
$this->assertFalse($oOrderList->offsetExists($this->aOrderIdList[2]));
|
|
|
|
$this->assertFalse($oOrderList->offsetExists($this->aOrderIdList[3]));
|
|
|
|
$this->assertTrue($oOrderList->offsetExists($this->aOrderIdList[1]));
|
2024-09-03 14:13:47 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param $invalidValue
|
|
|
|
*
|
|
|
|
* @return d3ordermanager|MockObject
|
|
|
|
* @throws DBALException
|
|
|
|
* @throws DatabaseConnectionException
|
|
|
|
* @throws DatabaseErrorException
|
|
|
|
*/
|
|
|
|
public function getConfiguredManagerNoValidConfig($invalidValue)
|
|
|
|
{
|
|
|
|
$oManager = $this->getManagerMock($this->sManagerId);
|
|
|
|
|
|
|
|
$oManager->setValue('blCheckOrderField_status', true);
|
|
|
|
$oManager->setValue('sOrderField_FieldName', $invalidValue);
|
|
|
|
|
|
|
|
return $oManager;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @test
|
|
|
|
* @param $testValue
|
|
|
|
* @throws DBALException
|
|
|
|
* @throws DatabaseConnectionException
|
|
|
|
* @throws DatabaseErrorException
|
|
|
|
* @throws StandardException
|
|
|
|
* @throws d3ShopCompatibilityAdapterException
|
|
|
|
* @throws d3_cfg_mod_exception
|
|
|
|
* @throws Exception
|
|
|
|
* @dataProvider requirementsSelectsRightOrdersNoValidConfigDataProvider
|
|
|
|
*/
|
|
|
|
public function requirementsSelectsRightOrdersNoValidConfig($testValue)
|
|
|
|
{
|
|
|
|
$this->expectException(d3ordermanager_requirementException::class);
|
|
|
|
|
|
|
|
$oListGenerator = $this->getListGenerator($this->getConfiguredManagerNoValidConfig($testValue));
|
|
|
|
$oListGenerator->getConcernedItems();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return array
|
|
|
|
*/
|
|
|
|
public function requirementsSelectsRightOrdersNoValidConfigDataProvider(): array
|
|
|
|
{
|
|
|
|
return [
|
|
|
|
'unknown'=> ['unknownValue'],
|
|
|
|
'space' => [' '],
|
|
|
|
'empty' => [''],
|
|
|
|
'false' => [false],
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|