2021-02-01 14:14:05 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace WerkraumMedia\ThueCat\Tests\Unit\Domain\Import\Model;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
|
2023-12-05 09:43:55 +01:00
|
|
|
use PHPUnit\Framework\Attributes\Test;
|
2021-02-01 14:14:05 +01:00
|
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
use WerkraumMedia\ThueCat\Domain\Import\Model\GenericEntity;
|
|
|
|
|
|
|
|
class GenericEntityTest extends TestCase
|
|
|
|
{
|
2023-12-05 09:43:55 +01:00
|
|
|
#[Test]
|
2021-02-01 14:14:05 +01:00
|
|
|
public function canBeCreated(): void
|
|
|
|
{
|
|
|
|
$subject = new GenericEntity(
|
|
|
|
0,
|
|
|
|
'',
|
2021-02-03 17:20:01 +01:00
|
|
|
0,
|
2021-02-01 14:14:05 +01:00
|
|
|
'',
|
|
|
|
[]
|
|
|
|
);
|
|
|
|
self::assertInstanceOf(GenericEntity::class, $subject);
|
|
|
|
}
|
|
|
|
|
2023-12-05 09:43:55 +01:00
|
|
|
#[Test]
|
2021-02-01 14:14:05 +01:00
|
|
|
public function returnsTypo3StoragePid(): void
|
|
|
|
{
|
|
|
|
$subject = new GenericEntity(
|
|
|
|
10,
|
|
|
|
'',
|
2021-02-03 17:20:01 +01:00
|
|
|
0,
|
2021-02-01 14:14:05 +01:00
|
|
|
'',
|
|
|
|
[]
|
|
|
|
);
|
|
|
|
self::assertSame(10, $subject->getTypo3StoragePid());
|
|
|
|
}
|
|
|
|
|
2023-12-05 09:43:55 +01:00
|
|
|
#[Test]
|
2021-02-01 14:14:05 +01:00
|
|
|
public function returnsTypo3DatabaseTableName(): void
|
|
|
|
{
|
|
|
|
$subject = new GenericEntity(
|
|
|
|
0,
|
|
|
|
'tx_thuecat_entity',
|
2021-02-03 17:20:01 +01:00
|
|
|
0,
|
2021-02-01 14:14:05 +01:00
|
|
|
'',
|
|
|
|
[]
|
|
|
|
);
|
|
|
|
self::assertSame('tx_thuecat_entity', $subject->getTypo3DatabaseTableName());
|
|
|
|
}
|
|
|
|
|
2023-12-05 09:43:55 +01:00
|
|
|
#[Test]
|
2021-02-03 17:20:01 +01:00
|
|
|
public function returnsTypo3SystemLanguageUid(): void
|
|
|
|
{
|
|
|
|
$subject = new GenericEntity(
|
|
|
|
0,
|
|
|
|
'',
|
|
|
|
10,
|
|
|
|
'',
|
|
|
|
[]
|
|
|
|
);
|
|
|
|
self::assertSame(10, $subject->getTypo3SystemLanguageUid());
|
|
|
|
}
|
|
|
|
|
2023-12-05 09:43:55 +01:00
|
|
|
#[Test]
|
2021-02-03 17:20:01 +01:00
|
|
|
public function claimsIsForDefaultLanguage(): void
|
|
|
|
{
|
|
|
|
$subject = new GenericEntity(
|
|
|
|
0,
|
|
|
|
'',
|
|
|
|
0,
|
|
|
|
'',
|
|
|
|
[]
|
|
|
|
);
|
|
|
|
self::assertTrue($subject->isForDefaultLanguage());
|
|
|
|
}
|
|
|
|
|
2023-12-05 09:43:55 +01:00
|
|
|
#[Test]
|
2021-02-03 17:20:01 +01:00
|
|
|
public function claimsIsTranslation(): void
|
|
|
|
{
|
|
|
|
$subject = new GenericEntity(
|
|
|
|
0,
|
|
|
|
'',
|
|
|
|
10,
|
|
|
|
'',
|
|
|
|
[]
|
|
|
|
);
|
|
|
|
self::assertTrue($subject->isTranslation());
|
|
|
|
}
|
|
|
|
|
2023-12-05 09:43:55 +01:00
|
|
|
#[Test]
|
2021-02-01 14:14:05 +01:00
|
|
|
public function returnsRemoteId(): void
|
|
|
|
{
|
|
|
|
$subject = new GenericEntity(
|
|
|
|
0,
|
|
|
|
'',
|
2021-02-03 17:20:01 +01:00
|
|
|
0,
|
2021-02-01 14:14:05 +01:00
|
|
|
'https://example.com/resources/333039283321-xxwg',
|
|
|
|
[]
|
|
|
|
);
|
|
|
|
self::assertSame(
|
|
|
|
'https://example.com/resources/333039283321-xxwg',
|
|
|
|
$subject->getRemoteId()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-12-05 09:43:55 +01:00
|
|
|
#[Test]
|
2021-02-01 14:14:05 +01:00
|
|
|
public function returnsData(): void
|
|
|
|
{
|
|
|
|
$subject = new GenericEntity(
|
|
|
|
0,
|
|
|
|
'',
|
2021-02-03 17:20:01 +01:00
|
|
|
0,
|
2021-02-01 14:14:05 +01:00
|
|
|
'',
|
|
|
|
[
|
|
|
|
'column_name_1' => 'value 1',
|
|
|
|
'column_name_2' => 'value 2',
|
|
|
|
]
|
|
|
|
);
|
|
|
|
self::assertSame(
|
|
|
|
[
|
|
|
|
'column_name_1' => 'value 1',
|
|
|
|
'column_name_2' => 'value 2',
|
|
|
|
],
|
|
|
|
$subject->getData()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-12-05 09:43:55 +01:00
|
|
|
#[Test]
|
2021-02-01 14:14:05 +01:00
|
|
|
public function returnsNotCreatedByDefault(): void
|
|
|
|
{
|
|
|
|
$subject = new GenericEntity(
|
|
|
|
0,
|
|
|
|
'',
|
2021-02-03 17:20:01 +01:00
|
|
|
0,
|
2021-02-01 14:14:05 +01:00
|
|
|
'',
|
|
|
|
[]
|
|
|
|
);
|
2021-02-16 17:12:47 +01:00
|
|
|
self::assertFalse(
|
2021-02-01 14:14:05 +01:00
|
|
|
$subject->wasCreated()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-12-05 09:43:55 +01:00
|
|
|
#[Test]
|
2021-02-16 17:12:47 +01:00
|
|
|
public function returnsNotExistingByDefault(): void
|
|
|
|
{
|
|
|
|
$subject = new GenericEntity(
|
|
|
|
0,
|
|
|
|
'',
|
|
|
|
0,
|
|
|
|
'',
|
|
|
|
[]
|
|
|
|
);
|
|
|
|
self::assertFalse(
|
|
|
|
$subject->exists()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-12-05 09:43:55 +01:00
|
|
|
#[Test]
|
2021-02-01 14:14:05 +01:00
|
|
|
public function returnsZeroAsDefaultTypo3Uid(): void
|
|
|
|
{
|
|
|
|
$subject = new GenericEntity(
|
|
|
|
0,
|
|
|
|
'',
|
2021-02-03 17:20:01 +01:00
|
|
|
0,
|
2021-02-01 14:14:05 +01:00
|
|
|
'',
|
|
|
|
[]
|
|
|
|
);
|
|
|
|
self::assertSame(
|
|
|
|
0,
|
|
|
|
$subject->getTypo3Uid()
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2023-12-05 09:43:55 +01:00
|
|
|
#[Test]
|
2021-02-01 14:14:05 +01:00
|
|
|
public function canBeMarkedAsImported(): void
|
|
|
|
{
|
|
|
|
$subject = new GenericEntity(
|
|
|
|
0,
|
|
|
|
'',
|
2021-02-03 17:20:01 +01:00
|
|
|
0,
|
2021-02-01 14:14:05 +01:00
|
|
|
'',
|
|
|
|
[]
|
|
|
|
);
|
|
|
|
|
|
|
|
$subject->setImportedTypo3Uid(10);
|
2021-02-16 17:12:47 +01:00
|
|
|
self::assertTrue($subject->wasCreated());
|
|
|
|
self::assertTrue($subject->exists());
|
2021-02-01 14:14:05 +01:00
|
|
|
self::assertSame(10, $subject->getTypo3Uid());
|
|
|
|
}
|
|
|
|
|
2023-12-05 09:43:55 +01:00
|
|
|
#[Test]
|
2021-02-01 14:14:05 +01:00
|
|
|
public function canBeMarkedAsExisting(): void
|
|
|
|
{
|
|
|
|
$subject = new GenericEntity(
|
|
|
|
0,
|
|
|
|
'',
|
2021-02-03 17:20:01 +01:00
|
|
|
0,
|
2021-02-01 14:14:05 +01:00
|
|
|
'',
|
|
|
|
[]
|
|
|
|
);
|
|
|
|
|
|
|
|
$subject->setExistingTypo3Uid(10);
|
2021-02-16 17:12:47 +01:00
|
|
|
self::assertFalse($subject->wasCreated());
|
|
|
|
self::assertTrue($subject->exists());
|
2021-02-01 14:14:05 +01:00
|
|
|
self::assertSame(10, $subject->getTypo3Uid());
|
|
|
|
}
|
|
|
|
}
|