4 require_once
'Services/TermsOfService/test/ilTermsOfServiceBaseTest.php';
25 define(
'CLIENT_ID',
'phpunit');
28 vfs\vfsStreamWrapper::register();
38 require_once
'Services/TermsOfService/classes/class.ilTermsOfServiceTableDataProviderFactory.php';
40 $factory->setLanguageAdapter($this->getMockBuilder(
'ilLanguage')->setMethods(
array(
'toJSON',
'getInstalledLanguages'))->disableOriginalConstructor()->getMock());
43 $this->assertInstanceOf(
'ilTermsOfServiceAgreementByLanguageProvider',
$provider);
44 $this->assertInstanceOf(
'ilTermsOfServiceTableDataProvider',
$provider);
55 $client_rel_path = implode(
'/',
array(
'clients',
'default',
'agreement'));
56 $global_rel_path = implode(
'/',
array(
'global',
'agreement'));
58 $root = vfs\vfsStreamWrapper::setRoot(
new vfs\vfsStreamDirectory(
'root'));
59 $customizing_dir = vfs\vfsStream::newDirectory(
'Customizing')->at($root);
61 $client_dir = vfs\vfsStream::newDirectory($client_rel_path)->at($customizing_dir);
62 vfs\vfsStream::newFile(
'agreement_de.html', 0777)->at($client_dir);
63 file_put_contents(vfs\vfsStream::url(
'root/Customizing/' . $client_rel_path .
'/agreement_de.html'),
'phpunit');
65 $global_dir = vfs\vfsStream::newDirectory($global_rel_path)->at($customizing_dir);
66 vfs\vfsStream::newFile(
'agreement_en.html', 0777)->at($global_dir);
67 file_put_contents(vfs\vfsStream::url(
'root/Customizing/' . $global_rel_path .
'/agreement_en.html'),
'phpunit');
70 vfs\vfsStream::url(
'root/Customizing/' . $client_rel_path),
71 vfs\vfsStream::url(
'root/Customizing/' . $global_rel_path)
74 $lng = $this->getMockBuilder(
'ilLanguage')->setMethods(
array(
'toJSON',
'getInstalledLanguages'))->disableOriginalConstructor()->getMock();
75 $installed_languages =
array(
'en',
'de',
'fr');
76 $lng->expects($this->once())->method(
'getInstalledLanguages')->will($this->onConsecutiveCalls($installed_languages));
80 $this->assertArrayHasKey(
'items',
$data);
81 $this->assertArrayHasKey(
'cnt',
$data);
82 $this->assertCount(count($installed_languages),
$data[
'items']);
83 $this->assertEquals(count($installed_languages),
$data[
'cnt']);
85 for (
$i = 0;
$i < count($installed_languages);
$i++) {
86 $this->assertArrayHasKey(
'language',
$data[
'items'][
$i]);
87 $this->assertArrayHasKey(
'agreement',
$data[
'items'][$i]);
88 $this->assertArrayHasKey(
'agreement_document',
$data[
'items'][$i]);
89 $this->assertArrayHasKey(
'agreement_document_modification_ts',
$data[
'items'][$i]);
91 if ($installed_languages[$i] ==
'fr') {
92 $this->assertFalse(file_exists(
$data[
'items'][$i][
'agreement_document']));
94 $this->assertTrue(file_exists(
$data[
'items'][$i][
'agreement_document']));
105 $expected = $this->getMockBuilder(
'ilLanguage')->setMethods(
array(
'toJSON',
'getInstalledLanguages'))->disableOriginalConstructor()->getMock();
117 $expected =
array(
'/phpunit',
'/ilias');
getList(array $params, array $filter)
{Table paramaters like limit or order Filter settings array}
const CONTEXT_AGRREMENT_BY_LANGUAGE
testProviderShouldReturnSourceDirectoriesWhenSourceDirectoriesAreSet(ilTermsOfServiceAgreementByLanguageProvider $provider)
testProviderShouldReturnLanguageAdapterWhenLanguageAdapterIsSet(ilTermsOfServiceAgreementByLanguageProvider $provider)
testProviderReturnsAResultForEveryInstalledLanguage(ilTermsOfServiceAgreementByLanguageProvider $provider)
setSourceDirectories($terms_of_service_source_directories)
testAgreementByLanguageProviderCanBeCreatedByFactory()
Create styles array
The data for the language used.
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'