20 return @include_once(
'vfsStream.php');
30 $this->markTestSkipped(
'Requires vfsStream (http://vfs.bovigo.org)');
41 vfsStreamWrapper::register();
50 require_once
'Services/TermsOfService/classes/class.ilTermsOfServiceTableDataProviderFactory.php';
52 $factory->setLanguageAdapter($this->getMockBuilder(
'ilLanguage')->disableOriginalConstructor()->getMock());
55 $this->assertInstanceOf(
'ilTermsOfServiceAgreementByLanguageProvider', $provider);
56 $this->assertInstanceOf(
'ilTermsOfServiceTableDataProvider', $provider);
69 $client_rel_path = implode(
'/', array(
'clients',
'default',
'agreement'));
70 $global_rel_path = implode(
'/', array(
'global',
'agreement'));
72 $root = vfsStreamWrapper::setRoot(
new vfsStreamDirectory(
'root'));
73 $customizing_dir = vfsStream::newDirectory(
'Customizing')->at($root);
75 $client_dir = vfsStream::newDirectory($client_rel_path)->at($customizing_dir);
76 vfsStream::newFile(
'agreement_de.html', 0777)->at($client_dir);
77 file_put_contents(vfsStream::url(
'root/Customizing/' . $client_rel_path .
'/agreement_de.html'),
'phpunit');
79 $global_dir = vfsStream::newDirectory($global_rel_path)->at($customizing_dir);
80 vfsStream::newFile(
'agreement_en.html', 0777)->at($global_dir);
81 file_put_contents(vfsStream::url(
'root/Customizing/' . $global_rel_path .
'/agreement_en.html'),
'phpunit');
84 vfsStream::url(
'root/Customizing/' . $client_rel_path),
85 vfsStream::url(
'root/Customizing/' . $global_rel_path)
88 $lng = $this->getMockBuilder(
'ilLanguage')->disableOriginalConstructor()->getMock();
89 $installed_languages = array(
'en',
'de',
'fr');
90 $lng->expects($this->once())->method(
'getInstalledLanguages')->will($this->onConsecutiveCalls($installed_languages));
93 $data = $provider->
getList(array(), array());
94 $this->assertArrayHasKey(
'items', $data);
95 $this->assertArrayHasKey(
'cnt', $data);
96 $this->assertCount(count($installed_languages), $data[
'items']);
97 $this->assertEquals(count($installed_languages), $data[
'cnt']);
99 for($i = 0; $i < count($installed_languages); $i++)
101 $this->assertArrayHasKey(
'language', $data[
'items'][$i]);
102 $this->assertArrayHasKey(
'agreement', $data[
'items'][$i]);
103 $this->assertArrayHasKey(
'agreement_document', $data[
'items'][$i]);
104 $this->assertArrayHasKey(
'agreement_document_modification_ts', $data[
'items'][$i]);
106 if($installed_languages[$i] ==
'fr')
108 $this->assertFalse(file_exists($data[
'items'][$i][
'agreement_document']));
112 $this->assertTrue(file_exists($data[
'items'][$i][
'agreement_document']));
123 $expected = $this->getMockBuilder(
'ilLanguage')->disableOriginalConstructor()->getMock();
135 $expected = array(
'/phpunit',
'/ilias');