mirror of
https://github.com/werkraum-media/thuecat.git
synced 2024-12-04 19:16:13 +01:00
parent
1088a580a0
commit
e13bb35252
5 changed files with 117 additions and 6 deletions
|
@ -34,9 +34,9 @@ class ImportLog extends Typo3AbstractEntity
|
|||
protected $logEntries;
|
||||
|
||||
/**
|
||||
* @var ImportConfiguration
|
||||
* @var ImportConfiguration|null
|
||||
*/
|
||||
protected $configuration;
|
||||
protected $configuration = null;
|
||||
|
||||
/**
|
||||
* @var \DateTimeImmutable|null
|
||||
|
@ -44,7 +44,7 @@ class ImportLog extends Typo3AbstractEntity
|
|||
protected $crdate;
|
||||
|
||||
public function __construct(
|
||||
ImportConfiguration $configuration
|
||||
?ImportConfiguration $configuration = null
|
||||
) {
|
||||
$this->logEntries = new ObjectStorage();
|
||||
$this->configuration = $configuration;
|
||||
|
@ -55,11 +55,20 @@ class ImportLog extends Typo3AbstractEntity
|
|||
$this->logEntries->attach($entry);
|
||||
}
|
||||
|
||||
public function getConfiguration(): ImportConfiguration
|
||||
public function getConfiguration(): ?ImportConfiguration
|
||||
{
|
||||
return $this->configuration;
|
||||
}
|
||||
|
||||
public function getConfigurationUid(): int
|
||||
{
|
||||
if ($this->configuration instanceof ImportConfiguration) {
|
||||
$uid = $this->configuration->getUid();
|
||||
}
|
||||
|
||||
return $uid ?? 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ObjectStorage<ImportLogEntry>
|
||||
*/
|
||||
|
|
|
@ -61,7 +61,7 @@ class ImportLogRepository extends Repository
|
|||
'tx_thuecat_import_log' => [
|
||||
'NEW0' => [
|
||||
'pid' => 0,
|
||||
'configuration' => $log->getConfiguration()->getUid(),
|
||||
'configuration' => $log->getConfigurationUid(),
|
||||
],
|
||||
],
|
||||
'tx_thuecat_import_log_entry' => $this->getLogEntries($log),
|
||||
|
|
|
@ -81,6 +81,9 @@
|
|||
<trans-unit id="module.imports.th.summary" xml:space="preserve">
|
||||
<source>Summary</source>
|
||||
</trans-unit>
|
||||
<trans-unit id="module.imports.configuration.notAvailable" xml:space="preserve">
|
||||
<source>Not available</source>
|
||||
</trans-unit>
|
||||
<trans-unit id="module.imports.summary.tableName.tx_thuecat_organisation" xml:space="preserve">
|
||||
<source>Organisation</source>
|
||||
</trans-unit>
|
||||
|
|
|
@ -41,7 +41,16 @@
|
|||
<f:section name="Import">
|
||||
<tr class="{f:if(condition: import.errors, then: 'danger')}">
|
||||
<td>{import.created -> f:format.date(format: 'd.m.Y H:i:s')}</td>
|
||||
<td>{import.configuration.title}</td>
|
||||
<td>
|
||||
<f:if condition="{import.configuration}">
|
||||
<f:then>
|
||||
{import.configuration.title}
|
||||
</f:then>
|
||||
<f:else>
|
||||
{f:translate(id: 'module.imports.configuration.notAvailable')}
|
||||
</f:else>
|
||||
</f:if>
|
||||
</td>
|
||||
<td>{import.entries -> f:count()}</td>
|
||||
<td><f:for each="{import.summaryOfEntries}" key="tableName" as="amount">
|
||||
{f:translate(id: 'module.imports.summary.tableName.{tableName}')} {amount}<br>
|
||||
|
|
90
Tests/Unit/Domain/Model/Backend/ImportLogTest.php
Normal file
90
Tests/Unit/Domain/Model/Backend/ImportLogTest.php
Normal file
|
@ -0,0 +1,90 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace WerkraumMedia\ThueCat\Tests\Unit\Domain\Model\Backend;
|
||||
|
||||
/*
|
||||
* Copyright (C) 2021 Daniel Siepmann <coding@daniel-siepmann.de>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
||||
* 02110-1301, USA.
|
||||
*/
|
||||
|
||||
use Prophecy\PhpUnit\ProphecyTrait;
|
||||
use WerkraumMedia\ThueCat\Domain\Model\Backend\ImportConfiguration;
|
||||
use WerkraumMedia\ThueCat\Domain\Model\Backend\ImportLog;
|
||||
use PHPUnit\Framework\TestCase;
|
||||
|
||||
/**
|
||||
* @covers \WerkraumMedia\ThueCat\Domain\Model\Backend\ImportLog
|
||||
*/
|
||||
class ImportLogTest extends TestCase
|
||||
{
|
||||
use ProphecyTrait;
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function canBeCreated(): void
|
||||
{
|
||||
$subject = new ImportLog();
|
||||
|
||||
self::assertInstanceOf(ImportLog::class, $subject);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function returnsConfigurationIfSet(): void
|
||||
{
|
||||
$configuration = $this->prophesize(ImportConfiguration::class);
|
||||
$subject = new ImportLog($configuration->reveal());
|
||||
|
||||
self::assertSame($configuration->reveal(), $subject->getConfiguration());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function returnsNullForConfigurationIfNotSet(): void
|
||||
{
|
||||
$subject = new ImportLog();
|
||||
|
||||
self::assertNull($subject->getConfiguration());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function returnsConfigurationUidIfSet(): void
|
||||
{
|
||||
$configuration = $this->prophesize(ImportConfiguration::class);
|
||||
$configuration->getUid()->willReturn(10);
|
||||
$subject = new ImportLog($configuration->reveal());
|
||||
|
||||
self::assertSame(10, $subject->getConfigurationUid());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function returnsZeroForConfigurationIfNotSet(): void
|
||||
{
|
||||
$subject = new ImportLog();
|
||||
|
||||
self::assertSame(0, $subject->getConfigurationUid());
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue