[!!!][TASK] Extract testing framework for TYPO3
[Packages/TYPO3.CMS.git] / typo3 / sysext / documentation / Tests / Unit / Domain / Model / DocumentTest.php
1 <?php
2 namespace TYPO3\CMS\Documentation\Tests\Unit\Domain\Model;
3
4 /*
5 * This file is part of the TYPO3 CMS project.
6 *
7 * It is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License, either version 2
9 * of the License, or any later version.
10 *
11 * For the full copyright and license information, please read the
12 * LICENSE.txt file that was distributed with this source code.
13 *
14 * The TYPO3 project - inspiring people to share!
15 */
16
17 /**
18 * Test case
19 */
20 class DocumentTest extends \TYPO3\CMS\Components\TestingFramework\Core\UnitTestCase
21 {
22 /**
23 * @var \TYPO3\CMS\Documentation\Domain\Model\Document
24 */
25 protected $subject;
26
27 protected function setUp()
28 {
29 $this->subject = new \TYPO3\CMS\Documentation\Domain\Model\Document();
30 }
31
32 /**
33 * @test
34 */
35 public function setPackageKeyForStringSetsPackageKey()
36 {
37 $this->subject->setPackageKey('Conceived at T3DD13');
38
39 $this->assertSame(
40 'Conceived at T3DD13',
41 $this->subject->getPackageKey()
42 );
43 }
44
45 /**
46 * @test
47 */
48 public function setIconForStringSetsTitle()
49 {
50 $this->subject->setIcon('Conceived at T3DD13');
51
52 $this->assertSame(
53 'Conceived at T3DD13',
54 $this->subject->getIcon()
55 );
56 }
57
58 /**
59 * @test
60 */
61 public function getTranslationsReturnsInitialValueForDocumentTranslation()
62 {
63 $newObjectStorage = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
64 $this->assertEquals(
65 $newObjectStorage,
66 $this->subject->getTranslations()
67 );
68 }
69
70 /**
71 * @test
72 */
73 public function setTranslationsForObjectStorageContainingDocumentTranslationSetsTranslations()
74 {
75 $translation = new \TYPO3\CMS\Documentation\Domain\Model\DocumentTranslation();
76 $objectStorageHoldingExactlyOneTranslations = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
77 $objectStorageHoldingExactlyOneTranslations->attach($translation);
78 $this->subject->setTranslations($objectStorageHoldingExactlyOneTranslations);
79
80 $this->assertSame(
81 $objectStorageHoldingExactlyOneTranslations,
82 $this->subject->getTranslations()
83 );
84 }
85
86 /**
87 * @test
88 */
89 public function addTranslationToObjectStorageHoldingTranslations()
90 {
91 $translation = new \TYPO3\CMS\Documentation\Domain\Model\DocumentTranslation();
92 $objectStorageHoldingExactlyOneTranslation = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
93 $objectStorageHoldingExactlyOneTranslation->attach($translation);
94 $this->subject->addTranslation($translation);
95
96 $this->assertEquals(
97 $objectStorageHoldingExactlyOneTranslation,
98 $this->subject->getTranslations()
99 );
100 }
101
102 /**
103 * @test
104 */
105 public function removeTranslationFromObjectStorageHoldingTranslations()
106 {
107 $translation = new \TYPO3\CMS\Documentation\Domain\Model\DocumentTranslation();
108 $localObjectStorage = new \TYPO3\CMS\Extbase\Persistence\ObjectStorage();
109 $localObjectStorage->attach($translation);
110 $localObjectStorage->detach($translation);
111 $this->subject->addTranslation($translation);
112 $this->subject->removeTranslation($translation);
113
114 $this->assertEquals(
115 $localObjectStorage,
116 $this->subject->getTranslations()
117 );
118 }
119 }