ILIAS  Release_4_4_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
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

Detailed Description

Member Function Documentation

ilTermsOfServiceAgreementsByLanguageTableDataProviderTest::setUp ( )

Definition at line 20 of file ilTermsOfServiceAgreementsByLanguageTableDataProviderTest.php.

{
vfsStreamWrapper::register();
}
ilTermsOfServiceAgreementsByLanguageTableDataProviderTest::testAgreementByLanguageProviderCanBeCreatedByFactory ( )
Returns
ilTermsOfServiceAgreementByLanguageProvider

Definition at line 28 of file ilTermsOfServiceAgreementsByLanguageTableDataProviderTest.php.

References ilTermsOfServiceTableDataProviderFactory\CONTEXT_AGRREMENT_BY_LANGUAGE.

{
require_once 'Services/TermsOfService/classes/class.ilTermsOfServiceTableDataProviderFactory.php';
$factory->setLanguageAdapter($this->getMockBuilder('ilLanguage')->disableOriginalConstructor()->getMock());
$this->assertInstanceOf('ilTermsOfServiceAgreementByLanguageProvider', $provider);
$this->assertInstanceOf('ilTermsOfServiceTableDataProvider', $provider);
return $provider;
}
ilTermsOfServiceAgreementsByLanguageTableDataProviderTest::testProviderReturnsAResultForEveryInstalledLanguage ( ilTermsOfServiceAgreementByLanguageProvider  $provider)
Parameters
ilTermsOfServiceAgreementByLanguageProvider$providertestAgreementByLanguageProviderCanBeCreatedByFactory

Definition at line 45 of file ilTermsOfServiceAgreementsByLanguageTableDataProviderTest.php.

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

{
$client_rel_path = implode('/', array('clients', 'default', 'agreement'));
$global_rel_path = implode('/', array('global', 'agreement'));
$root = vfsStreamWrapper::setRoot(new vfsStreamDirectory('root'));
$customizing_dir = vfsStream::newDirectory('Customizing')->at($root);
$client_dir = vfsStream::newDirectory($client_rel_path)->at($customizing_dir);
vfsStream::newFile('agreement_de.html', 0777)->at($client_dir);
file_put_contents(vfsStream::url('root/Customizing/' . $client_rel_path . '/agreement_de.html'), 'phpunit');
$global_dir = vfsStream::newDirectory($global_rel_path)->at($customizing_dir);
vfsStream::newFile('agreement_en.html', 0777)->at($global_dir);
file_put_contents(vfsStream::url('root/Customizing/' . $global_rel_path . '/agreement_en.html'), 'phpunit');
$provider->setSourceDirectories(array(
vfsStream::url('root/Customizing/' . $client_rel_path),
vfsStream::url('root/Customizing/' . $global_rel_path)
));
$lng = $this->getMockBuilder('ilLanguage')->disableOriginalConstructor()->getMock();
$installed_languages = array('en', 'de', 'fr');
$lng->expects($this->once())->method('getInstalledLanguages')->will($this->onConsecutiveCalls($installed_languages));
$provider->setLanguageAdapter($lng);
$data = $provider->getList(array(), array());
$this->assertArrayHasKey('items', $data);
$this->assertArrayHasKey('cnt', $data);
$this->assertCount(count($installed_languages), $data['items']);
$this->assertEquals(count($installed_languages), $data['cnt']);
for($i = 0; $i < count($installed_languages); $i++)
{
$this->assertArrayHasKey('language', $data['items'][$i]);
$this->assertArrayHasKey('agreement', $data['items'][$i]);
$this->assertArrayHasKey('agreement_document', $data['items'][$i]);
$this->assertArrayHasKey('agreement_document_modification_ts', $data['items'][$i]);
if($installed_languages[$i] == 'fr')
{
$this->assertFalse(file_exists($data['items'][$i]['agreement_document']));
}
else
{
$this->assertTrue(file_exists($data['items'][$i]['agreement_document']));
}
}
}

+ Here is the call graph for this function:

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

Definition at line 99 of file ilTermsOfServiceAgreementsByLanguageTableDataProviderTest.php.

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

{
$expected = $this->getMockBuilder('ilLanguage')->disableOriginalConstructor()->getMock();
$provider->setLanguageAdapter($expected);
$this->assertEquals($expected, $provider->getLanguageAdapter());
}

+ Here is the call graph for this function:

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

Definition at line 111 of file ilTermsOfServiceAgreementsByLanguageTableDataProviderTest.php.

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

{
$expected = array('/phpunit', '/ilias');
$provider->setSourceDirectories($expected);
$this->assertEquals($expected, $provider->getSourceDirectories());
}

+ Here is the call graph for this function:

Field Documentation

ilTermsOfServiceAgreementsByLanguageTableDataProviderTest::$backupGlobals = false
protected

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