ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
ilTermsOfServiceAgreementsByLanguageTableDataProviderTest Class Reference
+ Inheritance diagram for ilTermsOfServiceAgreementsByLanguageTableDataProviderTest:
+ Collaboration diagram for ilTermsOfServiceAgreementsByLanguageTableDataProviderTest:

Public Member Functions

 setUp ()
 
 testAgreementByLanguageProviderCanBeCreatedByFactory ()
 
 testProviderReturnsAResultForEveryInstalledLanguage (ilTermsOfServiceAgreementByLanguageProvider $provider)
 
 testProviderShouldReturnLanguageAdapterWhenLanguageAdapterIsSet (ilTermsOfServiceAgreementByLanguageProvider $provider)
 
 testProviderShouldReturnSourceDirectoriesWhenSourceDirectoriesAreSet (ilTermsOfServiceAgreementByLanguageProvider $provider)
 

Protected Attributes

 $backupGlobals = false
 

Additional Inherited Members

- Protected Member Functions inherited from ilTermsOfServiceBaseTest
 assertException ($exception_class)
 

Detailed Description

Member Function Documentation

◆ setUp()

ilTermsOfServiceAgreementsByLanguageTableDataProviderTest::setUp ( )

Definition at line 22 of file ilTermsOfServiceAgreementsByLanguageTableDataProviderTest.php.

References defined.

23  {
24  if (!defined('CLIENT_ID')) {
25  define('CLIENT_ID', 'phpunit');
26  }
27 
28  vfs\vfsStreamWrapper::register();
29 
30  parent::setUp();
31  }
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'
Definition: bootstrap.php:27

◆ testAgreementByLanguageProviderCanBeCreatedByFactory()

ilTermsOfServiceAgreementsByLanguageTableDataProviderTest::testAgreementByLanguageProviderCanBeCreatedByFactory ( )
Returns
ilTermsOfServiceAgreementByLanguageProvider

Definition at line 36 of file ilTermsOfServiceAgreementsByLanguageTableDataProviderTest.php.

References $factory, League\OAuth2\Client\Provider\$provider, array, and ilTermsOfServiceTableDataProviderFactory\CONTEXT_AGRREMENT_BY_LANGUAGE.

37  {
38  require_once 'Services/TermsOfService/classes/class.ilTermsOfServiceTableDataProviderFactory.php';
40  $factory->setLanguageAdapter($this->getMockBuilder('ilLanguage')->setMethods(array('toJSON', 'getInstalledLanguages'))->disableOriginalConstructor()->getMock());
42 
43  $this->assertInstanceOf('ilTermsOfServiceAgreementByLanguageProvider', $provider);
44  $this->assertInstanceOf('ilTermsOfServiceTableDataProvider', $provider);
45 
46  return $provider;
47  }
$factory
Definition: metadata.php:47
Create styles array
The data for the language used.

◆ testProviderReturnsAResultForEveryInstalledLanguage()

ilTermsOfServiceAgreementsByLanguageTableDataProviderTest::testProviderReturnsAResultForEveryInstalledLanguage ( ilTermsOfServiceAgreementByLanguageProvider  $provider)
Parameters
ilTermsOfServiceAgreementByLanguageProvider$providertestAgreementByLanguageProviderCanBeCreatedByFactory

Definition at line 53 of file ilTermsOfServiceAgreementsByLanguageTableDataProviderTest.php.

References $data, $i, $lng, array, ilTermsOfServiceAgreementByLanguageProvider\getList(), ilTermsOfServiceAgreementByLanguageProvider\setLanguageAdapter(), and ilTermsOfServiceAgreementByLanguageProvider\setSourceDirectories().

54  {
55  $client_rel_path = implode('/', array('clients', 'default', 'agreement'));
56  $global_rel_path = implode('/', array('global', 'agreement'));
57 
58  $root = vfs\vfsStreamWrapper::setRoot(new vfs\vfsStreamDirectory('root'));
59  $customizing_dir = vfs\vfsStream::newDirectory('Customizing')->at($root);
60 
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');
64 
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');
68 
69  $provider->setSourceDirectories(array(
70  vfs\vfsStream::url('root/Customizing/' . $client_rel_path),
71  vfs\vfsStream::url('root/Customizing/' . $global_rel_path)
72  ));
73 
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));
77  $provider->setLanguageAdapter($lng);
78 
79  $data = $provider->getList(array(), array());
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']);
84 
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]);
90 
91  if ($installed_languages[$i] == 'fr') {
92  $this->assertFalse(file_exists($data['items'][$i]['agreement_document']));
93  } else {
94  $this->assertTrue(file_exists($data['items'][$i]['agreement_document']));
95  }
96  }
97  }
getList(array $params, array $filter)
{Table paramaters like limit or order Filter settings array}
Create styles array
The data for the language used.
global $lng
Definition: privfeed.php:17
$i
Definition: disco.tpl.php:19
+ Here is the call graph for this function:

◆ testProviderShouldReturnLanguageAdapterWhenLanguageAdapterIsSet()

ilTermsOfServiceAgreementsByLanguageTableDataProviderTest::testProviderShouldReturnLanguageAdapterWhenLanguageAdapterIsSet ( ilTermsOfServiceAgreementByLanguageProvider  $provider)
Parameters
ilTermsOfServiceAgreementByLanguageProvider$providertestAgreementByLanguageProviderCanBeCreatedByFactory

Definition at line 103 of file ilTermsOfServiceAgreementsByLanguageTableDataProviderTest.php.

References array, ilTermsOfServiceAgreementByLanguageProvider\getLanguageAdapter(), and ilTermsOfServiceAgreementByLanguageProvider\setLanguageAdapter().

104  {
105  $expected = $this->getMockBuilder('ilLanguage')->setMethods(array('toJSON', 'getInstalledLanguages'))->disableOriginalConstructor()->getMock();
106 
107  $provider->setLanguageAdapter($expected);
108  $this->assertEquals($expected, $provider->getLanguageAdapter());
109  }
Create styles array
The data for the language used.
+ Here is the call graph for this function:

◆ testProviderShouldReturnSourceDirectoriesWhenSourceDirectoriesAreSet()

ilTermsOfServiceAgreementsByLanguageTableDataProviderTest::testProviderShouldReturnSourceDirectoriesWhenSourceDirectoriesAreSet ( ilTermsOfServiceAgreementByLanguageProvider  $provider)
Parameters
ilTermsOfServiceAgreementByLanguageProvider$providertestAgreementByLanguageProviderCanBeCreatedByFactory

Definition at line 115 of file ilTermsOfServiceAgreementsByLanguageTableDataProviderTest.php.

References array, ilTermsOfServiceAgreementByLanguageProvider\getSourceDirectories(), and ilTermsOfServiceAgreementByLanguageProvider\setSourceDirectories().

116  {
117  $expected = array('/phpunit', '/ilias');
118 
119  $provider->setSourceDirectories($expected);
120  $this->assertEquals($expected, $provider->getSourceDirectories());
121  }
Create styles array
The data for the language used.
+ Here is the call graph for this function:

Field Documentation

◆ $backupGlobals

ilTermsOfServiceAgreementsByLanguageTableDataProviderTest::$backupGlobals = false
protected

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