ILIAS  release_5-0 Revision 5.0.0-1144-gc4397b1f870
All Data Structures Namespaces Files Functions Variables Modules Pages
ilTermsOfServiceFileSystemDocumentTest Class Reference
+ Inheritance diagram for ilTermsOfServiceFileSystemDocumentTest:
+ Collaboration diagram for ilTermsOfServiceFileSystemDocumentTest:

Public Member Functions

 setUp ()
 
 testInstanceCanBeCreated ()
 
 testExceptionIsRaisedWhenNoSingableDocumentCouldBeFoundForCurrentLanguage ()
 ilTermsOfServiceNoSignableDocumentFoundException More...
 
 testClientDocumentCouldBeRetrievedByCurrentLanguage (ilTermsOfServiceFileSystemDocument $document)
 
 testClientDocumentCouldBeRetrievedByDefaultLanguage (ilTermsOfServiceFileSystemDocument $document)
 
 testClientDocumentCouldBeRetrievedByEnglishLanguage (ilTermsOfServiceFileSystemDocument $document)
 
 testGlobalDocumentCouldBeRetrievedByCurrentLanguage (ilTermsOfServiceFileSystemDocument $document)
 
 testGlobalDocumentCouldBeRetrievedByDefaultLanguage (ilTermsOfServiceFileSystemDocument $document)
 
 testGlobalDocumentCouldBeRetrievedByEnglishLanguage (ilTermsOfServiceFileSystemDocument $document)
 

Protected Attributes

 $backupGlobals = false
 
 $client_dir
 
 $global_dir
 
 $lng
 
 $source_files = array()
 

Private Member Functions

 isVsfStreamInstalled ()
 
 skipIfvfsStreamNotSupported ()
 

Detailed Description

Author
Michael Jansen mjans.nosp@m.en@d.nosp@m.ataba.nosp@m.y.de
Version
$Id$

Definition at line 10 of file ilTermsOfServiceFileSystemDocumentTest.php.

Member Function Documentation

◆ isVsfStreamInstalled()

ilTermsOfServiceFileSystemDocumentTest::isVsfStreamInstalled ( )
private
Returns
bool

Definition at line 40 of file ilTermsOfServiceFileSystemDocumentTest.php.

Referenced by setUp(), and skipIfvfsStreamNotSupported().

41  {
42  return @include_once('vfsStream.php');
43  }
+ Here is the caller graph for this function:

◆ setUp()

ilTermsOfServiceFileSystemDocumentTest::setUp ( )

Definition at line 59 of file ilTermsOfServiceFileSystemDocumentTest.php.

References isVsfStreamInstalled().

60  {
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'));
68 
69  if($this->isVsfStreamInstalled())
70  {
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'
83  );
84  }
85  }
+ Here is the call graph for this function:

◆ skipIfvfsStreamNotSupported()

ilTermsOfServiceFileSystemDocumentTest::skipIfvfsStreamNotSupported ( )
private

◆ testClientDocumentCouldBeRetrievedByCurrentLanguage()

ilTermsOfServiceFileSystemDocumentTest::testClientDocumentCouldBeRetrievedByCurrentLanguage ( ilTermsOfServiceFileSystemDocument  $document)
Parameters
ilTermsOfServiceFileSystemDocument$documenttestInstanceCanBeCreated

Definition at line 112 of file ilTermsOfServiceFileSystemDocumentTest.php.

References ilTermsOfServiceFileSystemDocument\determine(), ilTermsOfServiceFileSystemDocument\getContent(), ilTermsOfServiceFileSystemDocument\getIso2LanguageCode(), ilTermsOfServiceFileSystemDocument\getSource(), ilTermsOfServiceFileSystemDocument\getSourceType(), ilTermsOfServiceFileSystemDocument\hasContent(), skipIfvfsStreamNotSupported(), and ilTermsOfServiceSignableDocument\SRC_TYPE_FILE_SYSTEM_PATH.

113  {
115 
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');
118 
119  $document->determine();
120  $this->assertEquals('de', $document->getIso2LanguageCode());
121  $this->assertTrue($document->hasContent());
122  $this->assertEquals('phpunit', $document->getContent());
124  $this->assertEquals(vfsStream::url('root/Customizing/clients/default/agreement/agreement_de.html'), $document->getSource());
125  }
+ Here is the call graph for this function:

◆ testClientDocumentCouldBeRetrievedByDefaultLanguage()

ilTermsOfServiceFileSystemDocumentTest::testClientDocumentCouldBeRetrievedByDefaultLanguage ( ilTermsOfServiceFileSystemDocument  $document)
Parameters
ilTermsOfServiceFileSystemDocument$documenttestInstanceCanBeCreated

Definition at line 131 of file ilTermsOfServiceFileSystemDocumentTest.php.

References ilTermsOfServiceFileSystemDocument\determine(), ilTermsOfServiceFileSystemDocument\getContent(), ilTermsOfServiceFileSystemDocument\getIso2LanguageCode(), ilTermsOfServiceFileSystemDocument\getSource(), ilTermsOfServiceFileSystemDocument\getSourceType(), ilTermsOfServiceFileSystemDocument\hasContent(), skipIfvfsStreamNotSupported(), and ilTermsOfServiceSignableDocument\SRC_TYPE_FILE_SYSTEM_PATH.

132  {
134 
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');
137 
138  $document->determine();
139  $this->assertEquals('fr', $document->getIso2LanguageCode());
140  $this->assertTrue($document->hasContent());
141  $this->assertEquals('phpunit', $document->getContent());
143  $this->assertEquals(vfsStream::url('root/Customizing/clients/default/agreement/agreement_fr.html'), $document->getSource());
144  }
+ Here is the call graph for this function:

◆ testClientDocumentCouldBeRetrievedByEnglishLanguage()

ilTermsOfServiceFileSystemDocumentTest::testClientDocumentCouldBeRetrievedByEnglishLanguage ( ilTermsOfServiceFileSystemDocument  $document)
Parameters
ilTermsOfServiceFileSystemDocument$documenttestInstanceCanBeCreated

Definition at line 150 of file ilTermsOfServiceFileSystemDocumentTest.php.

References ilTermsOfServiceFileSystemDocument\determine(), ilTermsOfServiceFileSystemDocument\getContent(), ilTermsOfServiceFileSystemDocument\getIso2LanguageCode(), ilTermsOfServiceFileSystemDocument\getSource(), ilTermsOfServiceFileSystemDocument\getSourceType(), ilTermsOfServiceFileSystemDocument\hasContent(), skipIfvfsStreamNotSupported(), and ilTermsOfServiceSignableDocument\SRC_TYPE_FILE_SYSTEM_PATH.

151  {
153 
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');
156 
157  $document->determine();
158  $this->assertEquals('en', $document->getIso2LanguageCode());
159  $this->assertTrue($document->hasContent());
160  $this->assertEquals('phpunit', $document->getContent());
162  $this->assertEquals(vfsStream::url('root/Customizing/clients/default/agreement/agreement_en.html'), $document->getSource());
163  }
+ Here is the call graph for this function:

◆ testExceptionIsRaisedWhenNoSingableDocumentCouldBeFoundForCurrentLanguage()

ilTermsOfServiceFileSystemDocumentTest::testExceptionIsRaisedWhenNoSingableDocumentCouldBeFoundForCurrentLanguage ( )

ilTermsOfServiceNoSignableDocumentFoundException

Definition at line 101 of file ilTermsOfServiceFileSystemDocumentTest.php.

102  {
103  $document = new ilTermsOfServiceFileSystemDocument($this->getMockBuilder('ilLanguage')->disableOriginalConstructor()->getMock());
104  $document->setSourceFiles(array());
105  $document->determine();
106  }

◆ testGlobalDocumentCouldBeRetrievedByCurrentLanguage()

ilTermsOfServiceFileSystemDocumentTest::testGlobalDocumentCouldBeRetrievedByCurrentLanguage ( ilTermsOfServiceFileSystemDocument  $document)
Parameters
ilTermsOfServiceFileSystemDocument$documenttestInstanceCanBeCreated

Definition at line 169 of file ilTermsOfServiceFileSystemDocumentTest.php.

References ilTermsOfServiceFileSystemDocument\determine(), ilTermsOfServiceFileSystemDocument\getContent(), ilTermsOfServiceFileSystemDocument\getIso2LanguageCode(), ilTermsOfServiceFileSystemDocument\getSource(), ilTermsOfServiceFileSystemDocument\getSourceType(), ilTermsOfServiceFileSystemDocument\hasContent(), skipIfvfsStreamNotSupported(), and ilTermsOfServiceSignableDocument\SRC_TYPE_FILE_SYSTEM_PATH.

170  {
172 
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');
175 
176  $document->determine();
177  $this->assertEquals('de', $document->getIso2LanguageCode());
178  $this->assertTrue($document->hasContent());
179  $this->assertEquals('phpunit', $document->getContent());
181  $this->assertEquals(vfsStream::url('root/Customizing/global/agreement/agreement_de.html'), $document->getSource());
182  }
+ Here is the call graph for this function:

◆ testGlobalDocumentCouldBeRetrievedByDefaultLanguage()

ilTermsOfServiceFileSystemDocumentTest::testGlobalDocumentCouldBeRetrievedByDefaultLanguage ( ilTermsOfServiceFileSystemDocument  $document)
Parameters
ilTermsOfServiceFileSystemDocument$documenttestInstanceCanBeCreated

Definition at line 188 of file ilTermsOfServiceFileSystemDocumentTest.php.

References ilTermsOfServiceFileSystemDocument\determine(), ilTermsOfServiceFileSystemDocument\getContent(), ilTermsOfServiceFileSystemDocument\getIso2LanguageCode(), ilTermsOfServiceFileSystemDocument\getSource(), ilTermsOfServiceFileSystemDocument\getSourceType(), ilTermsOfServiceFileSystemDocument\hasContent(), skipIfvfsStreamNotSupported(), and ilTermsOfServiceSignableDocument\SRC_TYPE_FILE_SYSTEM_PATH.

189  {
191 
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');
194 
195  $document->determine();
196  $this->assertEquals('fr', $document->getIso2LanguageCode());
197  $this->assertTrue($document->hasContent());
198  $this->assertEquals('phpunit', $document->getContent());
200  $this->assertEquals(vfsStream::url('root/Customizing/global/agreement/agreement_fr.html'), $document->getSource());
201  }
+ Here is the call graph for this function:

◆ testGlobalDocumentCouldBeRetrievedByEnglishLanguage()

ilTermsOfServiceFileSystemDocumentTest::testGlobalDocumentCouldBeRetrievedByEnglishLanguage ( ilTermsOfServiceFileSystemDocument  $document)
Parameters
ilTermsOfServiceFileSystemDocument$documenttestInstanceCanBeCreated

Definition at line 207 of file ilTermsOfServiceFileSystemDocumentTest.php.

References ilTermsOfServiceFileSystemDocument\determine(), ilTermsOfServiceFileSystemDocument\getContent(), ilTermsOfServiceFileSystemDocument\getIso2LanguageCode(), ilTermsOfServiceFileSystemDocument\getSource(), ilTermsOfServiceFileSystemDocument\getSourceType(), ilTermsOfServiceFileSystemDocument\hasContent(), skipIfvfsStreamNotSupported(), and ilTermsOfServiceSignableDocument\SRC_TYPE_FILE_SYSTEM_PATH.

208  {
210 
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');
213 
214  $document->determine();
215  $this->assertEquals('en', $document->getIso2LanguageCode());
216  $this->assertTrue($document->hasContent());
217  $this->assertEquals('phpunit', $document->getContent());
219  $this->assertEquals(vfsStream::url('root/Customizing/global/agreement/agreement_en.html'), $document->getSource());
220  }
+ Here is the call graph for this function:

◆ testInstanceCanBeCreated()

ilTermsOfServiceFileSystemDocumentTest::testInstanceCanBeCreated ( )

Definition at line 90 of file ilTermsOfServiceFileSystemDocumentTest.php.

91  {
92  $document = new ilTermsOfServiceFileSystemDocument($this->lng);
93  $this->assertInstanceOf('ilTermsOfServiceSignableDocument', $document);
94  $document->setSourceFiles($this->source_files);
95  return $document;
96  }

Field Documentation

◆ $backupGlobals

ilTermsOfServiceFileSystemDocumentTest::$backupGlobals = false
protected

Definition at line 15 of file ilTermsOfServiceFileSystemDocumentTest.php.

◆ $client_dir

ilTermsOfServiceFileSystemDocumentTest::$client_dir
protected

Definition at line 20 of file ilTermsOfServiceFileSystemDocumentTest.php.

◆ $global_dir

ilTermsOfServiceFileSystemDocumentTest::$global_dir
protected

Definition at line 25 of file ilTermsOfServiceFileSystemDocumentTest.php.

◆ $lng

ilTermsOfServiceFileSystemDocumentTest::$lng
protected

Definition at line 30 of file ilTermsOfServiceFileSystemDocumentTest.php.

◆ $source_files

ilTermsOfServiceFileSystemDocumentTest::$source_files = array()
protected

Definition at line 35 of file ilTermsOfServiceFileSystemDocumentTest.php.


The documentation for this class was generated from the following file: