*
* 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 TYPO3\TestingFramework\Core\Functional\FunctionalTestCase as TestCase;
use WerkraumMedia\ThueCat\Domain\Model\Backend\ImportConfiguration;
/**
* @covers \WerkraumMedia\ThueCat\Domain\Model\Backend\ImportConfiguration
*/
class ImportConfigurationTest extends TestCase
{
/**
* @test
*/
public function canBeCreated(): void
{
$subject = new ImportConfiguration();
self::assertInstanceOf(ImportConfiguration::class, $subject);
}
/**
* @test
*/
public function returnsTitle(): void
{
$subject = new ImportConfiguration();
$subject->_setProperty('title', 'Example Title');
self::assertSame('Example Title', $subject->getTitle());
}
/**
* @test
*/
public function returnsType(): void
{
$subject = new ImportConfiguration();
$subject->_setProperty('type', 'static');
self::assertSame('static', $subject->getType());
}
/**
* @test
*/
public function returnsTableName(): void
{
$subject = new ImportConfiguration();
self::assertSame('tx_thuecat_import_configuration', $subject->getTableName());
}
/**
* @test
*/
public function returnsLastChanged(): void
{
$lastChanged = new \DateTimeImmutable();
$subject = new ImportConfiguration();
$subject->_setProperty('tstamp', $lastChanged);
self::assertSame($lastChanged, $subject->getLastChanged());
}
/**
* @test
*/
public function returnsStoragePidWhenSet(): void
{
$flexForm = implode(PHP_EOL, [
'',
'',
'',
'',
'',
'',
'20',
'',
'',
'',
'',
'',
]);
$subject = new ImportConfiguration();
$subject->_setProperty('configuration', $flexForm);
self::assertSame(20, $subject->getStoragePid());
}
/**
* @test
*/
public function returnsZeroAsStoragePidWhenNoConfigurationExists(): void
{
$flexForm = '';
$subject = new ImportConfiguration();
$subject->_setProperty('configuration', $flexForm);
self::assertSame(0, $subject->getStoragePid());
}
/**
* @test
*/
public function returnsZeroAsStoragePidWhenNegativePidIsConfigured(): void
{
$flexForm = implode(PHP_EOL, [
'',
'',
'',
'',
'',
'',
'-1',
'',
'',
'',
'',
'',
]);
$subject = new ImportConfiguration();
$subject->_setProperty('configuration', $flexForm);
self::assertSame(0, $subject->getStoragePid());
}
/**
* @test
*/
public function returnsZeroAsStoragePidWhenNoneNumericPidIsConfigured(): void
{
$flexForm = implode(PHP_EOL, [
'',
'',
'',
'',
'',
'',
'abc',
'',
'',
'',
'',
'',
]);
$subject = new ImportConfiguration();
$subject->_setProperty('configuration', $flexForm);
self::assertSame(0, $subject->getStoragePid());
}
/**
* @test
*/
public function returnsUrlsWhenSet(): void
{
$flexForm = implode(PHP_EOL, [
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'',
'https://thuecat.org/resources/942302009360-jopp',
'',
'',
'',
'0',
'',
'',
'',
'',
'',
'',
'',
]);
$subject = new ImportConfiguration();
$subject->_setProperty('configuration', $flexForm);
self::assertSame([
'https://thuecat.org/resources/942302009360-jopp',
], $subject->getUrls());
}
/**
* @test
*/
public function returnsEmptyArrayAsUrlsWhenNoConfigurationExists(): void
{
$flexForm = '';
$subject = new ImportConfiguration();
$subject->_setProperty('configuration', $flexForm);
self::assertSame([], $subject->getUrls());
}
/**
* @test
*/
public function returnsEmptyArrayAsUrlsWhenNoUrlsAreConfigured(): void
{
$flexForm = implode(PHP_EOL, [
'',
'',
'',
'',
'',
'',
'10',
'',
'',
'',
'',
'',
]);
$subject = new ImportConfiguration();
$subject->_setProperty('configuration', $flexForm);
self::assertSame([], $subject->getUrls());
}
/**
* @test
*/
public function returnsSyncScopeIdWhenSet(): void
{
$flexForm = implode(PHP_EOL, [
'',
'',
'',
'',
'',
'',
'dd4639dc-58a7-4648-a6ce-4950293a06db',
'',
'',
'',
'',
'',
]);
$subject = new ImportConfiguration();
$subject->_setProperty('configuration', $flexForm);
self::assertSame('dd4639dc-58a7-4648-a6ce-4950293a06db', $subject->getSyncScopeId());
}
/**
* @test
*/
public function returnsEmptyStringAsSyncScopeIdWhenNoConfigurationExists(): void
{
$flexForm = '';
$subject = new ImportConfiguration();
$subject->_setProperty('configuration', $flexForm);
self::assertSame('', $subject->getSyncScopeId());
}
/**
* @test
*/
public function returnsEmptyStringAsSyncScopeIdWhenNoSyncScopeIdAreConfigured(): void
{
$flexForm = implode(PHP_EOL, [
'',
'',
'',
'',
'',
'',
'10',
'',
'',
'',
'',
'',
]);
$subject = new ImportConfiguration();
$subject->_setProperty('configuration', $flexForm);
self::assertSame('', $subject->getSyncScopeId());
}
}