ILIAS  Release_5_0_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

Private Member Functions

 isVsfStreamInstalled ()
 skipIfvfsStreamNotSupported ()

Detailed Description

Member Function Documentation

ilTermsOfServiceAgreementsByLanguageTableDataProviderTest::isVsfStreamInstalled ( )
private
Returns
bool

Definition at line 18 of file ilTermsOfServiceAgreementsByLanguageTableDataProviderTest.php.

Referenced by setUp(), and skipIfvfsStreamNotSupported().

{
return @include_once('vfsStream.php');
}

+ Here is the caller graph for this function:

ilTermsOfServiceAgreementsByLanguageTableDataProviderTest::setUp ( )

Definition at line 37 of file ilTermsOfServiceAgreementsByLanguageTableDataProviderTest.php.

References isVsfStreamInstalled().

{
if($this->isVsfStreamInstalled())
{
vfsStreamWrapper::register();
}
}

+ Here is the call graph for this function:

ilTermsOfServiceAgreementsByLanguageTableDataProviderTest::skipIfvfsStreamNotSupported ( )
private

Definition at line 26 of file ilTermsOfServiceAgreementsByLanguageTableDataProviderTest.php.

References isVsfStreamInstalled().

Referenced by testProviderReturnsAResultForEveryInstalledLanguage().

{
if(!$this->isVsfStreamInstalled())
{
$this->markTestSkipped('Requires vfsStream (http://vfs.bovigo.org)');
}
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilTermsOfServiceAgreementsByLanguageTableDataProviderTest::testAgreementByLanguageProviderCanBeCreatedByFactory ( )
Returns
ilTermsOfServiceAgreementByLanguageProvider

Definition at line 48 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 65 of file ilTermsOfServiceAgreementsByLanguageTableDataProviderTest.php.

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

{
$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 121 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 133 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: