Skip to content

Commit

Permalink
Removed global option "enableunseenonly" from config
Browse files Browse the repository at this point in the history
  • Loading branch information
HorstOeko committed Oct 26, 2024
1 parent debc15e commit e97bc19
Show file tree
Hide file tree
Showing 7 changed files with 1 addition and 99 deletions.
5 changes: 0 additions & 5 deletions src/ZugferdMailReader.php
Original file line number Diff line number Diff line change
Expand Up @@ -152,11 +152,6 @@ protected function checkSingleAccountFolder(ZugferdMailAccount $account, Folder
{
if (in_array($folder->full_name, $account->getFoldersTowatch())) {
$folder->messages()->all()->when(
$this->config->getUnseenMessagesOnlyEnabled(),
function ($query) {
return $query->unseen();
}
)->when(
$account->getUnseenMessagesOnlyEnabled(),
function ($query) {
return $query->unseen();
Expand Down
4 changes: 1 addition & 3 deletions src/concerns/ZugferdMailConsoleHandlesConfigOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ protected function configureConfigOptions()
$this->addOption('enableublsupport', null, InputOption::VALUE_NONE, 'Enable UBL support')
->addOption('enablesymfonyvalidation', null, InputOption::VALUE_NONE, 'Enable Symfony validation')
->addOption('enablexsdvalidation', null, InputOption::VALUE_NONE, 'Enable XSD validation')
->addOption('enablekositvalidation', null, InputOption::VALUE_NONE, 'Enable Kosit validation')
->addOption('enableunseenonly', null, InputOption::VALUE_NONE, 'Process only unseen messages');
->addOption('enablekositvalidation', null, InputOption::VALUE_NONE, 'Enable Kosit validation');

return $this;
}
Expand All @@ -55,7 +54,6 @@ protected function createConfigFromOptions(InputInterface $input): ZugferdMailCo
$config->setSymfonyValidationEnabled($input->hasOption('enablesymfonyvalidation') ? $input->getOption('enablesymfonyvalidation') : false);
$config->setXsdValidationEnabled($input->hasOption('enablexsdvalidation') ? $input->getOption('enablexsdvalidation') : false);
$config->setKositValidationEnabled($input->hasOption('enablekositvalidation') ? $input->getOption('enablekositvalidation') : false);
$config->setUnseenMessagesOnlyEnabled($input->hasOption('enableunseenonly') ? $input->getOption('enableunseenonly') : false);

return $config;
}
Expand Down
52 changes: 0 additions & 52 deletions src/config/ZugferdMailConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,6 @@ class ZugferdMailConfig
*/
protected $kositValidationEnabled = false;

/**
* Look for unseen messages only
*
* @var boolean
*/
protected $unseenMessagesOnlyEnabled = false;

/**
* List of defined accounts
*
Expand Down Expand Up @@ -314,49 +307,6 @@ public function deactivateKositValidation(): ZugferdMailConfig
return $this->setKositValidationEnabled(false);
}

/**
* Returns true if only unssen messages are processed, otherwise false
*
* @return boolean
*/
public function getUnseenMessagesOnlyEnabled(): bool
{
return $this->unseenMessagesOnlyEnabled;
}

/**
* Activate or deactivate the processing only of unseen messages
*
* @param boolean $unseenMessagesOnly
* @return ZugferdMailConfig
*/
public function setUnseenMessagesOnlyEnabled(bool $unseenMessagesOnly): ZugferdMailConfig
{
$this->unseenMessagesOnlyEnabled = $unseenMessagesOnly;

return $this;
}

/**
* Activate the processing only of unseen messages
*
* @return ZugferdMailConfig
*/
public function activateUnseenMessagesOnly(): ZugferdMailConfig
{
return $this->setUnseenMessagesOnlyEnabled(true);
}

/**
* Deactivate the processing only of unseen messages
*
* @return ZugferdMailConfig
*/
public function deactivateUnseenMessagesOnly(): ZugferdMailConfig
{
return $this->setUnseenMessagesOnlyEnabled(false);
}

/**
* Add an account definition
*
Expand Down Expand Up @@ -495,7 +445,6 @@ public static function loadFromFile(string $filename): ZugferdMailConfig
$config->setSymfonyValidationEnabled($jsonObject->symfonyValidationEnabled);
$config->setXsdValidationEnabled($jsonObject->xsdValidationEnabled);
$config->setKositValidationEnabled($jsonObject->kositValidationEnabled);
$config->setUnseenMessagesOnlyEnabled($jsonObject->unseenMessagesOnlyEnabled);

foreach ($jsonObject->accounts as $accountDefinition) {
$account = new ZugferdMailAccount();
Expand Down Expand Up @@ -540,7 +489,6 @@ public function saveToFile(string $filename): ZugferdMailConfig
$jsonObject->symfonyValidationEnabled = $this->getSymfonyValidationEnabled();
$jsonObject->xsdValidationEnabled = $this->getXsdValidationEnabled();
$jsonObject->kositValidationEnabled = $this->getKositValidationEnabled();
$jsonObject->unseenMessagesOnlyEnabled = $this->getUnseenMessagesOnlyEnabled();
$jsonObject->accounts = [];

foreach ($this->getAccounts() as $account) {
Expand Down
4 changes: 0 additions & 4 deletions src/config/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
"symfonyValidationEnabled",
"xsdValidationEnabled",
"kositValidationEnabled",
"unseenMessagesOnlyEnabled",
"accounts"
],
"properties": {
Expand All @@ -27,9 +26,6 @@
"kositValidationEnabled": {
"type": "boolean"
},
"unseenMessagesOnlyEnabled": {
"type": "boolean"
},
"accounts": {
"type": "array",
"items": {
Expand Down
1 change: 0 additions & 1 deletion tests/assets/config.valid.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"symfonyValidationEnabled": true,
"xsdValidationEnabled": true,
"kositValidationEnabled": true,
"unseenMessagesOnlyEnabled": true,
"accounts": [
{
"identifier": "DC38517A-6410-421E-947D-0E971A1F9A28",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ public function testInputInterface(): void
'--enablesymfonyvalidation' => null,
'--enablexsdvalidation' => null,
'--enablekositvalidation' => null,
'--enableunseenonly' => null,
],
$this->definition
);
Expand All @@ -63,7 +62,6 @@ public function testInputInterface(): void
$this->assertTrue($arrayInput->hasOption('enablesymfonyvalidation'));
$this->assertTrue($arrayInput->hasOption('enablexsdvalidation'));
$this->assertTrue($arrayInput->hasOption('enablekositvalidation'));
$this->assertTrue($arrayInput->hasOption('enableunseenonly'));
}

public function testCreateConfigFromOptions(): void
Expand All @@ -76,7 +74,6 @@ public function testCreateConfigFromOptions(): void
'--enablesymfonyvalidation' => null,
'--enablexsdvalidation' => null,
'--enablekositvalidation' => null,
'--enableunseenonly' => null,
],
$this->definition
);
Expand All @@ -87,6 +84,5 @@ public function testCreateConfigFromOptions(): void
$this->assertTrue($config->getSymfonyValidationEnabled());
$this->assertTrue($config->getXsdValidationEnabled());
$this->assertTrue($config->getKositValidationEnabled());
$this->assertTrue($config->getUnseenMessagesOnlyEnabled());
}
}
30 changes: 0 additions & 30 deletions tests/testcases/ZugferdMailConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ public function testMailCondigInit(): void
$this->assertEquals(false, $config->getSymfonyValidationEnabled());
$this->assertEquals(false, $config->getXsdValidationEnabled());
$this->assertEquals(false, $config->getKositValidationEnabled());
$this->assertEquals(false, $config->getUnseenMessagesOnlyEnabled());
$this->assertEmpty($config->getAccounts());
}

Expand Down Expand Up @@ -169,32 +168,6 @@ public function testMailConfigDeactivateKositValidation(): void
$this->assertEquals(false, $config->getKositValidationEnabled());
}

public function testMailConfigActivateProcessUnseenMessagesOnly(): void
{
$config = new ZugferdMailConfig();

$this->assertEquals(false, $config->getUnseenMessagesOnlyEnabled());

$config->activateUnseenMessagesOnly();

$this->assertEquals(true, $config->getUnseenMessagesOnlyEnabled());
}

public function testMailConfigDeactivateProcessUnseenMessagesOnly(): void
{
$config = new ZugferdMailConfig();

$this->assertEquals(false, $config->getUnseenMessagesOnlyEnabled());

$config->activateUnseenMessagesOnly();

$this->assertEquals(true, $config->getUnseenMessagesOnlyEnabled());

$config->deactivateUnseenMessagesOnly();

$this->assertEquals(false, $config->getUnseenMessagesOnlyEnabled());
}

public function testMailConfigMakeClientManager(): void
{
$config = new ZugferdMailConfig();
Expand Down Expand Up @@ -324,7 +297,6 @@ public function testLoadConfigWithValidJson(): void
$this->assertTrue($config->getSymfonyValidationEnabled());
$this->assertTrue($config->getXsdValidationEnabled());
$this->assertTrue($config->getKositValidationEnabled());
$this->assertTrue($config->getUnseenMessagesOnlyEnabled());

$this->assertNotEmpty($config->getAccounts());
$this->assertArrayHasKey(0, $config->getAccounts());
Expand Down Expand Up @@ -451,7 +423,6 @@ public function testSaveAndLoadConfigSameFile(): void
$config->activateSymfonyValidation();
$config->activateXsdValidation();
$config->activateKositValidation();
$config->activateUnseenMessagesOnly();
$config->saveToFile($configFilename);

// Load formerly saved config file
Expand All @@ -466,7 +437,6 @@ public function testSaveAndLoadConfigSameFile(): void
$this->assertTrue($config->getSymfonyValidationEnabled());
$this->assertTrue($config->getXsdValidationEnabled());
$this->assertTrue($config->getKositValidationEnabled());
$this->assertTrue($config->getUnseenMessagesOnlyEnabled());

$this->assertNotEmpty($config->getAccounts());
$this->assertArrayHasKey(0, $config->getAccounts());
Expand Down

0 comments on commit e97bc19

Please sign in to comment.