4 require_once
'Services/TermsOfService/classes/class.ilTermsOfServiceFileSystemDocument.php';
5 require_once
'Services/TermsOfService/test/ilTermsOfServiceBaseTest.php';
45 $this->lng = $this->getMockBuilder(
'ilLanguage')->setMethods(
array(
'toJSON',
'getInstalledLanguages',
'getLangKey',
'getDefaultLanguage'))->disableOriginalConstructor()->getMock();
46 $this->lng->expects($this->any())
47 ->method(
'getLangKey')
48 ->will($this->returnValue(
'de'));
49 $this->lng->expects($this->any())
50 ->method(
'getDefaultLanguage')
51 ->will($this->returnValue(
'fr'));
53 vfs\vfsStreamWrapper::register();
54 $root = vfs\vfsStreamWrapper::setRoot(
new vfs\vfsStreamDirectory(
'root'));
55 $customizing_dir = vfs\vfsStream::newDirectory(
'Customizing')->at($root);
56 $this->client_dir = vfs\vfsStream::newDirectory(
'clients/default/agreement')->at($customizing_dir);
57 $this->global_dir = vfs\vfsStream::newDirectory(
'global/agreement')->at($customizing_dir);
58 $this->source_files =
array(
59 vfs\vfsStream::url(implode(
'/',
array(
'root',
'Customizing',
'clients',
'default',
'agreement',
'agreement_' . $this->lng->getLangKey() .
'.html'))) => $this->lng->getLangKey(),
60 vfs\vfsStream::url(implode(
'/',
array(
'root',
'Customizing',
'clients',
'default',
'agreement',
'agreement_' . $this->lng->getDefaultLanguage() .
'.html'))) => $this->lng->getDefaultLanguage(),
61 vfs\vfsStream::url(implode(
'/',
array(
'root',
'Customizing',
'clients',
'default',
'agreement',
'agreement_en.html'))) =>
'en',
62 vfs\vfsStream::url(implode(
'/',
array(
'root',
'Customizing',
'global',
'agreement',
'agreement_' . $this->lng->getLangKey() .
'.html'))) => $this->lng->getLangKey(),
63 vfs\vfsStream::url(implode(
'/',
array(
'root',
'Customizing',
'global',
'agreement',
'agreement_' . $this->lng->getDefaultLanguage() .
'.html'))) => $this->lng->getDefaultLanguage(),
64 vfs\vfsStream::url(implode(
'/',
array(
'root',
'Customizing',
'global',
'agreement',
'agreement_en.html'))) =>
'en' 74 $this->assertInstanceOf(
'ilTermsOfServiceSignableDocument', $document);
75 $this->assertTrue($document->exists());
76 $document->setSourceFiles($this->source_files);
85 $this->
assertException(ilTermsOfServiceNoSignableDocumentFoundException::class);
86 $document =
new ilTermsOfServiceFileSystemDocument($this->getMockBuilder(
'ilLanguage')->setMethods(
array(
'getLangKey',
'getDefaultLanguage',
'toJSON',
'getInstalledLanguages'))->disableOriginalConstructor()->getMock());
87 $document->setSourceFiles(
array());
88 $document->determine();
97 vfs\vfsStream::newFile(
'agreement_de.html', 0777)->withContent(
'phpunit')->at($this->client_dir);
98 file_put_contents(vfs\vfsStream::url(
'root/Customizing/clients/default/agreement/agreement_de.html'),
'phpunit');
103 $this->assertEquals(
'phpunit', $document->
getContent());
105 $this->assertEquals(vfs\vfsStream::url(
'root/Customizing/clients/default/agreement/agreement_de.html'), $document->
getSource());
114 vfs\vfsStream::newFile(
'agreement_fr.html', 0777)->withContent(
'phpunit')->at($this->client_dir);
115 file_put_contents(vfs\vfsStream::url(
'root/Customizing/clients/default/agreement/agreement_fr.html'),
'phpunit');
120 $this->assertEquals(
'phpunit', $document->
getContent());
122 $this->assertEquals(vfs\vfsStream::url(
'root/Customizing/clients/default/agreement/agreement_fr.html'), $document->
getSource());
131 vfs\vfsStream::newFile(
'agreement_en.html', 0777)->withContent(
'phpunit')->at($this->client_dir);
132 file_put_contents(vfs\vfsStream::url(
'root/Customizing/clients/default/agreement/agreement_en.html'),
'phpunit');
137 $this->assertEquals(
'phpunit', $document->
getContent());
139 $this->assertEquals(vfs\vfsStream::url(
'root/Customizing/clients/default/agreement/agreement_en.html'), $document->
getSource());
148 vfs\vfsStream::newFile(
'agreement_de.html', 0777)->withContent(
'phpunit')->at($this->client_dir);
149 file_put_contents(vfs\vfsStream::url(
'root/Customizing/global/agreement/agreement_de.html'),
'phpunit');
154 $this->assertEquals(
'phpunit', $document->
getContent());
156 $this->assertEquals(vfs\vfsStream::url(
'root/Customizing/global/agreement/agreement_de.html'), $document->
getSource());
165 vfs\vfsStream::newFile(
'agreement_fr.html', 0777)->withContent(
'phpunit')->at($this->client_dir);
166 file_put_contents(vfs\vfsStream::url(
'root/Customizing/global/agreement/agreement_fr.html'),
'phpunit');
171 $this->assertEquals(
'phpunit', $document->
getContent());
173 $this->assertEquals(vfs\vfsStream::url(
'root/Customizing/global/agreement/agreement_fr.html'), $document->
getSource());
182 vfs\vfsStream::newFile(
'agreement_en.html', 0777)->withContent(
'phpunit')->at($this->client_dir);
183 file_put_contents(vfs\vfsStream::url(
'root/Customizing/global/agreement/agreement_en.html'),
'phpunit');
188 $this->assertEquals(
'phpunit', $document->
getContent());
190 $this->assertEquals(vfs\vfsStream::url(
'root/Customizing/global/agreement/agreement_en.html'), $document->
getSource());
testClientDocumentCouldBeRetrievedByCurrentLanguage(ilTermsOfServiceFileSystemDocument $document)
testClientDocumentCouldBeRetrievedByEnglishLanguage(ilTermsOfServiceFileSystemDocument $document)
testExceptionIsRaisedWhenNoSingableDocumentCouldBeFoundForCurrentLanguage()
ilTermsOfServiceNoSignableDocumentFoundException
assertException($exception_class)
testGlobalDocumentCouldBeRetrievedByEnglishLanguage(ilTermsOfServiceFileSystemDocument $document)
testGlobalDocumentCouldBeRetrievedByCurrentLanguage(ilTermsOfServiceFileSystemDocument $document)
testClientDocumentCouldBeRetrievedByDefaultLanguage(ilTermsOfServiceFileSystemDocument $document)
const SRC_TYPE_FILE_SYSTEM_PATH
testGlobalDocumentCouldBeRetrievedByDefaultLanguage(ilTermsOfServiceFileSystemDocument $document)
Create styles array
The data for the language used.
testInstanceCanBeCreated()