-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Matthias Richter
committed
Mar 4, 2024
1 parent
88107aa
commit b3eeca0
Showing
5 changed files
with
173 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
<?php | ||
namespace Slub\MpdbCore\Tests\Unit\Domain\Model; | ||
|
||
use Slub\DmNorm\Domain\Model\GndPerson; | ||
use Slub\DmNorm\Domain\Model\GndWork; | ||
use Slub\MpdbCore\Domain\Model\PublishedItem; | ||
use Slub\MpdbCore\Domain\Model\PublishedSubitem; | ||
use TYPO3\CMS\Extbase\Persistence\ObjectStorage; | ||
use TYPO3\TestingFramework\Core\Functional\FunctionalTestCase; | ||
|
||
/** | ||
* Test case. | ||
* | ||
* @author Matthias Richter <matthias.richter@slub-dresden.de> | ||
*/ | ||
class PublishedItemTest extends FunctionalTestCase | ||
{ | ||
/** | ||
* @var \Slub\PublisherDb\Domain\Model\PublishedItem | ||
*/ | ||
protected ?PublishedItem $subject = null; | ||
|
||
/** | ||
* @var \Slub\DmNorm\Domain\Model\GndPerson | ||
*/ | ||
protected ?GndPerson $composer1 = null; | ||
|
||
/** | ||
* @var \Slub\DmNorm\Domain\Model\GndPerson | ||
*/ | ||
protected ?GndPerson $composer2 = null; | ||
|
||
/** | ||
* @var \Slub\DmNorm\Domain\Model\GndWork | ||
*/ | ||
protected ?GndWork $work1 = null; | ||
|
||
/** | ||
* @var \Slub\DmNorm\Domain\Model\GndWork | ||
*/ | ||
protected ?GndWork $work2 = null; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected string $nameComposer1 = 'Composer 1'; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected string $nameComposer2 = 'Composer 2'; | ||
|
||
protected function setUp(): void | ||
{ | ||
parent::setUp(); | ||
$this->subject = new PublishedItem(); | ||
|
||
$this->composer1 = new GndPerson(); | ||
$this->composer2 = new GndPerson(); | ||
$this->composer1->setName($this->nameComposer1); | ||
$this->composer2->setName($this->nameComposer2); | ||
|
||
$this->work1 = new GndWork(); | ||
$this->work2 = new GndWork(); | ||
$this->work1->setFirstComposer($this->composer1); | ||
$this->work2->setFirstComposer($this->composer2); | ||
} | ||
|
||
protected function tearDown(): void | ||
{ | ||
parent::tearDown(); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function publishedItemWithOneComposerReturnsComposer() | ||
{ | ||
$this->subject->addFirstComposer($this->composer1); | ||
|
||
self::assertSame( | ||
$this->nameComposer1, | ||
$this->subject->getComposers() | ||
); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function publishedItemWithManyComposersReturnsComposers() | ||
{ | ||
$this->subject->addFirstComposer($this->composer1); | ||
$this->subject->addFirstComposer($this->composer2); | ||
$namesString = implode('; ', [$this->nameComposer1, $this->nameComposer2]); | ||
|
||
self::assertSame( | ||
$namesString, | ||
$this->subject->getComposers() | ||
); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function publishedItemWithoutComposersReturnsOneWorkComposer() | ||
{ | ||
$this->subject->addContainedWork($this->work1); | ||
|
||
self::assertSame( | ||
$this->nameComposer1, | ||
$this->subject->getComposers() | ||
); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function publishedItemWithoutComposerReturnsManyWorkComposers() | ||
{ | ||
$this->subject->addContainedWork($this->work1); | ||
$this->subject->addContainedWork($this->work2); | ||
$namesString = implode('; ', [$this->nameComposer1, $this->nameComposer2]); | ||
|
||
self::assertSame( | ||
$namesString, | ||
$this->subject->getComposers() | ||
); | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function publishedItemWithoutComposerWithoutWorkcomposersReturnsString() | ||
{ | ||
self::assertSame( | ||
'', | ||
$this->subject->getComposers() | ||
); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.4/phpunit.xsd" | ||
backupGlobals="true" | ||
beStrictAboutTestsThatDoNotTestAnything="false" | ||
bootstrap="../.Build/vendor/typo3/testing-framework/Resources/Core/Build/UnitTestsBootstrap.php" | ||
cacheResult="false" | ||
colors="true" | ||
failOnRisky="true" | ||
failOnWarning="true" | ||
> | ||
<testsuites> | ||
<testsuite name="MpdbCore"> | ||
<directory>../Tests/Functional</directory> | ||
</testsuite> | ||
</testsuites> | ||
|
||
<php> | ||
<!-- | ||
@deprecated: Set this to not suppress warnings, notices and deprecations in functional tests | ||
with TYPO3 core v11 and up. | ||
Will always be done with next major version. | ||
To still suppress warnings, notices and deprecations, do NOT define the constant at all. | ||
--> | ||
<const name="TYPO3_TESTING_FUNCTIONAL_REMOVE_ERROR_HANDLER" value="true"/> | ||
<ini name="display_errors" value="1"/> | ||
<env name="TYPO3_CONTEXT" value="Testing"/> | ||
</php> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters