Skip to content

Commit

Permalink
Merge branch 'b-7.0.x-shop_exception_if_setting_not_exist-OXDEV-7670'…
Browse files Browse the repository at this point in the history
… into b-7.0.x
  • Loading branch information
angel-dimitrov committed Dec 18, 2023
2 parents 8e96950 + 14fb9e5 commit ebd7559
Showing 1 changed file with 68 additions and 0 deletions.
68 changes: 68 additions & 0 deletions tests/Integration/Infrastructure/ShopSettingRepositoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

use Doctrine\DBAL\Connection;
use OxidEsales\EshopCommunity\Internal\Framework\Config\Dao\ShopConfigurationSettingDaoInterface;
use OxidEsales\EshopCommunity\Internal\Framework\Dao\EntryDoesNotExistDaoException;
use OxidEsales\EshopCommunity\Internal\Framework\Database\QueryBuilderFactoryInterface;
use OxidEsales\EshopCommunity\Internal\Transition\Utility\BasicContextInterface;
use OxidEsales\EshopCommunity\Tests\Integration\IntegrationTestCase;
Expand Down Expand Up @@ -53,6 +54,73 @@ public function testGetSettingsListOnNoSettingsThrowsException(): void
$sut->getSettingsList();
}

/**
* @dataProvider exceptionGetterDataProvider
*/
public function testGetterExceptionIfSettingNotExist(string $getterMethod): void
{
$sut = $this->getSutForShop(2);

$this->expectException(EntryDoesNotExistDaoException::class);
$this->expectExceptionMessage('Setting NotExistant doesn\'t exist in the shop with id 2');
$sut->$getterMethod('NotExistant');
}

public function exceptionGetterDataProvider(): \Generator
{
yield ['getInteger'];
yield ['getFloat'];
yield ['getBoolean'];
yield ['getString'];
yield ['getSelect'];
yield ['getCollection'];
yield ['getAssocCollection'];
}

/**
* @dataProvider exceptionSetterDataProvider
*/
public function testSetterExceptionIfSettingNotExist(string $setterMethod, mixed $value): void
{
$sut = $this->getSutForShop(2);

$this->expectException(EntryDoesNotExistDaoException::class);
$this->expectExceptionMessage('Setting NotExistant doesn\'t exist in the shop with id 2');
$sut->$setterMethod('NotExistant', $value);
}

public function exceptionSetterDataProvider(): \Generator
{
yield [
'setterMethod' => 'saveIntegerSetting',
'value' => 123
];
yield [
'setterMethod' => 'saveFloatSetting',
'value' => 1.23
];
yield [
'setterMethod' => 'saveBooleanSetting',
'value' => true
];
yield [
'setterMethod' => 'saveStringSetting',
'value' => 'string'
];
yield [
'setterMethod' => 'saveSelectSetting',
'value' => 'select'
];
yield [
'setterMethod' => 'saveCollectionSetting',
'value' => ['nice', 'collection']
];
yield [
'setterMethod' => 'saveAssocCollectionSetting',
'value' => ['first' => 'nice', 'second' => 'collection']
];
}

private function getDbConnection(): Connection
{
/** @var QueryBuilderFactoryInterface $queryBuilderFactory */
Expand Down

0 comments on commit ebd7559

Please sign in to comment.