Skip to content

Commit

Permalink
Merge branch 'b-7.1.x' into b-7.2.x
Browse files Browse the repository at this point in the history
  • Loading branch information
Sieg committed Jul 2, 2024
2 parents aeb481f + 6c4cf67 commit 6456e0d
Show file tree
Hide file tree
Showing 31 changed files with 115 additions and 250 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@
use OxidEsales\EshopCommunity\Internal\Framework\Form\Form;
use OxidEsales\EshopCommunity\Internal\Framework\Form\FormField;
use OxidEsales\EshopCommunity\Internal\Domain\Contact\Form\ContactFormMessageBuilder;
use PHPUnit\Framework\Attributes\DataProvider;

class ContactFormMessageBuilderTest extends \PHPUnit\Framework\TestCase
{
/**
* @dataProvider fieldsProvider
*/
#[DataProvider('fieldsProvider')]
public function testContentGetter($name, $value)
{
$form = $this->getContactForm();
Expand Down
12 changes: 4 additions & 8 deletions tests/Unit/Internal/Domain/Email/EmailValidatorServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@
namespace OxidEsales\EshopCommunity\Tests\Unit\Internal\Domain\Email;

use OxidEsales\EshopCommunity\Internal\Utility\Email\EmailValidatorService;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

/**
* Class EmailValidatorServiceTest
*
* @covers \OxidEsales\EshopCommunity\Internal\Utility\Email\EmailValidatorService
*/
#[CoversClass(EmailValidatorService::class)]
class EmailValidatorServiceTest extends TestCase
{
public static function providerEmailsToValidate(): array
Expand All @@ -37,9 +35,7 @@ public static function providerEmailsToValidate(): array
];
}

/**
* @dataProvider providerEmailsToValidate
*/
#[DataProvider('providerEmailsToValidate')]
public function testValidateEmailWithValidEmail(string $email, bool $validMail): void
{
$mailValidator = new EmailValidatorService();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,11 @@
use OxidEsales\EshopCommunity\Internal\Domain\Review\Dao\ProductRatingDao;
use OxidEsales\EshopCommunity\Internal\Domain\Review\DataMapper\ProductRatingDataMapperInterface;
use \OxidEsales\EshopCommunity\Internal\Framework\Dao\InvalidObjectIdDaoException;
use PHPUnit\Framework\Attributes\DataProvider;

class ProductRatingDaoTest extends \PHPUnit\Framework\TestCase
{
/**
* @dataProvider invalidProductIdsProvider
*/
#[DataProvider('invalidProductIdsProvider')]
public function testGetProductByIdWithInvalidId($invalidProductId)
{
$this->expectException(InvalidObjectIdDaoException::class);
Expand Down
13 changes: 2 additions & 11 deletions tests/Unit/Internal/Framework/Database/Logger/QueryFilterTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,10 @@
namespace OxidEsales\EshopCommunity\Tests\Unit\Internal\Framework\Database\Logger;

use OxidEsales\EshopCommunity\Internal\Framework\Database\Logger\QueryFilter;
use PHPUnit\Framework\Attributes\DataProvider;

class QueryFilterTest extends \PHPUnit\Framework\TestCase
{

/**
* @return array
*/
public static function providerTestFiltering(): array
{
return [
Expand Down Expand Up @@ -79,13 +76,7 @@ public static function providerTestFiltering(): array
];
}

/**
* @param string $query
* @param array $skipLogTags
* @param bool $expected
*
* @dataProvider providerTestFiltering
*/
#[DataProvider('providerTestFiltering')]
public function testFiltering(string $query, array $skipLogTags, bool $expected)
{
$queryFilter = new QueryFilter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,16 @@
use InvalidArgumentException;
use OxidEsales\EshopCommunity\Internal\Framework\Logger\Configuration\PsrLoggerConfigurationInterface;
use OxidEsales\EshopCommunity\Internal\Framework\Logger\Validator\PsrLoggerConfigurationValidator;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\Attributes\DoesNotPerformAssertions;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Psr\Log\LogLevel;

class PsrLoggerConfigurationValidatorTest extends TestCase
{

/**
* @dataProvider dataProviderValidLogLevels
* @doesNotPerformAssertions
*/
#[DataProvider('dataProviderValidLogLevels')]
#[DoesNotPerformAssertions]
public function testValidLogLevelValidation($logLevel)
{
/** @var MockObject|PsrLoggerConfigurationInterface $configurationMock */
Expand Down Expand Up @@ -50,9 +49,7 @@ public static function dataProviderValidLogLevels(): array
];
}

/**
* @dataProvider dataProviderInvalidLogLevels
*/
#[DataProvider('dataProviderInvalidLogLevels')]
public function testInvalidLogLevelValidation($logLevel)
{
$this->expectException(InvalidArgumentException::class);
Expand Down
19 changes: 6 additions & 13 deletions tests/Unit/Internal/Framework/Logger/Wrapper/LoggerWrapperTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace OxidEsales\EshopCommunity\Tests\Unit\Internal\Framework\Logger\Wrapper;

use OxidEsales\EshopCommunity\Internal\Framework\Logger\Wrapper\LoggerWrapper;
use PHPUnit\Framework\Attributes\DataProvider;
use Psr\Log\LoggerInterface;

/**
Expand All @@ -19,26 +20,21 @@
*/
class LoggerWrapperTest extends \PHPUnit\Framework\TestCase
{

/**
* @dataProvider dataProviderPsrInterfaceMethods
*
* @param string $methodName The name of the method to test
*/
public function testAllInterfaceMethodsExceptLogAreHandled($methodName)
#[DataProvider('dataProviderPsrInterfaceMethods')]
public function testAllInterfaceMethodsExceptLogAreHandled(string $methodNameToTest)
{
$messageToLog = "The message is {myMessage}";
$contextToLog = ['myMessage' => 'Hello World!'];
$loggerMock = $this->getLoggerMock();
$loggerMock->expects($this->once())
->method($methodName)
->method($methodNameToTest)
->with(
$this->equalTo($messageToLog),
$this->equalTo($contextToLog)
);

$loggerServiceWrapper = new LoggerWrapper($loggerMock);
$loggerServiceWrapper->$methodName($messageToLog, $contextToLog);
$loggerServiceWrapper->$methodNameToTest($messageToLog, $contextToLog);
}

/**
Expand Down Expand Up @@ -77,10 +73,7 @@ public function testLog()
$loggerServiceWrapper->log($levelToLog, $messageToLog, $contextToLog);
}

/**
* @return LoggerInterface
*/
private function getLoggerMock()
private function getLoggerMock(): LoggerInterface
{
$loggerMock = $this
->getMockBuilder(LoggerInterface::class)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Cache\ClassPropertyModuleConfigurationCache;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\DataObject\ModuleConfiguration;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\DataObject\ShopConfiguration;
use PHPUnit\Framework\Attributes\DoesNotPerformAssertions;
use PHPUnit\Framework\TestCase;

final class ClassPropertyModuleConfigurationCacheTest extends TestCase
Expand Down Expand Up @@ -41,9 +42,7 @@ public function testExists(): void
$this->assertTrue($cache->exists('test',1));
}

/**
* @doesNotPerformAssertions
*/
#[DoesNotPerformAssertions]
public function testNotExistentEvict(): void
{
$cache = new ClassPropertyModuleConfigurationCache();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,21 +16,14 @@
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\DataMapper\ModuleConfigurationDataMapperInterface;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\DataObject\ModuleConfiguration;
use OxidEsales\EshopCommunity\Tests\ContainerTrait;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

/**
* @internal
*/
class ModuleConfigurationDataMapperTest extends TestCase
{
use ContainerTrait;

/**
* @dataProvider moduleConfigurationDataProvider
*
* @param array $data
* @param ModuleConfigurationDataMapperInterface $dataMapper
*/
#[DataProvider('moduleConfigurationDataProvider')]
public function testToDataAndFromData(array $data, ModuleConfigurationDataMapperInterface $dataMapper)
{

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@
namespace OxidEsales\EshopCommunity\Tests\Unit\Internal\Framework\Module\Configuration\DataObject;

use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\DataObject\ClassExtensionsChain;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\DataObject\ModuleConfiguration\ClassExtension;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Configuration\Exception\ExtensionNotInChainException;
/**
* @internal
*/

class ClassExtensionsChainTest extends TestCase
{
public function testAddExtensionsIfChainIsEmpty()
Expand Down Expand Up @@ -137,12 +136,7 @@ public function testRemoveExtension()
);
}

/**
* @dataProvider invalidExtensionProvider
*
* @param ClassExtension $extension
*
*/
#[DataProvider('invalidExtensionProvider')]
public function testRemoveExtensionThrowsExceptionIfClassNotExistsInChain(ClassExtension $extension)
{
$this->expectException(ExtensionNotInChainException::class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use OxidEsales\EshopCommunity\Internal\Framework\Module\Install\Service\BootstrapModuleInstaller;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Install\Service\ModuleConfigurationInstallerInterface;
use OxidEsales\EshopCommunity\Internal\Framework\Module\Install\Service\ModuleFilesInstallerInterface;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

class BootstrapModuleInstallerTest extends TestCase
Expand All @@ -39,9 +40,7 @@ public function testInstallTriggersAllInstallers()
$moduleInstaller->install($package);
}

/**
* @dataProvider moduleInstallMatrixDataProvider
*/
#[DataProvider('moduleInstallMatrixDataProvider')]
public function testIsInstalled(bool $filesInstalled, bool $projectConfigurationInstalled, bool $moduleInstalled)
{
$moduleFilesInstaller = $this->getMockBuilder(ModuleFilesInstallerInterface::class)->getMock();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@

use OxidEsales\EshopCommunity\Internal\Framework\Module\MetaData\Converter\MetaDataConverterInterface;
use OxidEsales\EshopCommunity\Internal\Framework\Module\MetaData\Converter\MetaDataConverterAggregate;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\TestCase;

/**
* @covers \OxidEsales\EshopCommunity\Internal\Framework\Module\MetaData\Converter\MetaDataConverterAggregate
*/
#[CoversClass(MetaDataConverterAggregate::class)]
class MetaDataConverterAggregateTest extends TestCase
{
public function testConvert(): void
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

use OxidEsales\EshopCommunity\Internal\Framework\Module\MetaData\Converter\ModuleSettingsBooleanConverter;
use OxidEsales\EshopCommunity\Internal\Framework\Module\MetaData\Dao\MetaDataProvider;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

class ModuleSettingsBooleanConverterTest extends TestCase
Expand All @@ -26,9 +27,7 @@ public static function convertToTrueDataProvider(): array
];
}

/**
* @dataProvider convertToTrueDataProvider
*/
#[DataProvider('convertToTrueDataProvider')]
public function testConvertToTrue($value): void
{
$metaData =
Expand Down Expand Up @@ -56,9 +55,7 @@ public static function convertToFalseDataProvider(): array
];
}

/**
* @dataProvider convertToFalseDataProvider
*/
#[DataProvider('convertToFalseDataProvider')]
public function testConvertToFalse($value): void
{
$metaData =
Expand Down Expand Up @@ -91,9 +88,7 @@ public static function whenNothingToConvertDataProvider(): array
];
}

/**
* @dataProvider whenNothingToConvertDataProvider
*/
#[DataProvider('whenNothingToConvertDataProvider')]
public function testWhenNothingToConvert(array $metaData): void
{
$converter = new ModuleSettingsBooleanConverter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace OxidEsales\EshopCommunity\Tests\Unit\Internal\Framework\Module\MetaData\Dao;

use OxidEsales\EshopCommunity\Internal\Framework\Module\MetaData\Dao\MetaDataNormalizer;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

class MetaDataNormalizerTest extends TestCase
Expand Down Expand Up @@ -60,9 +61,7 @@ public function testNormalizerConvertsModuleSettingConstraintsToArray()
);
}

/**
* @dataProvider multiLanguageFieldDataProvider
*/
#[DataProvider('multiLanguageFieldDataProvider')]
public function testNormalizerConvertsMultiLanguageFieldToArrayWithDefaultLanguageIfItIsString(string $fieldName, string $value)
{
$metadata = [
Expand All @@ -79,9 +78,7 @@ public function testNormalizerConvertsMultiLanguageFieldToArrayWithDefaultLangua
);
}

/**
* @dataProvider multiLanguageFieldDataProvider
*/
#[DataProvider('multiLanguageFieldDataProvider')]
public function testNormalizerConvertsMultiLanguageFieldToArrayWithCustomLanguageIfItIsStringAndLangOptionIsSet(string $fieldName, string $value)
{
$metadata = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use OxidEsales\EshopCommunity\Internal\Framework\Module\MetaData\Exception\UnsupportedMetaDataValueTypeException;
use OxidEsales\EshopCommunity\Internal\Framework\Module\MetaData\Exception\UnsupportedMetaDataVersionException;
use OxidEsales\EshopCommunity\Internal\Framework\Module\MetaData\Validator\MetaDataSchemaValidator;
use PHPUnit\Framework\Attributes\DoesNotPerformAssertions;
use PHPUnit\Framework\TestCase;

class MetaDataSchemaValidatorTest extends TestCase
Expand Down Expand Up @@ -78,8 +79,8 @@ public function testValidateUnsupportedMetaDataSubKey()

/**
* This test covers metaData sections like 'extend', or 'templates', which have their custom subKeys
* @doesNotPerformAssertions
*/
#[DoesNotPerformAssertions]
public function testExcludedSectionItemValidation()
{
$metaDataToValidate = [
Expand Down Expand Up @@ -144,9 +145,7 @@ public function testValidateThrowsExceptionOnUnsupportedMetaDataValueType()
$validator->validate('path/to/metadata.php', '2.0', $metaDataToValidate);
}

/**
* @doesNotPerformAssertions
*/
#[DoesNotPerformAssertions]
public function testValidateThrowsNoExceptionOnIncompleteFirstLevel()
{
$metaDataToValidate = [
Expand All @@ -165,9 +164,7 @@ public function testValidateThrowsNoExceptionOnIncompleteFirstLevel()
$validator->validate('path/to/metadata.php', '2.0', $metaDataToValidate);
}

/**
* @doesNotPerformAssertions
*/
#[DoesNotPerformAssertions]
public function testValidateThrowsNoExceptionOnIncompleteSecondLevel()
{
$metaDataToValidate = [
Expand Down
Loading

0 comments on commit 6456e0d

Please sign in to comment.