Initial commit - Typo3 11.5.41
This commit is contained in:
847
typo3conf/ext/news/Tests/Unit/Domain/Model/CategoryTest.php
Normal file
847
typo3conf/ext/news/Tests/Unit/Domain/Model/CategoryTest.php
Normal file
@@ -0,0 +1,847 @@
|
||||
<?php
|
||||
|
||||
namespace GeorgRinger\News\Tests\Unit\Domain\Model;
|
||||
|
||||
use GeorgRinger\News\Domain\Model\Category;
|
||||
use GeorgRinger\News\Domain\Model\FileReference;
|
||||
/**
|
||||
* This file is part of the "news" Extension for TYPO3 CMS.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
|
||||
use TYPO3\TestingFramework\Core\BaseTestCase;
|
||||
|
||||
/**
|
||||
* Tests for \GeorgRinger\News\Domain\Model\Category
|
||||
*
|
||||
*/
|
||||
class CategoryTest extends BaseTestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @var Category
|
||||
*/
|
||||
protected $instance;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->instance = new Category();
|
||||
}
|
||||
|
||||
protected function tearDown(): void
|
||||
{
|
||||
unset($this->instance);
|
||||
|
||||
parent::tearDown();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function getSortingInitiallyReturnsZero(): void
|
||||
{
|
||||
$this->assertSame(
|
||||
0,
|
||||
$this->instance->getSorting()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setSortingWithStringConvertsValueToInt(): void
|
||||
{
|
||||
$this->instance->setSorting('123');
|
||||
$this->assertSame(
|
||||
123,
|
||||
$this->instance->getSorting()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setSortingWithIntSetsSorting(): void
|
||||
{
|
||||
$value = 123;
|
||||
$this->instance->setSorting($value);
|
||||
$this->assertSame(
|
||||
$value,
|
||||
$this->instance->getSorting()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function getCrdateInitiallyReturnsNull(): void
|
||||
{
|
||||
$this->assertNull(
|
||||
$this->instance->getCrdate()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setCrdateSetsCrdate(): void
|
||||
{
|
||||
$date = new \DateTime('now');
|
||||
$this->instance->setCrdate($date);
|
||||
$this->assertSame(
|
||||
$date,
|
||||
$this->instance->getCrdate()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function getTstampInitiallyReturnsNull(): void
|
||||
{
|
||||
$this->assertNull(
|
||||
$this->instance->getTstamp()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setTstampSetsTstamp(): void
|
||||
{
|
||||
$date = new \DateTime('now');
|
||||
$this->instance->setTstamp($date);
|
||||
$this->assertSame(
|
||||
$date,
|
||||
$this->instance->getTstamp()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function getStarttimeInitiallyReturnsNull(): void
|
||||
{
|
||||
$this->assertNull(
|
||||
$this->instance->getStarttime()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setStarttimeSetsStarttime(): void
|
||||
{
|
||||
$date = new \DateTime('now');
|
||||
$this->instance->setStarttime($date);
|
||||
$this->assertSame(
|
||||
$date,
|
||||
$this->instance->getStarttime()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function getEndtimeInitiallyReturnsNull(): void
|
||||
{
|
||||
$this->assertNull(
|
||||
$this->instance->getEndtime()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setEndtimeSetsEndtime(): void
|
||||
{
|
||||
$date = new \DateTime('now');
|
||||
$this->instance->setEndtime($date);
|
||||
$this->assertSame(
|
||||
$date,
|
||||
$this->instance->getEndtime()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function getHiddenInitiallyReturnsFalse(): void
|
||||
{
|
||||
$this->assertFalse(
|
||||
$this->instance->getHidden()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setHiddenWithStringSetsHidden(): void
|
||||
{
|
||||
$this->instance->setHidden('1');
|
||||
$this->assertTrue(
|
||||
$this->instance->getHidden()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setHiddenWithIntSetsHidden(): void
|
||||
{
|
||||
$this->instance->setHidden(1);
|
||||
$this->assertTrue(
|
||||
$this->instance->getHidden()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setHiddenWithTrueSetsHidden(): void
|
||||
{
|
||||
$this->instance->setHidden(true);
|
||||
$this->assertTrue(
|
||||
$this->instance->getHidden()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setHiddenWithFalseSetsHidden(): void
|
||||
{
|
||||
$this->instance->setHidden(false);
|
||||
$this->assertFalse(
|
||||
$this->instance->getHidden()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function getSysLanguageUidInitiallyReturnsZero(): void
|
||||
{
|
||||
$this->assertSame(
|
||||
0,
|
||||
$this->instance->getSysLanguageUid()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setSysLanguageUidWithStringConvertsToInt(): void
|
||||
{
|
||||
$this->instance->setSysLanguageUid('2');
|
||||
$this->assertSame(
|
||||
2,
|
||||
$this->instance->getSysLanguageUid()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setSysLanguageUidSetsSysLanguageUid(): void
|
||||
{
|
||||
$value = 3;
|
||||
$this->instance->setSysLanguageUid($value);
|
||||
$this->assertSame(
|
||||
$value,
|
||||
$this->instance->getSysLanguageUid()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function getL10nParentInitiallyReturnsZero(): void
|
||||
{
|
||||
$this->assertSame(
|
||||
0,
|
||||
$this->instance->getL10nParent()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setL10nParentWithStringConvertsToInt(): void
|
||||
{
|
||||
$this->instance->setL10nParent('2');
|
||||
$this->assertSame(
|
||||
2,
|
||||
$this->instance->getL10nParent()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setL10nParentSetsL10nParent(): void
|
||||
{
|
||||
$value = 3;
|
||||
$this->instance->setL10nParent($value);
|
||||
$this->assertSame(
|
||||
$value,
|
||||
$this->instance->getL10nParent()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function getTitleInitiallyReturnsEmptyString(): void
|
||||
{
|
||||
$this->assertSame(
|
||||
'',
|
||||
$this->instance->getTitle()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setTitleWithIntConvertsToSting(): void
|
||||
{
|
||||
$this->instance->setTitle(123);
|
||||
$this->assertSame(
|
||||
'123',
|
||||
$this->instance->getTitle()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setTitleSetsTitle(): void
|
||||
{
|
||||
$value = 'Hello';
|
||||
$this->instance->setTitle($value);
|
||||
$this->assertSame(
|
||||
$value,
|
||||
$this->instance->getTitle()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function getDescriptionInitiallyReturnsEmptyString(): void
|
||||
{
|
||||
$this->assertSame(
|
||||
'',
|
||||
$this->instance->getDescription()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setDescriptionWithIntConvertsToSting(): void
|
||||
{
|
||||
$this->instance->setDescription(123);
|
||||
$this->assertSame(
|
||||
'123',
|
||||
$this->instance->getDescription()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setDescriptionSetsDescription(): void
|
||||
{
|
||||
$value = 'Hello';
|
||||
$this->instance->setDescription($value);
|
||||
$this->assertSame(
|
||||
$value,
|
||||
$this->instance->getDescription()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function getParentcategoryInitiallyReturnsNull(): void
|
||||
{
|
||||
$this->assertNull(
|
||||
$this->instance->getParentcategory()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setParentcategorySetsParentcategory(): void
|
||||
{
|
||||
$value = new Category();
|
||||
$value->setTitle('TYPO3');
|
||||
$this->instance->setParentcategory($value);
|
||||
$this->assertSame(
|
||||
$value,
|
||||
$this->instance->getParentcategory()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function getImagesInitiallyReturnsObjectStorage(): void
|
||||
{
|
||||
$value = new ObjectStorage();
|
||||
$this->assertEquals(
|
||||
$value,
|
||||
$this->instance->getImages()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setImagesSetsImages(): void
|
||||
{
|
||||
$value = new ObjectStorage();
|
||||
$this->instance->setImages($value);
|
||||
$this->assertSame(
|
||||
$value,
|
||||
$this->instance->getImages()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function addImageAddsImage(): void
|
||||
{
|
||||
$fileReference = new FileReference();
|
||||
|
||||
$images = new ObjectStorage();
|
||||
$images->attach($fileReference);
|
||||
|
||||
$this->instance->addImage($fileReference);
|
||||
$this->assertEquals(
|
||||
$images,
|
||||
$this->instance->getImages()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function removeImageRemovesImage(): void
|
||||
{
|
||||
$fileReference = new FileReference();
|
||||
|
||||
$images = new ObjectStorage();
|
||||
$images->attach($fileReference);
|
||||
|
||||
$expectedImages = clone $images;
|
||||
$expectedImages->detach($fileReference);
|
||||
|
||||
$this->instance->setImages($images);
|
||||
|
||||
$this->instance->removeImage($fileReference);
|
||||
$this->assertEquals(
|
||||
$expectedImages,
|
||||
$this->instance->getImages()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function getFirstImageInitiallyReturnsNull(): void
|
||||
{
|
||||
$this->assertNull(
|
||||
$this->instance->getFirstImage()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function getFirstImageReturnsFileReference(): void
|
||||
{
|
||||
$fileReference1 = new FileReference();
|
||||
$fileReference1->setTitle('Image 1');
|
||||
|
||||
$fileReference2 = new FileReference();
|
||||
$fileReference2->setTitle('Image 2');
|
||||
|
||||
$images = new ObjectStorage();
|
||||
$images->attach($fileReference1);
|
||||
$images->attach($fileReference2);
|
||||
|
||||
$this->instance->setImages($images);
|
||||
|
||||
$this->assertSame(
|
||||
$fileReference1,
|
||||
$this->instance->getFirstImage()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function getShortcutInitiallyReturnsZero(): void
|
||||
{
|
||||
$this->assertSame(
|
||||
0,
|
||||
$this->instance->getShortcut()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setShortcutWithStringConvertsToInt(): void
|
||||
{
|
||||
$this->instance->setShortcut('43');
|
||||
$this->assertSame(
|
||||
43,
|
||||
$this->instance->getShortcut()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setShortcutSetsShortcut(): void
|
||||
{
|
||||
$value = 23;
|
||||
$this->instance->setShortcut($value);
|
||||
$this->assertSame(
|
||||
$value,
|
||||
$this->instance->getShortcut()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function getSinglePidInitiallyReturnsZero(): void
|
||||
{
|
||||
$this->assertSame(
|
||||
0,
|
||||
$this->instance->getSinglePid()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setSinglePidWithStringConvertsToInt(): void
|
||||
{
|
||||
$this->instance->setSinglePid('43');
|
||||
$this->assertSame(
|
||||
43,
|
||||
$this->instance->getSinglePid()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setSinglePidSetsSinglePid(): void
|
||||
{
|
||||
$value = 23;
|
||||
$this->instance->setSinglePid($value);
|
||||
$this->assertSame(
|
||||
$value,
|
||||
$this->instance->getSinglePid()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function getImportIdInitiallyReturnsEmptyString(): void
|
||||
{
|
||||
$this->assertSame(
|
||||
'',
|
||||
$this->instance->getImportId()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setImportIdWithIntConvertsToString(): void
|
||||
{
|
||||
$this->instance->setImportId(24);
|
||||
$this->assertSame(
|
||||
'24',
|
||||
$this->instance->getImportId()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setImportIdSetsImportId(): void
|
||||
{
|
||||
$value = '1324';
|
||||
$this->instance->setImportId($value);
|
||||
$this->assertSame(
|
||||
$value,
|
||||
$this->instance->getImportId()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function getImportSourceInitiallyReturnsEmptyString(): void
|
||||
{
|
||||
$this->assertSame(
|
||||
'',
|
||||
$this->instance->getImportSource()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setImportSourceWithIntConvertsToString(): void
|
||||
{
|
||||
$this->instance->setImportSource(24);
|
||||
$this->assertSame(
|
||||
'24',
|
||||
$this->instance->getImportSource()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setImportSourceSetsImportSource(): void
|
||||
{
|
||||
$value = '1324';
|
||||
$this->instance->setImportSource($value);
|
||||
$this->assertSame(
|
||||
$value,
|
||||
$this->instance->getImportSource()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function getFeGroupInitiallyReturnsEmptyString(): void
|
||||
{
|
||||
$this->assertSame(
|
||||
'',
|
||||
$this->instance->getImportSource()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setFeGroupWithIntConvertsToString(): void
|
||||
{
|
||||
$this->instance->setFeGroup(24);
|
||||
$this->assertSame(
|
||||
'24',
|
||||
$this->instance->getFeGroup()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setFeGroupSetsFeGroup(): void
|
||||
{
|
||||
$value = '1324';
|
||||
$this->instance->setFeGroup($value);
|
||||
$this->assertSame(
|
||||
$value,
|
||||
$this->instance->getFeGroup()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function getSeoTitleInitiallyReturnsEmptyString(): void
|
||||
{
|
||||
$this->assertSame(
|
||||
'',
|
||||
$this->instance->getSeoTitle()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setSeoTitleWithIntConvertsToString(): void
|
||||
{
|
||||
$this->instance->setSeoTitle(24);
|
||||
$this->assertSame(
|
||||
'24',
|
||||
$this->instance->getSeoTitle()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setSeoTitleSetsSeoTitle(): void
|
||||
{
|
||||
$value = 'TYPO3';
|
||||
$this->instance->setSeoTitle($value);
|
||||
$this->assertSame(
|
||||
$value,
|
||||
$this->instance->getSeoTitle()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function getSeoDescriptionInitiallyReturnsEmptyString(): void
|
||||
{
|
||||
$this->assertSame(
|
||||
'',
|
||||
$this->instance->getSeoDescription()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setSeoDescriptionWithIntConvertsToString(): void
|
||||
{
|
||||
$this->instance->setSeoDescription(24);
|
||||
$this->assertSame(
|
||||
'24',
|
||||
$this->instance->getSeoDescription()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setSeoDescriptionSetsSeoDescription(): void
|
||||
{
|
||||
$value = 'TYPO3';
|
||||
$this->instance->setSeoDescription($value);
|
||||
$this->assertSame(
|
||||
$value,
|
||||
$this->instance->getSeoDescription()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function getSeoHeadlineInitiallyReturnsEmptyString(): void
|
||||
{
|
||||
$this->assertSame(
|
||||
'',
|
||||
$this->instance->getSeoHeadline()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setSeoHeadlineWithIntConvertsToString(): void
|
||||
{
|
||||
$this->instance->setSeoHeadline(24);
|
||||
$this->assertSame(
|
||||
'24',
|
||||
$this->instance->getSeoHeadline()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setSeoHeadlineSetsSeoHeadline(): void
|
||||
{
|
||||
$value = 'TYPO3';
|
||||
$this->instance->setSeoHeadline($value);
|
||||
$this->assertSame(
|
||||
$value,
|
||||
$this->instance->getSeoHeadline()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function getSeoTextInitiallyReturnsEmptyString(): void
|
||||
{
|
||||
$this->assertSame(
|
||||
'',
|
||||
$this->instance->getSeoText()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setSeoTextWithIntConvertsToString(): void
|
||||
{
|
||||
$this->instance->setSeoText(24);
|
||||
$this->assertSame(
|
||||
'24',
|
||||
$this->instance->getSeoText()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setSeoTextSetsSeoText(): void
|
||||
{
|
||||
$value = 'TYPO3';
|
||||
$this->instance->setSeoText($value);
|
||||
$this->assertSame(
|
||||
$value,
|
||||
$this->instance->getSeoText()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function getSlugInitiallyReturnsEmptyString(): void
|
||||
{
|
||||
$this->assertSame(
|
||||
'',
|
||||
$this->instance->getSlug()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setSlugWithIntConvertsToString(): void
|
||||
{
|
||||
$this->instance->setSlug(24);
|
||||
$this->assertSame(
|
||||
'24',
|
||||
$this->instance->getSlug()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*/
|
||||
public function setSlugSetsSlug(): void
|
||||
{
|
||||
$value = 'TYPO3';
|
||||
$this->instance->setSlug($value);
|
||||
$this->assertSame(
|
||||
$value,
|
||||
$this->instance->getSlug()
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
<?php
|
||||
|
||||
namespace GeorgRinger\News\Tests\Unit\Domain\Model\Dto;
|
||||
|
||||
/**
|
||||
* This file is part of the "news" Extension for TYPO3 CMS.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*/
|
||||
use GeorgRinger\News\Domain\Model\Dto\AdministrationDemand;
|
||||
use TYPO3\TestingFramework\Core\BaseTestCase;
|
||||
|
||||
/**
|
||||
* Tests for AdministrationDemand
|
||||
*
|
||||
*/
|
||||
class AdministrationDemandTest extends BaseTestCase
|
||||
{
|
||||
|
||||
/** @var AdministrationDemand */
|
||||
protected $instance;
|
||||
|
||||
public function setup(): void
|
||||
{
|
||||
$this->instance = new AdministrationDemand();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if recursive can be set
|
||||
*
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function recursiveCanBeSet(): void
|
||||
{
|
||||
$value = 'Test 123';
|
||||
$this->instance->setRecursive($value);
|
||||
$this->assertEquals($value, $this->instance->getRecursive());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if selectedCategories can be set
|
||||
*
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function selectedCategoriesCanBeSet(): void
|
||||
{
|
||||
$value = ['Test 123'];
|
||||
$this->instance->setCategories($value);
|
||||
$this->assertEquals($value, $this->instance->getCategories());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if sortingField can be set
|
||||
*
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function sortingFieldCanBeSet(): void
|
||||
{
|
||||
$value = 'title';
|
||||
$this->instance->setSortingField($value);
|
||||
$this->assertEquals($value, $this->instance->getSortingField());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if sortingDirection can be set
|
||||
*
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function sortingDirectionCanBeSet(): void
|
||||
{
|
||||
$value = 'asc';
|
||||
$this->instance->setSortingDirection($value);
|
||||
$this->assertEquals($value, $this->instance->getSortingDirection());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function hiddenCanBeSet(): void
|
||||
{
|
||||
$value = 2;
|
||||
$this->instance->setHidden($value);
|
||||
$this->assertEquals($value, $this->instance->getHidden());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
namespace GeorgRinger\News\Tests\Unit\Domain\Model\Dto;
|
||||
|
||||
/**
|
||||
* This file is part of the "news" Extension for TYPO3 CMS.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use GeorgRinger\News\Domain\Model\Dto\EmConfiguration;
|
||||
use TYPO3\TestingFramework\Core\BaseTestCase;
|
||||
|
||||
/**
|
||||
* Tests for domains model News
|
||||
*
|
||||
*/
|
||||
class EmConfigurationTest extends BaseTestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* Test if the settings can be read
|
||||
*
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function settingsCanBeRead(): void
|
||||
{
|
||||
$configuration = [
|
||||
'tagPid' => 123,
|
||||
'prependAtCopy' => true,
|
||||
'categoryRestriction' => 'fo',
|
||||
'contentElementRelation' => false,
|
||||
'manualSorting' => false,
|
||||
'archiveDate' => 'bar',
|
||||
'dateTimeNotRequired' => true,
|
||||
'showImporter' => true,
|
||||
'showAdministrationModule' => false,
|
||||
'rteForTeaser' => false,
|
||||
'storageUidImporter' => 1,
|
||||
'resourceFolderImporter' => 'fo',
|
||||
'hidePageTreeForAdministrationModule' => true,
|
||||
'slugBehaviour' => 'uniqueInSite',
|
||||
];
|
||||
|
||||
$configurationInstance = $this->getAccessibleMock(EmConfiguration::class, ['dummy'], [], '', false);
|
||||
foreach ($configuration as $key => $value) {
|
||||
$configurationInstance->_set($key, $value);
|
||||
}
|
||||
foreach ($configuration as $key => $value) {
|
||||
$functionName = 'get' . ucwords($key);
|
||||
$this->assertEquals($value, $configurationInstance->$functionName());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if default settings can be read
|
||||
*
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function defaultSettingsCanBeRead(): void
|
||||
{
|
||||
$configuration = [
|
||||
'tagPid' => 0,
|
||||
'prependAtCopy' => true,
|
||||
'categoryRestriction' => '',
|
||||
'contentElementRelation' => true,
|
||||
'manualSorting' => false,
|
||||
'archiveDate' => 'date',
|
||||
'dateTimeNotRequired' => false,
|
||||
'showImporter' => false,
|
||||
'showAdministrationModule' => true,
|
||||
'rteForTeaser' => false,
|
||||
'storageUidImporter' => 1,
|
||||
'resourceFolderImporter' => '/news_import',
|
||||
'hidePageTreeForAdministrationModule' => false,
|
||||
'slugBehaviour' => 'unique',
|
||||
];
|
||||
|
||||
$configurationInstance = $this->getAccessibleMock(EmConfiguration::class, ['dummy'], [], '', false);
|
||||
|
||||
foreach ($configuration as $key => $value) {
|
||||
$functionName = 'get' . ucwords($key);
|
||||
$this->assertEquals($value, $configurationInstance->$functionName());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,349 @@
|
||||
<?php
|
||||
|
||||
namespace GeorgRinger\News\Tests\Unit\Domain\Model\Dto;
|
||||
|
||||
/**
|
||||
* This file is part of the "news" Extension for TYPO3 CMS.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*/
|
||||
use GeorgRinger\News\Domain\Model\Dto\NewsDemand;
|
||||
use GeorgRinger\News\Domain\Model\Dto\Search;
|
||||
use TYPO3\TestingFramework\Core\BaseTestCase;
|
||||
|
||||
/**
|
||||
* Tests for NewsDemand
|
||||
*/
|
||||
class NewsDemandTest extends BaseTestCase
|
||||
{
|
||||
|
||||
/** @var NewsDemand */
|
||||
protected $instance;
|
||||
|
||||
public function setup(): void
|
||||
{
|
||||
$this->instance = new NewsDemand();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function categoriesCanBeSet(): void
|
||||
{
|
||||
$value = ['Test 123'];
|
||||
$this->instance->setCategories($value);
|
||||
$this->assertEquals($value, $this->instance->getCategories());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function categoryConjunctionCanBeSet(): void
|
||||
{
|
||||
$value = 'AND';
|
||||
$this->instance->setCategoryConjunction($value);
|
||||
$this->assertEquals($value, $this->instance->getCategoryConjunction());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function includeSubCategoriesCanBeSet(): void
|
||||
{
|
||||
$value = true;
|
||||
$this->instance->setIncludeSubCategories($value);
|
||||
$this->assertEquals($value, $this->instance->getIncludeSubCategories());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function authorCanBeSet(): void
|
||||
{
|
||||
$value = '7elix';
|
||||
$this->instance->setAuthor($value);
|
||||
$this->assertEquals($value, $this->instance->getAuthor());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function tagsCanBeSet(): void
|
||||
{
|
||||
$value = '1,2,3';
|
||||
$this->instance->setTags($value);
|
||||
$this->assertEquals($value, $this->instance->getTags());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function archiveRestrictionCanBeSet(): void
|
||||
{
|
||||
$value = 'archive';
|
||||
$this->instance->setArchiveRestriction($value);
|
||||
$this->assertEquals($value, $this->instance->getArchiveRestriction());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function timeRestrictionCanBeSet(): void
|
||||
{
|
||||
$value = '2014-04-01';
|
||||
$this->instance->setTimeRestriction($value);
|
||||
$this->assertEquals($value, $this->instance->getTimeRestriction());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function timeRestrictionHighCanBeSet(): void
|
||||
{
|
||||
$value = '2014-05-01';
|
||||
$this->instance->setTimeRestrictionHigh($value);
|
||||
$this->assertEquals($value, $this->instance->getTimeRestrictionHigh());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function topNewsRestrictionCanBeSet(): void
|
||||
{
|
||||
$value = 1;
|
||||
$this->instance->setTopNewsRestriction($value);
|
||||
$this->assertEquals($value, $this->instance->getTopNewsRestriction());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function dateFieldCanBeSet(): void
|
||||
{
|
||||
$value = 'datetime';
|
||||
$this->instance->setDateField($value);
|
||||
$this->assertEquals($value, $this->instance->getDateField());
|
||||
|
||||
$value = 'archive';
|
||||
$this->instance->setDateField($value);
|
||||
$this->assertEquals($value, $this->instance->getDateField());
|
||||
|
||||
$value = 'invalid';
|
||||
$this->instance->setDateField($value);
|
||||
$this->assertEquals('', $this->instance->getDateField());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function monthCanBeSet(): void
|
||||
{
|
||||
$value = 4;
|
||||
$this->instance->setMonth($value);
|
||||
$this->assertEquals($value, $this->instance->getMonth());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function yearCanBeSet(): void
|
||||
{
|
||||
$value = 2014;
|
||||
$this->instance->setYear($value);
|
||||
$this->assertEquals($value, $this->instance->getYear());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function dayCanBeSet(): void
|
||||
{
|
||||
$value = 1;
|
||||
$this->instance->setDay($value);
|
||||
$this->assertEquals($value, $this->instance->getDay());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function searchFieldsCanBeSet(): void
|
||||
{
|
||||
$value = 'field1,field2';
|
||||
$this->instance->setSearchFields($value);
|
||||
$this->assertEquals($value, $this->instance->getSearchFields());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function searchCanBeSet(): void
|
||||
{
|
||||
$value = new Search();
|
||||
$value->setSubject('fo');
|
||||
$this->instance->setSearch($value);
|
||||
$this->assertEquals($value, $this->instance->getSearch());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function orderCanBeSet(): void
|
||||
{
|
||||
$value = 'order';
|
||||
$this->instance->setOrder($value);
|
||||
$this->assertEquals($value, $this->instance->getOrder());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function orderByAllowedCanBeSet(): void
|
||||
{
|
||||
$value = 'order,order2';
|
||||
$this->instance->setOrderByAllowed($value);
|
||||
$this->assertEquals($value, $this->instance->getOrderByAllowed());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function topNewsFirstCanBeSet(): void
|
||||
{
|
||||
$value = true;
|
||||
$this->instance->setTopNewsFirst($value);
|
||||
$this->assertEquals($value, $this->instance->getTopNewsFirst());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function storagePageCanBeSet(): void
|
||||
{
|
||||
$value = 456;
|
||||
$this->instance->setStoragePage($value);
|
||||
$this->assertEquals($value, $this->instance->getStoragePage());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function limitCanBeSet(): void
|
||||
{
|
||||
$value = 10;
|
||||
$this->instance->setLimit($value);
|
||||
$this->assertEquals($value, $this->instance->getLimit());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function offsetCanBeSet(): void
|
||||
{
|
||||
$value = 20;
|
||||
$this->instance->setOffset($value);
|
||||
$this->assertEquals($value, $this->instance->getOffset());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function excludeAlreadyDisplayedNewsCanBeSet(): void
|
||||
{
|
||||
$value = true;
|
||||
$this->instance->setExcludeAlreadyDisplayedNews($value);
|
||||
$this->assertEquals($value, $this->instance->getExcludeAlreadyDisplayedNews());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function hideIdListCanBeSet(): void
|
||||
{
|
||||
$value = '123,456';
|
||||
$this->instance->setHideIdList($value);
|
||||
$this->assertEquals($value, $this->instance->getHideIdList());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function actionCanBeSet(): void
|
||||
{
|
||||
$value = 'anAction';
|
||||
$this->instance->setAction($value);
|
||||
$this->assertEquals($value, $this->instance->getAction());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function classCanBeSet(): void
|
||||
{
|
||||
$value = 'FooBar';
|
||||
$this->instance->setClass($value);
|
||||
$this->assertEquals($value, $this->instance->getClass());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function typesCanBeSet(): void
|
||||
{
|
||||
$value = ['12', '34'];
|
||||
$this->instance->setTypes($value);
|
||||
$this->assertEquals($value, $this->instance->getTypes());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
|
||||
namespace GeorgRinger\News\Tests\Unit\Domain\Model\Dto;
|
||||
|
||||
/**
|
||||
* This file is part of the "news" Extension for TYPO3 CMS.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*/
|
||||
use GeorgRinger\News\Domain\Model\Dto\Search;
|
||||
use TYPO3\TestingFramework\Core\BaseTestCase;
|
||||
|
||||
/**
|
||||
* Tests for domains model News
|
||||
*
|
||||
*/
|
||||
class SearchTest extends BaseTestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* Test if subject can be set
|
||||
*
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function subjectCanBeSet(): void
|
||||
{
|
||||
$domainModelInstance = new Search();
|
||||
$subject = 'Test 123';
|
||||
$domainModelInstance->setSubject($subject);
|
||||
$this->assertEquals($subject, $domainModelInstance->getSubject());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if fields can be set
|
||||
*
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function fieldsCanBeSet(): void
|
||||
{
|
||||
$domainModelInstance = new Search();
|
||||
$fields = 'field1,field2';
|
||||
$domainModelInstance->setFields($fields);
|
||||
$this->assertEquals($fields, $domainModelInstance->getFields());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if minimumDate can be set
|
||||
*
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function minimumDateCanBeSet(): void
|
||||
{
|
||||
$domainModelInstance = new Search();
|
||||
$value = '123';
|
||||
$domainModelInstance->setMinimumDate($value);
|
||||
$this->assertEquals($value, $domainModelInstance->getMinimumDate());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if minimumDate can be set
|
||||
*
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function maximumDateCanBeSet(): void
|
||||
{
|
||||
$domainModelInstance = new Search();
|
||||
$value = '456';
|
||||
$domainModelInstance->setMaximumDate($value);
|
||||
$this->assertEquals($value, $domainModelInstance->getMaximumDate());
|
||||
}
|
||||
}
|
||||
109
typo3conf/ext/news/Tests/Unit/Domain/Model/FileReferenceTest.php
Normal file
109
typo3conf/ext/news/Tests/Unit/Domain/Model/FileReferenceTest.php
Normal file
@@ -0,0 +1,109 @@
|
||||
<?php
|
||||
|
||||
namespace GeorgRinger\News\Tests\Unit\Domain\Model;
|
||||
|
||||
/**
|
||||
* This file is part of the "news" Extension for TYPO3 CMS.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*/
|
||||
use GeorgRinger\News\Domain\Model\FileReference;
|
||||
use TYPO3\TestingFramework\Core\BaseTestCase;
|
||||
|
||||
/**
|
||||
* Tests for GeorgRinger\News\Domain\Model\FileReference
|
||||
*/
|
||||
class FileReferenceTest extends BaseTestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* Test if fileUid can be set
|
||||
*
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function fileUidCanBeSet(): void
|
||||
{
|
||||
$domainModelInstance = new FileReference();
|
||||
$value = 781;
|
||||
$domainModelInstance->setFileUid($value);
|
||||
$this->assertEquals($value, $domainModelInstance->getFileUid());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if alternative can be set
|
||||
*
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function alternativeBeSet(): void
|
||||
{
|
||||
$domainModelInstance = new FileReference();
|
||||
$value = 'Test 123';
|
||||
$domainModelInstance->setAlternative($value);
|
||||
$this->assertEquals($value, $domainModelInstance->getAlternative());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if description can be set
|
||||
*
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function descriptionBeSet(): void
|
||||
{
|
||||
$domainModelInstance = new FileReference();
|
||||
$value = 'Test 123';
|
||||
$domainModelInstance->setDescription($value);
|
||||
$this->assertEquals($value, $domainModelInstance->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if link can be set
|
||||
*
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function linkBeSet(): void
|
||||
{
|
||||
$domainModelInstance = new FileReference();
|
||||
$value = 'Test 123';
|
||||
$domainModelInstance->setLink($value);
|
||||
$this->assertEquals($value, $domainModelInstance->getLink());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if title can be set
|
||||
*
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function titleBeSet(): void
|
||||
{
|
||||
$domainModelInstance = new FileReference();
|
||||
$value = 'Test 123';
|
||||
$domainModelInstance->setTitle($value);
|
||||
$this->assertEquals($value, $domainModelInstance->getTitle());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if showInPreview can be set
|
||||
*
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function showInPreviewBeSet(): void
|
||||
{
|
||||
$domainModelInstance = new FileReference();
|
||||
$value = 2;
|
||||
$domainModelInstance->setShowinpreview($value);
|
||||
$this->assertEquals($value, $domainModelInstance->getShowinpreview());
|
||||
}
|
||||
}
|
||||
103
typo3conf/ext/news/Tests/Unit/Domain/Model/LinkTest.php
Normal file
103
typo3conf/ext/news/Tests/Unit/Domain/Model/LinkTest.php
Normal file
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
|
||||
namespace GeorgRinger\News\Tests\Unit\Domain\Model;
|
||||
|
||||
/**
|
||||
* This file is part of the "news" Extension for TYPO3 CMS.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*/
|
||||
use GeorgRinger\News\Domain\Model\Link;
|
||||
use TYPO3\TestingFramework\Core\BaseTestCase;
|
||||
|
||||
/**
|
||||
* Tests for domains model Link
|
||||
*/
|
||||
class LinkTest extends BaseTestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @var Link
|
||||
*/
|
||||
protected $linkDomainModelInstance;
|
||||
|
||||
/**
|
||||
* Setup
|
||||
*
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->linkDomainModelInstance = new Link();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if title can be set
|
||||
*
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function titleCanBeSet(): void
|
||||
{
|
||||
$title = 'File title';
|
||||
$this->linkDomainModelInstance->setTitle($title);
|
||||
$this->assertEquals($title, $this->linkDomainModelInstance->getTitle());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if crdate can be set
|
||||
*
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function crdateCanBeSet(): void
|
||||
{
|
||||
$time = new \DateTime();
|
||||
$this->linkDomainModelInstance->setCrdate($time);
|
||||
$this->assertEquals($time, $this->linkDomainModelInstance->getCrdate());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if tstamp can be set
|
||||
*
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function tstampCanBeSet(): void
|
||||
{
|
||||
$time = new \DateTime();
|
||||
$this->linkDomainModelInstance->setTstamp($time);
|
||||
$this->assertEquals($time, $this->linkDomainModelInstance->getTstamp());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if description can be set
|
||||
*
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function descriptionCanBeSet(): void
|
||||
{
|
||||
$description = 'This is a description';
|
||||
$this->linkDomainModelInstance->setDescription($description);
|
||||
$this->assertEquals($description, $this->linkDomainModelInstance->getDescription());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if uri can be set
|
||||
*
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function uriCanBeSet(): void
|
||||
{
|
||||
$uri = 'http://typo3.org';
|
||||
$this->linkDomainModelInstance->setUri($uri);
|
||||
$this->assertEquals($uri, $this->linkDomainModelInstance->getUri());
|
||||
}
|
||||
}
|
||||
408
typo3conf/ext/news/Tests/Unit/Domain/Model/NewsTest.php
Normal file
408
typo3conf/ext/news/Tests/Unit/Domain/Model/NewsTest.php
Normal file
@@ -0,0 +1,408 @@
|
||||
<?php
|
||||
|
||||
namespace GeorgRinger\News\Tests\Unit\Domain\Model;
|
||||
|
||||
use GeorgRinger\News\Domain\Model\Category;
|
||||
/**
|
||||
* This file is part of the "news" Extension for TYPO3 CMS.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use GeorgRinger\News\Domain\Model\FileReference;
|
||||
use GeorgRinger\News\Domain\Model\Link;
|
||||
use GeorgRinger\News\Domain\Model\News;
|
||||
use GeorgRinger\News\Domain\Model\Tag;
|
||||
use TYPO3\CMS\Extbase\Persistence\ObjectStorage;
|
||||
use TYPO3\TestingFramework\Core\BaseTestCase;
|
||||
|
||||
/**
|
||||
* Tests for domains model News
|
||||
*
|
||||
*/
|
||||
class NewsTest extends BaseTestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @var News
|
||||
*/
|
||||
protected $newsDomainModelInstance;
|
||||
|
||||
/**
|
||||
* Set up framework
|
||||
*
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->newsDomainModelInstance = new News();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if title can be set
|
||||
*
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function titleCanBeSet(): void
|
||||
{
|
||||
$title = 'News title';
|
||||
$this->newsDomainModelInstance->setTitle($title);
|
||||
$this->assertEquals($title, $this->newsDomainModelInstance->getTitle());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if teaser can be set
|
||||
*
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function teaserCanBeSet(): void
|
||||
{
|
||||
$teaser = 'News teaser';
|
||||
$this->newsDomainModelInstance->setTeaser($teaser);
|
||||
$this->assertEquals($teaser, $this->newsDomainModelInstance->getTeaser());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if bodytext can be set
|
||||
*
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function bodytextCanBeSet(): void
|
||||
{
|
||||
$bodytext = 'News bodytext';
|
||||
$this->newsDomainModelInstance->setBodytext($bodytext);
|
||||
$this->assertEquals($bodytext, $this->newsDomainModelInstance->getBodytext());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if datetime can be set
|
||||
*
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function datetimeCanBeSet(): void
|
||||
{
|
||||
$datetime = new \DateTime();
|
||||
$this->newsDomainModelInstance->setDatetime($datetime);
|
||||
$this->assertEquals($datetime, $this->newsDomainModelInstance->getDatetime());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if archive can be set
|
||||
*
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function archiveCanBeSet(): void
|
||||
{
|
||||
$archive = new \DateTime();
|
||||
$this->newsDomainModelInstance->setArchive($archive);
|
||||
$this->assertEquals($archive, $this->newsDomainModelInstance->getArchive());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if author can be set
|
||||
*
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function authorCanBeSet(): void
|
||||
{
|
||||
$author = 'News author';
|
||||
$this->newsDomainModelInstance->setAuthor($author);
|
||||
$this->assertEquals($author, $this->newsDomainModelInstance->getAuthor());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if emailadr can be set
|
||||
*
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function authorEmailCanBeSet(): void
|
||||
{
|
||||
$authorEmail = 'author@news.org';
|
||||
$this->newsDomainModelInstance->setAuthorEmail($authorEmail);
|
||||
$this->assertEquals($authorEmail, $this->newsDomainModelInstance->getAuthorEmail());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if type can be set
|
||||
*
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function typeCanBeSet(): void
|
||||
{
|
||||
$type = 123;
|
||||
$this->newsDomainModelInstance->setType($type);
|
||||
$this->assertEquals($type, $this->newsDomainModelInstance->getType());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if keyword can be set
|
||||
*
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function keywordsCanBeSet(): void
|
||||
{
|
||||
$keywords = 'news1 keyword, news keyword';
|
||||
$this->newsDomainModelInstance->setKeywords($keywords);
|
||||
$this->assertEquals($keywords, $this->newsDomainModelInstance->getKeywords());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if internalurl can be set
|
||||
*
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function internalurlCanBeSet(): void
|
||||
{
|
||||
$internalurl = 'http://foo.org/';
|
||||
$this->newsDomainModelInstance->setInternalurl($internalurl);
|
||||
$this->assertEquals($internalurl, $this->newsDomainModelInstance->getInternalurl());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if externalurl can be set
|
||||
*
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function externalurlCanBeSet(): void
|
||||
{
|
||||
$externalurl = 'http://bar.org/';
|
||||
$this->newsDomainModelInstance->setExternalurl($externalurl);
|
||||
$this->assertEquals($externalurl, $this->newsDomainModelInstance->getExternalurl());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if topnews can be set
|
||||
*
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function isttopnewsCanBeSet(): void
|
||||
{
|
||||
$istopnews = true;
|
||||
$this->newsDomainModelInstance->setIstopnews($istopnews);
|
||||
$this->assertEquals($istopnews, $this->newsDomainModelInstance->getIstopnews());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if editlock can be set
|
||||
*
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function editlockCanBeSet(): void
|
||||
{
|
||||
$editlock = 2;
|
||||
$this->newsDomainModelInstance->setEditlock($editlock);
|
||||
$this->assertEquals($editlock, $this->newsDomainModelInstance->getEditlock());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if importid can be set
|
||||
*
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function importIdCanBeSet(): void
|
||||
{
|
||||
$importId = 2;
|
||||
$this->newsDomainModelInstance->setImportId($importId);
|
||||
$this->assertEquals($importId, $this->newsDomainModelInstance->getImportId());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if importSource can be set
|
||||
*
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function importSourceCanBeSet(): void
|
||||
{
|
||||
$importSource = 'test';
|
||||
$this->newsDomainModelInstance->setImportSource($importSource);
|
||||
$this->assertEquals($importSource, $this->newsDomainModelInstance->getImportSource());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if sorting can be set
|
||||
*
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function sortingCanBeSet(): void
|
||||
{
|
||||
$sorting = 2;
|
||||
$this->newsDomainModelInstance->setSorting($sorting);
|
||||
$this->assertEquals($sorting, $this->newsDomainModelInstance->getSorting());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if tag can be set
|
||||
*
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function tagsCanBeSet(): void
|
||||
{
|
||||
$tags = new ObjectStorage();
|
||||
|
||||
$tag = new Tag();
|
||||
$tag->setTitle('Tag');
|
||||
$tags->attach($tag);
|
||||
$this->newsDomainModelInstance->setTags($tags);
|
||||
$this->assertEquals($tags, $this->newsDomainModelInstance->getTags());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if content elements can be set
|
||||
*
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function contentElementsCanBeSet(): void
|
||||
{
|
||||
$ce = new ObjectStorage();
|
||||
|
||||
$item = new \SplObjectStorage();
|
||||
$ce->attach($item);
|
||||
|
||||
$this->newsDomainModelInstance->setContentElements($ce);
|
||||
$this->assertEquals($ce, $this->newsDomainModelInstance->getContentElements());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if category can be set
|
||||
*
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function categoryCanBeSet(): void
|
||||
{
|
||||
$category = new Category();
|
||||
$category->setTitle('fo');
|
||||
$categories = new ObjectStorage();
|
||||
$categories->attach($category);
|
||||
$this->newsDomainModelInstance->setCategories($categories);
|
||||
$this->assertEquals($categories, $this->newsDomainModelInstance->getCategories());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if related links can be set
|
||||
*
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function relatedLinksCanBeSet(): void
|
||||
{
|
||||
$link = new Link();
|
||||
$link->setTitle('fo');
|
||||
|
||||
$related = new ObjectStorage();
|
||||
$related->attach($link);
|
||||
$this->newsDomainModelInstance->setRelatedLinks($related);
|
||||
$this->assertEquals($related, $this->newsDomainModelInstance->getRelatedLinks());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function falMediaCanBeAdded(): void
|
||||
{
|
||||
$mediaItem = new FileReference();
|
||||
$mediaItem->setTitle('Fo');
|
||||
|
||||
$news = new News();
|
||||
$news->addFalMedia($mediaItem);
|
||||
|
||||
$this->assertEquals($news->getFalMedia()->current(), $mediaItem);
|
||||
$this->assertEquals($news->getMedia()->current(), $mediaItem);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function falMediaPreviewsAreReturned(): void
|
||||
{
|
||||
$news = new News();
|
||||
|
||||
$mockedElement1 = $this->getAccessibleMock(FileReference::class, ['getProperty']);
|
||||
$mockedElement1->_set('uid', 1);
|
||||
$mockedElement1->_set('showinpreview', 1);
|
||||
$mockedElement1->expects($this->any())->method('getProperty')->will($this->returnValue(1));
|
||||
|
||||
$mediaItem1 = new FileReference();
|
||||
$mediaItem1->_setProperty('originalResource', $mockedElement1);
|
||||
$mediaItem1->_setProperty('uid', 1);
|
||||
$news->addFalMedia($mediaItem1);
|
||||
|
||||
$mockedElement2 = $this->getAccessibleMock(FileReference::class, ['getProperty']);
|
||||
$mockedElement2->_set('uid', 2);
|
||||
$mockedElement2->_set('showinpreview', 0);
|
||||
$mockedElement2->expects($this->any())->method('getProperty')->will($this->returnValue(0));
|
||||
|
||||
$mediaItem2 = new FileReference();
|
||||
$mediaItem2->_setProperty('originalResource', $mockedElement2);
|
||||
$mediaItem2->_setProperty('uid', 2);
|
||||
$news->addFalMedia($mediaItem2);
|
||||
|
||||
$mockedElement3 = $this->getAccessibleMock(FileReference::class, ['getProperty']);
|
||||
$mockedElement3->_set('uid', 3);
|
||||
$mockedElement3->_set('showinpreview', 1);
|
||||
$mockedElement3->expects($this->any())->method('getProperty')->will($this->returnValue(1));
|
||||
|
||||
$mediaItem3 = new FileReference();
|
||||
$mediaItem3->_setProperty('uid', 3);
|
||||
$mediaItem3->_setProperty('originalResource', $mockedElement3);
|
||||
$news->addFalMedia($mediaItem3);
|
||||
|
||||
$mockedElement4 = $this->getAccessibleMock(FileReference::class, ['getProperty']);
|
||||
$mockedElement4->_set('uid', 4);
|
||||
$mockedElement4->_set('showinpreview', 2);
|
||||
$mockedElement4->expects($this->any())->method('getProperty')->will($this->returnValue(2));
|
||||
|
||||
$mediaItem4 = new FileReference();
|
||||
$mediaItem4->_setProperty('uid', 4);
|
||||
$mediaItem4->_setProperty('originalResource', $mockedElement4);
|
||||
$news->addFalMedia($mediaItem4);
|
||||
|
||||
$this->assertEquals(3, count($news->getMediaPreviews()));
|
||||
$this->assertEquals(3, count($news->getMediaNonPreviews()));
|
||||
|
||||
$this->assertEquals(4, count($news->getFalMedia()));
|
||||
$this->assertEquals(4, count($news->getMedia()));
|
||||
}
|
||||
}
|
||||
76
typo3conf/ext/news/Tests/Unit/Domain/Model/TagTest.php
Normal file
76
typo3conf/ext/news/Tests/Unit/Domain/Model/TagTest.php
Normal file
@@ -0,0 +1,76 @@
|
||||
<?php
|
||||
|
||||
namespace GeorgRinger\News\Tests\Unit\Domain\Model;
|
||||
|
||||
/**
|
||||
* This file is part of the "news" Extension for TYPO3 CMS.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*/
|
||||
use GeorgRinger\News\Domain\Model\Tag;
|
||||
use TYPO3\TestingFramework\Core\BaseTestCase;
|
||||
|
||||
/**
|
||||
* Tests for domains model Tag
|
||||
*
|
||||
*/
|
||||
class TagTest extends BaseTestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @var Tag
|
||||
*/
|
||||
protected $tagDomainModelInstance;
|
||||
|
||||
/**
|
||||
* Setup
|
||||
*
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->tagDomainModelInstance = new Tag();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if title can be set
|
||||
*
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function titleCanBeSet(): void
|
||||
{
|
||||
$title = 'Tag title';
|
||||
$this->tagDomainModelInstance->setTitle($title);
|
||||
$this->assertEquals($title, $this->tagDomainModelInstance->getTitle());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if crdate can be set
|
||||
*
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function crdateCanBeSet(): void
|
||||
{
|
||||
$time = new \DateTime('now');
|
||||
$this->tagDomainModelInstance->setCrdate($time);
|
||||
$this->assertEquals($time, $this->tagDomainModelInstance->getCrdate());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if tstamp can be set
|
||||
*
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function tstampCanBeSet(): void
|
||||
{
|
||||
$time = new \DateTime('now');
|
||||
$this->tagDomainModelInstance->setTstamp($time);
|
||||
$this->assertEquals($time, $this->tagDomainModelInstance->getTstamp());
|
||||
}
|
||||
}
|
||||
322
typo3conf/ext/news/Tests/Unit/Domain/Model/TtContentTest.php
Normal file
322
typo3conf/ext/news/Tests/Unit/Domain/Model/TtContentTest.php
Normal file
@@ -0,0 +1,322 @@
|
||||
<?php
|
||||
|
||||
namespace GeorgRinger\News\Tests\Unit\Domain\Model;
|
||||
|
||||
/**
|
||||
* This file is part of the "news" Extension for TYPO3 CMS.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*/
|
||||
use GeorgRinger\News\Domain\Model\TtContent;
|
||||
use TYPO3\TestingFramework\Core\BaseTestCase;
|
||||
|
||||
/**
|
||||
* Tests for tt_content model
|
||||
*
|
||||
*/
|
||||
class TtContentTest extends BaseTestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* @var TtContent
|
||||
*/
|
||||
protected $ttContentDomainModelInstance;
|
||||
|
||||
/**
|
||||
* Setup
|
||||
*
|
||||
*/
|
||||
protected function setUp(): void
|
||||
{
|
||||
$this->ttContentDomainModelInstance = new TtContent();
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function crdateCanBeSet(): void
|
||||
{
|
||||
$fieldValue = new \DateTime();
|
||||
$this->ttContentDomainModelInstance->setCrdate($fieldValue);
|
||||
$this->assertEquals($fieldValue, $this->ttContentDomainModelInstance->getCrdate());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function tstampCanBeSet(): void
|
||||
{
|
||||
$fieldValue = new \DateTime();
|
||||
$this->ttContentDomainModelInstance->setTstamp($fieldValue);
|
||||
$this->assertEquals($fieldValue, $this->ttContentDomainModelInstance->getTstamp());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function cTypeCanBeSet(): void
|
||||
{
|
||||
$fieldValue = 'fo123';
|
||||
$this->ttContentDomainModelInstance->setCType($fieldValue);
|
||||
$this->assertEquals($fieldValue, $this->ttContentDomainModelInstance->getCType());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function headerCanBeSet(): void
|
||||
{
|
||||
$fieldValue = 'fo123';
|
||||
$this->ttContentDomainModelInstance->setHeader($fieldValue);
|
||||
$this->assertEquals($fieldValue, $this->ttContentDomainModelInstance->getHeader());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function headerPositionCanBeSet(): void
|
||||
{
|
||||
$fieldValue = 'fo123';
|
||||
$this->ttContentDomainModelInstance->setHeaderPosition($fieldValue);
|
||||
$this->assertEquals($fieldValue, $this->ttContentDomainModelInstance->getHeaderPosition());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function bodytextCanBeSet(): void
|
||||
{
|
||||
$fieldValue = 'fo123';
|
||||
$this->ttContentDomainModelInstance->setBodytext($fieldValue);
|
||||
$this->assertEquals($fieldValue, $this->ttContentDomainModelInstance->getBodytext());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function colPosCanBeSet(): void
|
||||
{
|
||||
$fieldValue = 1;
|
||||
$this->ttContentDomainModelInstance->setColPos($fieldValue);
|
||||
$this->assertEquals($fieldValue, $this->ttContentDomainModelInstance->getColPos());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function imageCanBeSet(): void
|
||||
{
|
||||
$fieldValue = 'fo123';
|
||||
$this->ttContentDomainModelInstance->setImage($fieldValue);
|
||||
$this->assertEquals($fieldValue, $this->ttContentDomainModelInstance->getImage());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function imageWidthCanBeSet(): void
|
||||
{
|
||||
$fieldValue = 123;
|
||||
$this->ttContentDomainModelInstance->setImagewidth($fieldValue);
|
||||
$this->assertEquals($fieldValue, $this->ttContentDomainModelInstance->getImagewidth());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function imageOrientCanBeSet(): void
|
||||
{
|
||||
$fieldValue = 3;
|
||||
$this->ttContentDomainModelInstance->setImageorient($fieldValue);
|
||||
$this->assertEquals($fieldValue, $this->ttContentDomainModelInstance->getImageorient());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function imageCaptionCanBeSet(): void
|
||||
{
|
||||
$fieldValue = 'Test123';
|
||||
$this->ttContentDomainModelInstance->setImagecaption($fieldValue);
|
||||
$this->assertEquals($fieldValue, $this->ttContentDomainModelInstance->getImagecaption());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function imageColsCanBeSet(): void
|
||||
{
|
||||
$fieldValue = 123;
|
||||
$this->ttContentDomainModelInstance->setImagecols($fieldValue);
|
||||
$this->assertEquals($fieldValue, $this->ttContentDomainModelInstance->getImagecols());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function imageBorderCanBeSet(): void
|
||||
{
|
||||
$fieldValue = 123;
|
||||
$this->ttContentDomainModelInstance->setImageborder($fieldValue);
|
||||
$this->assertEquals($fieldValue, $this->ttContentDomainModelInstance->getImageborder());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function mediaCanBeSet(): void
|
||||
{
|
||||
$fieldValue = 'Test 123';
|
||||
$this->ttContentDomainModelInstance->setMedia($fieldValue);
|
||||
$this->assertEquals($fieldValue, $this->ttContentDomainModelInstance->getMedia());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function layoutCanBeSet(): void
|
||||
{
|
||||
$fieldValue = 'Test 123';
|
||||
$this->ttContentDomainModelInstance->setLayout($fieldValue);
|
||||
$this->assertEquals($fieldValue, $this->ttContentDomainModelInstance->getLayout());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function colsCanBeSet(): void
|
||||
{
|
||||
$fieldValue = 123;
|
||||
$this->ttContentDomainModelInstance->setCols($fieldValue);
|
||||
$this->assertEquals($fieldValue, $this->ttContentDomainModelInstance->getCols());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function subheaderCanBeSet(): void
|
||||
{
|
||||
$fieldValue = 'Test 123';
|
||||
$this->ttContentDomainModelInstance->setSubheader($fieldValue);
|
||||
$this->assertEquals($fieldValue, $this->ttContentDomainModelInstance->getSubheader());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function headerLinkCanBeSet(): void
|
||||
{
|
||||
$fieldValue = 'Test 123';
|
||||
$this->ttContentDomainModelInstance->setHeaderLink($fieldValue);
|
||||
$this->assertEquals($fieldValue, $this->ttContentDomainModelInstance->getHeaderLink());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function imageLinkCanBeSet(): void
|
||||
{
|
||||
$fieldValue = 'Test 123';
|
||||
$this->ttContentDomainModelInstance->setImageLink($fieldValue);
|
||||
$this->assertEquals($fieldValue, $this->ttContentDomainModelInstance->getImageLink());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function imageZoomCanBeSet(): void
|
||||
{
|
||||
$fieldValue = 'Test 123';
|
||||
$this->ttContentDomainModelInstance->setImageZoom($fieldValue);
|
||||
$this->assertEquals($fieldValue, $this->ttContentDomainModelInstance->getImageZoom());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function altTextCanBeSet(): void
|
||||
{
|
||||
$fieldValue = 'Test 123';
|
||||
$this->ttContentDomainModelInstance->setAltText($fieldValue);
|
||||
$this->assertEquals($fieldValue, $this->ttContentDomainModelInstance->getAltText());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function titleTextCanBeSet(): void
|
||||
{
|
||||
$fieldValue = 'Test 123';
|
||||
$this->ttContentDomainModelInstance->setTitleText($fieldValue);
|
||||
$this->assertEquals($fieldValue, $this->ttContentDomainModelInstance->getTitleText());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function headerLayoutCanBeSet(): void
|
||||
{
|
||||
$fieldValue = 'Test 123';
|
||||
$this->ttContentDomainModelInstance->setHeaderLayout($fieldValue);
|
||||
$this->assertEquals($fieldValue, $this->ttContentDomainModelInstance->getHeaderLayout());
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function listTypeCanBeSet(): void
|
||||
{
|
||||
$fieldValue = 'Test 123';
|
||||
$this->ttContentDomainModelInstance->setListType($fieldValue);
|
||||
$this->assertEquals($fieldValue, $this->ttContentDomainModelInstance->getListType());
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
<?php
|
||||
|
||||
namespace GeorgRinger\News\Tests\Unit\Domain\Repository;
|
||||
|
||||
/**
|
||||
* This file is part of the "news" Extension for TYPO3 CMS.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use GeorgRinger\News\Domain\Repository\CategoryRepository;
|
||||
use TYPO3\TestingFramework\Core\BaseTestCase;
|
||||
|
||||
/**
|
||||
* Tests for domain repository categoryRepository
|
||||
*
|
||||
*/
|
||||
class CategoryRepositoryTest extends BaseTestCase
|
||||
{
|
||||
|
||||
/**
|
||||
* Test if category ids are replaced
|
||||
*
|
||||
* @param array $expectedResult
|
||||
* @param array $given
|
||||
*
|
||||
* @test
|
||||
*
|
||||
* @dataProvider categoryIdsAreCorrectlyReplacedDataProvider
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function categoryIdsAreCorrectlyReplaced($expectedResult, $given): void
|
||||
{
|
||||
$mockTemplateParser = $this->getAccessibleMock(CategoryRepository::class, ['dummy'], [], '', false);
|
||||
|
||||
$result = $mockTemplateParser->_call('replaceCategoryIds', $given['idList'], $given['toBeChanged']);
|
||||
|
||||
$this->assertEquals($expectedResult, $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function categoryIdsAreCorrectlyReplacedDataProvider(): array
|
||||
{
|
||||
return [
|
||||
'emptyRows' => [
|
||||
[1, 2, 3],
|
||||
[
|
||||
'idList' => [1, 2, 3],
|
||||
'toBeChanged' => []
|
||||
]
|
||||
],
|
||||
'oneIdReplaced' => [
|
||||
[1, 5, 3],
|
||||
[
|
||||
'idList' => [1, 2, 3],
|
||||
'toBeChanged' => [
|
||||
0 => [
|
||||
'l10n_parent' => 2,
|
||||
'uid' => 5,
|
||||
]
|
||||
]
|
||||
]
|
||||
],
|
||||
'noIdReplaced' => [
|
||||
[1, 2, 3],
|
||||
[
|
||||
'idList' => [1, 2, 3],
|
||||
'toBeChanged' => [
|
||||
0 => [
|
||||
'l10n_parent' => 6,
|
||||
'uid' => 5,
|
||||
],
|
||||
1 => [
|
||||
'l10n_parent' => 8,
|
||||
'uid' => 10,
|
||||
]
|
||||
]
|
||||
]
|
||||
],
|
||||
'allIdsReplaced' => [
|
||||
[4, 5, 6],
|
||||
[
|
||||
'idList' => [1, 2, 3],
|
||||
'toBeChanged' => [
|
||||
[
|
||||
'l10n_parent' => 2,
|
||||
'uid' => 5,
|
||||
],
|
||||
[
|
||||
'l10n_parent' => 1,
|
||||
'uid' => 4,
|
||||
],
|
||||
[
|
||||
'l10n_parent' => 3,
|
||||
'uid' => 6,
|
||||
],
|
||||
[
|
||||
'l10n_parent' => 8,
|
||||
'uid' => 10,
|
||||
]
|
||||
]
|
||||
]
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,163 @@
|
||||
<?php
|
||||
|
||||
namespace GeorgRinger\News\Tests\Unit\Domain\Repository;
|
||||
|
||||
/**
|
||||
* This file is part of the "news" Extension for TYPO3 CMS.
|
||||
*
|
||||
* For the full copyright and license information, please read the
|
||||
* LICENSE.txt file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
use GeorgRinger\News\Domain\Model\Dto\NewsDemand;
|
||||
use GeorgRinger\News\Domain\Model\Dto\Search;
|
||||
use GeorgRinger\News\Domain\Repository\NewsRepository;
|
||||
use TYPO3\CMS\Core\Database\Query\QueryBuilder;
|
||||
use TYPO3\CMS\Extbase\Persistence\QueryInterface;
|
||||
use TYPO3\TestingFramework\Core\BaseTestCase;
|
||||
use UnexpectedValueException;
|
||||
|
||||
/**
|
||||
* Tests for domain repository newsRepository
|
||||
*
|
||||
*
|
||||
*/
|
||||
class NewsRepositoryTest extends BaseTestCase
|
||||
{
|
||||
|
||||
/** @var \GeorgRinger\News\Domain\Repository\NewsRepository|\PHPUnit_Framework_MockObject_MockObject|\TYPO3\TestingFramework\Core\AccessibleObjectInterface */
|
||||
protected $mockedNewsRepository;
|
||||
|
||||
public function setup(): void
|
||||
{
|
||||
$this->mockedNewsRepository = $this->getAccessibleMock(NewsRepository::class, ['getQueryBuilder'], [], '', false);
|
||||
|
||||
$mockedQueryBuilder = $this->getAccessibleMock(QueryBuilder::class, ['escapeStrForLike', 'createNamedParameter'], [], '', false);
|
||||
$this->mockedNewsRepository->expects($this->any())->method('getQueryBuilder')->withAnyParameters()->will($this->returnValue($mockedQueryBuilder));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function getSearchConstraintsThrowsErrorIfNoSearchFieldIsGiven(): void
|
||||
{
|
||||
$this->expectException(UnexpectedValueException::class);
|
||||
$mockedQuery = $this->getMockBuilder(QueryInterface::class)->getMock();
|
||||
|
||||
$search = new Search();
|
||||
$search->setSubject('fo');
|
||||
|
||||
$demand = new NewsDemand();
|
||||
$demand->setSearch($search);
|
||||
|
||||
$this->mockedNewsRepository->_call('getSearchConstraints', $mockedQuery, $demand);
|
||||
}
|
||||
//
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function getSearchConstraintsThrowsErrorIfNoDateFieldForMaximumDateIsGiven(): void
|
||||
{
|
||||
$this->expectException(UnexpectedValueException::class);
|
||||
$mockedQuery = $this->getMockBuilder(QueryInterface::class)->getMock();
|
||||
|
||||
$search = new Search();
|
||||
$search->setMaximumDate('2014-04-01');
|
||||
|
||||
$demand = new NewsDemand();
|
||||
$demand->setSearch($search);
|
||||
|
||||
$this->mockedNewsRepository->_call('getSearchConstraints', $mockedQuery, $demand);
|
||||
}
|
||||
//
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function getSearchConstraintsThrowsErrorIfNoDateFieldForMinimumDateIsGiven(): void
|
||||
{
|
||||
$this->expectException(UnexpectedValueException::class);
|
||||
$mockedQuery = $this->getMockBuilder(QueryInterface::class)->getMock();
|
||||
|
||||
$search = new Search();
|
||||
$search->setDateField('');
|
||||
$search->setMinimumDate('2014-04-01');
|
||||
|
||||
$demand = new NewsDemand();
|
||||
$demand->setSearch($search);
|
||||
|
||||
$this->mockedNewsRepository->_call('getSearchConstraints', $mockedQuery, $demand);
|
||||
}
|
||||
//
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function emptyConstraintIsReturnedForEmptySearchDemand(): void
|
||||
{
|
||||
$mockedQuery = $this->getMockBuilder(QueryInterface::class)->getMock();
|
||||
|
||||
$demand = new NewsDemand();
|
||||
$demand->setSearch(null);
|
||||
$result = $this->mockedNewsRepository->_call('getSearchConstraints', $mockedQuery, $demand);
|
||||
$this->assertEmpty($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function constraintsAreReturnedForSearchSubject(): void
|
||||
{
|
||||
$mockedQuery = $this->getMockBuilder(QueryInterface::class)->getMock();
|
||||
|
||||
$search = new Search();
|
||||
$search->setSubject('Lorem');
|
||||
$search->setFields('title,fo');
|
||||
|
||||
$demand = new NewsDemand();
|
||||
$demand->setSearch($search);
|
||||
|
||||
$result = $this->mockedNewsRepository->_call('getSearchConstraints', $mockedQuery, $demand);
|
||||
$this->assertEquals(1, count($result));
|
||||
}
|
||||
|
||||
/**
|
||||
* @test
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function constraintsAreReturnedForDateFields(): void
|
||||
{
|
||||
$mockedQuery = $this->getMockBuilder(QueryInterface::class)->getMock();
|
||||
|
||||
$search = new Search();
|
||||
$search->setMinimumDate('2014-01-01');
|
||||
$search->setDateField('datetime');
|
||||
|
||||
$demand = new NewsDemand();
|
||||
$demand->setSearch($search);
|
||||
|
||||
$result = $this->mockedNewsRepository->_call('getSearchConstraints', $mockedQuery, $demand);
|
||||
$this->assertEquals(1, count($result));
|
||||
|
||||
$search->setMaximumDate('2015-01-01');
|
||||
$demand->setSearch($search);
|
||||
|
||||
$result = $this->mockedNewsRepository->_call('getSearchConstraints', $mockedQuery, $demand);
|
||||
$this->assertEquals(2, count($result));
|
||||
|
||||
$search->setMaximumDate('xyz');
|
||||
$demand->setSearch($search);
|
||||
|
||||
$result = $this->mockedNewsRepository->_call('getSearchConstraints', $mockedQuery, $demand);
|
||||
$this->assertEquals(1, count($result));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user