4 require_once
'vfsStream/vfsStream.php';
5 require_once
'Services/TermsOfService/classes/class.ilTermsOfServiceFileSystemDocument.php';
43 vfsStreamWrapper::register();
44 $root = vfsStreamWrapper::setRoot(
new vfsStreamDirectory(
'root'));
45 $customizing_dir = vfsStream::newDirectory(
'Customizing')->at($root);
46 $this->client_dir = vfsStream::newDirectory(
'clients/default/agreement')->at($customizing_dir);
47 $this->global_dir = vfsStream::newDirectory(
'global/agreement')->at($customizing_dir);
49 $this->lng = $this->getMockBuilder(
'ilLanguage')->disableOriginalConstructor()->getMock();
50 $this->lng->expects($this->any())
51 ->method(
'getLangKey')
52 ->will($this->returnValue(
'de'));
53 $this->lng->expects($this->any())
54 ->method(
'getDefaultLanguage')
55 ->will($this->returnValue(
'fr'));
57 $this->source_files = array(
58 vfsStream::url(implode(
'/', array(
'root',
'Customizing',
'clients',
'default',
'agreement',
'agreement_' . $this->lng->getLangKey() .
'.html'))) => $this->lng->getLangKey(),
59 vfsStream::url(implode(
'/', array(
'root',
'Customizing',
'clients',
'default',
'agreement',
'agreement_' . $this->lng->getDefaultLanguage() .
'.html'))) => $this->lng->getDefaultLanguage(),
60 vfsStream::url(implode(
'/', array(
'root',
'Customizing',
'clients',
'default',
'agreement',
'agreement_en.html'))) =>
'en',
61 vfsStream::url(implode(
'/', array(
'root',
'Customizing',
'global',
'agreement',
'agreement_' . $this->lng->getLangKey() .
'.html'))) => $this->lng->getLangKey(),
62 vfsStream::url(implode(
'/', array(
'root',
'Customizing',
'global',
'agreement',
'agreement_' . $this->lng->getDefaultLanguage() .
'.html'))) => $this->lng->getDefaultLanguage(),
63 vfsStream::url(implode(
'/', array(
'root',
'Customizing',
'global',
'agreement',
'agreement_en.html'))) =>
'en'
73 $this->assertInstanceOf(
'ilTermsOfServiceSignableDocument', $document);
74 $document->setSourceFiles($this->source_files);
85 $document->determine();
94 vfsStream::newFile(
'agreement_de.html', 0777)->withContent(
'phpunit')->at($this->client_dir);
95 file_put_contents(vfsStream::url(
'root/Customizing/clients/default/agreement/agreement_de.html'),
'phpunit');
100 $this->assertEquals(
'phpunit', $document->
getContent());
102 $this->assertEquals(vfsStream::url(
'root/Customizing/clients/default/agreement/agreement_de.html'), $document->
getSource());
111 vfsStream::newFile(
'agreement_fr.html', 0777)->withContent(
'phpunit')->at($this->client_dir);
112 file_put_contents(vfsStream::url(
'root/Customizing/clients/default/agreement/agreement_fr.html'),
'phpunit');
117 $this->assertEquals(
'phpunit', $document->
getContent());
119 $this->assertEquals(vfsStream::url(
'root/Customizing/clients/default/agreement/agreement_fr.html'), $document->
getSource());
128 vfsStream::newFile(
'agreement_en.html', 0777)->withContent(
'phpunit')->at($this->client_dir);
129 file_put_contents(vfsStream::url(
'root/Customizing/clients/default/agreement/agreement_en.html'),
'phpunit');
134 $this->assertEquals(
'phpunit', $document->
getContent());
136 $this->assertEquals(vfsStream::url(
'root/Customizing/clients/default/agreement/agreement_en.html'), $document->
getSource());
145 vfsStream::newFile(
'agreement_de.html', 0777)->withContent(
'phpunit')->at($this->client_dir);
146 file_put_contents(vfsStream::url(
'root/Customizing/global/agreement/agreement_de.html'),
'phpunit');
151 $this->assertEquals(
'phpunit', $document->
getContent());
153 $this->assertEquals(vfsStream::url(
'root/Customizing/global/agreement/agreement_de.html'), $document->
getSource());
162 vfsStream::newFile(
'agreement_fr.html', 0777)->withContent(
'phpunit')->at($this->client_dir);
163 file_put_contents(vfsStream::url(
'root/Customizing/global/agreement/agreement_fr.html'),
'phpunit');
168 $this->assertEquals(
'phpunit', $document->
getContent());
170 $this->assertEquals(vfsStream::url(
'root/Customizing/global/agreement/agreement_fr.html'), $document->
getSource());
179 vfsStream::newFile(
'agreement_en.html', 0777)->withContent(
'phpunit')->at($this->client_dir);
180 file_put_contents(vfsStream::url(
'root/Customizing/global/agreement/agreement_en.html'),
'phpunit');
185 $this->assertEquals(
'phpunit', $document->
getContent());
187 $this->assertEquals(vfsStream::url(
'root/Customizing/global/agreement/agreement_en.html'), $document->
getSource());