4 require_once
'Services/TermsOfService/classes/class.ilTermsOfServiceFileSystemDocument.php';
42 return @include_once(
'vfsStream.php');
52 $this->markTestSkipped(
'Requires vfsStream (http://vfs.bovigo.org)');
61 $this->lng = $this->getMockBuilder(
'ilLanguage')->disableOriginalConstructor()->getMock();
62 $this->lng->expects($this->any())
63 ->method(
'getLangKey')
64 ->will($this->returnValue(
'de'));
65 $this->lng->expects($this->any())
66 ->method(
'getDefaultLanguage')
67 ->will($this->returnValue(
'fr'));
71 vfsStreamWrapper::register();
72 $root = vfsStreamWrapper::setRoot(
new vfsStreamDirectory(
'root'));
73 $customizing_dir = vfsStream::newDirectory(
'Customizing')->at($root);
74 $this->client_dir = vfsStream::newDirectory(
'clients/default/agreement')->at($customizing_dir);
75 $this->global_dir = vfsStream::newDirectory(
'global/agreement')->at($customizing_dir);
76 $this->source_files = array(
77 vfsStream::url(implode(
'/', array(
'root',
'Customizing',
'clients',
'default',
'agreement',
'agreement_' . $this->lng->getLangKey() .
'.html'))) => $this->lng->getLangKey(),
78 vfsStream::url(implode(
'/', array(
'root',
'Customizing',
'clients',
'default',
'agreement',
'agreement_' . $this->lng->getDefaultLanguage() .
'.html'))) => $this->lng->getDefaultLanguage(),
79 vfsStream::url(implode(
'/', array(
'root',
'Customizing',
'clients',
'default',
'agreement',
'agreement_en.html'))) =>
'en',
80 vfsStream::url(implode(
'/', array(
'root',
'Customizing',
'global',
'agreement',
'agreement_' . $this->lng->getLangKey() .
'.html'))) => $this->lng->getLangKey(),
81 vfsStream::url(implode(
'/', array(
'root',
'Customizing',
'global',
'agreement',
'agreement_' . $this->lng->getDefaultLanguage() .
'.html'))) => $this->lng->getDefaultLanguage(),
82 vfsStream::url(implode(
'/', array(
'root',
'Customizing',
'global',
'agreement',
'agreement_en.html'))) =>
'en'
93 $this->assertInstanceOf(
'ilTermsOfServiceSignableDocument', $document);
94 $document->setSourceFiles($this->source_files);
104 $document->setSourceFiles(array());
105 $document->determine();
116 vfsStream::newFile(
'agreement_de.html', 0777)->withContent(
'phpunit')->at($this->client_dir);
117 file_put_contents(vfsStream::url(
'root/Customizing/clients/default/agreement/agreement_de.html'),
'phpunit');
122 $this->assertEquals(
'phpunit', $document->
getContent());
124 $this->assertEquals(vfsStream::url(
'root/Customizing/clients/default/agreement/agreement_de.html'), $document->
getSource());
135 vfsStream::newFile(
'agreement_fr.html', 0777)->withContent(
'phpunit')->at($this->client_dir);
136 file_put_contents(vfsStream::url(
'root/Customizing/clients/default/agreement/agreement_fr.html'),
'phpunit');
141 $this->assertEquals(
'phpunit', $document->
getContent());
143 $this->assertEquals(vfsStream::url(
'root/Customizing/clients/default/agreement/agreement_fr.html'), $document->
getSource());
154 vfsStream::newFile(
'agreement_en.html', 0777)->withContent(
'phpunit')->at($this->client_dir);
155 file_put_contents(vfsStream::url(
'root/Customizing/clients/default/agreement/agreement_en.html'),
'phpunit');
160 $this->assertEquals(
'phpunit', $document->
getContent());
162 $this->assertEquals(vfsStream::url(
'root/Customizing/clients/default/agreement/agreement_en.html'), $document->
getSource());
173 vfsStream::newFile(
'agreement_de.html', 0777)->withContent(
'phpunit')->at($this->client_dir);
174 file_put_contents(vfsStream::url(
'root/Customizing/global/agreement/agreement_de.html'),
'phpunit');
179 $this->assertEquals(
'phpunit', $document->
getContent());
181 $this->assertEquals(vfsStream::url(
'root/Customizing/global/agreement/agreement_de.html'), $document->
getSource());
192 vfsStream::newFile(
'agreement_fr.html', 0777)->withContent(
'phpunit')->at($this->client_dir);
193 file_put_contents(vfsStream::url(
'root/Customizing/global/agreement/agreement_fr.html'),
'phpunit');
198 $this->assertEquals(
'phpunit', $document->
getContent());
200 $this->assertEquals(vfsStream::url(
'root/Customizing/global/agreement/agreement_fr.html'), $document->
getSource());
211 vfsStream::newFile(
'agreement_en.html', 0777)->withContent(
'phpunit')->at($this->client_dir);
212 file_put_contents(vfsStream::url(
'root/Customizing/global/agreement/agreement_en.html'),
'phpunit');
217 $this->assertEquals(
'phpunit', $document->
getContent());
219 $this->assertEquals(vfsStream::url(
'root/Customizing/global/agreement/agreement_en.html'), $document->
getSource());