4 require_once
'vfsStream/vfsStream.php';
22 vfsStreamWrapper::register();
30 require_once
'Services/TermsOfService/classes/class.ilTermsOfServiceTableDataProviderFactory.php';
32 $factory->setLanguageAdapter($this->getMockBuilder(
'ilLanguage')->disableOriginalConstructor()->getMock());
35 $this->assertInstanceOf(
'ilTermsOfServiceAgreementByLanguageProvider', $provider);
36 $this->assertInstanceOf(
'ilTermsOfServiceTableDataProvider', $provider);
47 $client_rel_path = implode(
'/', array(
'clients',
'default',
'agreement'));
48 $global_rel_path = implode(
'/', array(
'global',
'agreement'));
50 $root = vfsStreamWrapper::setRoot(
new vfsStreamDirectory(
'root'));
51 $customizing_dir = vfsStream::newDirectory(
'Customizing')->at($root);
53 $client_dir = vfsStream::newDirectory($client_rel_path)->at($customizing_dir);
54 vfsStream::newFile(
'agreement_de.html', 0777)->at($client_dir);
55 file_put_contents(vfsStream::url(
'root/Customizing/' . $client_rel_path .
'/agreement_de.html'),
'phpunit');
57 $global_dir = vfsStream::newDirectory($global_rel_path)->at($customizing_dir);
58 vfsStream::newFile(
'agreement_en.html', 0777)->at($global_dir);
59 file_put_contents(vfsStream::url(
'root/Customizing/' . $global_rel_path .
'/agreement_en.html'),
'phpunit');
62 vfsStream::url(
'root/Customizing/' . $client_rel_path),
63 vfsStream::url(
'root/Customizing/' . $global_rel_path)
66 $lng = $this->getMockBuilder(
'ilLanguage')->disableOriginalConstructor()->getMock();
67 $installed_languages = array(
'en',
'de',
'fr');
68 $lng->expects($this->once())->method(
'getInstalledLanguages')->will($this->onConsecutiveCalls($installed_languages));
71 $data = $provider->
getList(array(), array());
72 $this->assertArrayHasKey(
'items', $data);
73 $this->assertArrayHasKey(
'cnt', $data);
74 $this->assertCount(count($installed_languages), $data[
'items']);
75 $this->assertEquals(count($installed_languages), $data[
'cnt']);
77 for($i = 0; $i < count($installed_languages); $i++)
79 $this->assertArrayHasKey(
'language', $data[
'items'][$i]);
80 $this->assertArrayHasKey(
'agreement', $data[
'items'][$i]);
81 $this->assertArrayHasKey(
'agreement_document', $data[
'items'][$i]);
82 $this->assertArrayHasKey(
'agreement_document_modification_ts', $data[
'items'][$i]);
84 if($installed_languages[$i] ==
'fr')
86 $this->assertFalse(file_exists($data[
'items'][$i][
'agreement_document']));
90 $this->assertTrue(file_exists($data[
'items'][$i][
'agreement_document']));
101 $expected = $this->getMockBuilder(
'ilLanguage')->disableOriginalConstructor()->getMock();
113 $expected = array(
'/phpunit',
'/ilias');