Skip to content
Snippets Groups Projects
Commit b0d1f44b authored by Marko Ivancic's avatar Marko Ivancic
Browse files

Merge branch 'units' into 'main'

Improve unit test coverage

See merge request !9
parents 5ef6c2d1 5e3f2291
Branches
No related tags found
1 merge request!9Improve unit test coverage
Pipeline #81955 passed
Showing
with 95 additions and 0 deletions
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
File mode changed from 100644 to 100755
<?php
declare(strict_types=1);
namespace SimpleSAML\Module\accounting\Data\Providers\Activity\DoctrineDbal;
use Psr\Log\LoggerInterface;
use SimpleSAML\Module\accounting\Data\Providers\Interfaces\ActivityInterface;
use SimpleSAML\Module\accounting\Data\Stores\Accounting\Activity\DoctrineDbal\Current\Store;
use SimpleSAML\Module\accounting\Data\Trackers\Activity\DoctrineDbal\CurrentDataTracker;
use SimpleSAML\Module\accounting\Data\Trackers\Interfaces\DataTrackerInterface;
use SimpleSAML\Module\accounting\Entities\Activity;
use SimpleSAML\Module\accounting\Exceptions\StoreException;
use SimpleSAML\Module\accounting\Exceptions\StoreException\MigrationException;
use SimpleSAML\Module\accounting\ModuleConfiguration;
class CurrentDataProvider implements ActivityInterface
{
protected ModuleConfiguration $moduleConfiguration;
protected LoggerInterface $logger;
protected Store $store;
/**
* @throws StoreException
*/
public function __construct(
ModuleConfiguration $moduleConfiguration,
LoggerInterface $logger,
string $connectionType = ModuleConfiguration\ConnectionType::SLAVE,
Store $store = null
) {
$this->moduleConfiguration = $moduleConfiguration;
$this->logger = $logger;
$this->store = $store ?? new Store(
$this->moduleConfiguration,
$this->logger,
$this->moduleConfiguration->getClassConnectionKey(self::class),
$connectionType
);
}
/**
* @throws StoreException
*/
public static function build(
ModuleConfiguration $moduleConfiguration,
LoggerInterface $logger,
string $connectionType = ModuleConfiguration\ConnectionType::SLAVE
): self {
return new self($moduleConfiguration, $logger, $connectionType);
}
/**
* @throws StoreException
*/
public function needsSetup(): bool
{
return $this->store->needsSetup();
}
/**
* @throws StoreException
* @throws MigrationException
*/
public function runSetup(): void
{
if (! $this->needsSetup()) {
$this->logger->warning('Run setup called, however setup is not needed.');
return;
}
$this->store->runSetup();
}
/**
* @throws StoreException
*/
public function getActivity(string $userIdentifier, int $maxResults, int $firstResult): Activity\Bag
{
return $this->store->getActivity($userIdentifier, $maxResults, $firstResult);
}
/**
* @throws StoreException
*/
public function getTracker(): ?DataTrackerInterface
{
return new CurrentDataTracker(
$this->moduleConfiguration,
$this->logger,
ModuleConfiguration\ConnectionType::MASTER,
);
}
}
File mode changed from 100644 to 100755
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment