ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
ilTermsOfServiceTableDataProviderFactoryTest.php
Go to the documentation of this file.
1 <?php
2 /* Copyright (c) 1998-2012 ILIAS open source, Extended GPL, see docs/LICENSE */
3 
4 require_once 'Services/TermsOfService/classes/class.ilTermsOfServiceTableDataProviderFactory.php';
5 require_once 'Services/TermsOfService/test/ilTermsOfServiceBaseTest.php';
6 
12 {
16  protected $backupGlobals = false;
17 
21  public function setUp()
22  {
23  if(!defined('CLIENT_ID'))
24  {
25  define('CLIENT_ID', 'phpunit');
26  }
27 
28  parent::setUp();
29  }
30 
34  public function testInstanceCanBeCreated()
35  {
37  $this->assertInstanceOf('ilTermsOfServiceTableDataProviderFactory', $factory);
38  $factory->setDatabaseAdapter($this->getMockBuilder('ilDBInterface')->getMock());
39  $factory->setLanguageAdapter($this->getMockBuilder('ilLanguage')->setMethods(array('toJSON', 'getInstalledLanguages', 'getLangKey', 'getDefaultLanguage'))->disableOriginalConstructor()->getMock());
40  return $factory;
41  }
42 
49  {
50  $this->assertException(InvalidArgumentException::class);
51  $factory->getByContext('PHP unit');
52  }
53 
59  {
60  $lng = $this->getMockBuilder('ilLanguage')->setMethods(array('toJSON', 'getInstalledLanguages'))->disableOriginalConstructor()->getMock();
61  $factory->setLanguageAdapter($lng);
62  $this->assertEquals($lng, $factory->getLanguageAdapter());
63  }
64 
70  {
71  $db = $this->getMockBuilder('ilDBInterface')->getMock();
72  $factory->setDatabaseAdapter($db);
73  $this->assertEquals($db, $factory->getDatabaseAdapter());
74  }
75 
82  {
83  $this->assertException(ilTermsOfServiceMissingLanguageAdapterException::class);
84  $factory->setLanguageAdapter(null);
86  }
87 
94  {
95  $this->assertException(ilTermsOfServiceMissingDatabaseAdapterException::class);
96  $factory->setDatabaseAdapter(null);
98  }
99 
105  {
106  $factory->setLanguageAdapter($this->getMockBuilder('ilLanguage')->setMethods(array('toJSON', 'getInstalledLanguages'))->disableOriginalConstructor()->getMock());
107  $this->assertInstanceOf('ilTermsOfServiceAgreementByLanguageProvider', $factory->getByContext(ilTermsOfServiceTableDataProviderFactory::CONTEXT_AGRREMENT_BY_LANGUAGE));
108  }
109 
115  {
116  $factory->setDatabaseAdapter($this->getMockBuilder('ilDBInterface')->getMock());
117  $this->assertInstanceOf('ilTermsOfServiceAcceptanceHistoryProvider', $factory->getByContext(ilTermsOfServiceTableDataProviderFactory::CONTEXT_ACCEPTANCE_HISTORY));
118  }
119 }
testExceptionIsRaisedWhenAgreementByLanguageProviderIsRequestedWithoutCompleteFactoryConfiguration(ilTermsOfServiceTableDataProviderFactory $factory)
testInstanceCanBeCreated
testFactoryShouldReturnLanguageAdapterWhenLanguageAdapterIsSet(ilTermsOfServiceTableDataProviderFactory $factory)
testExceptionIsRaisedWhenAcceptanceHistoryProviderIsRequestedWithoutCompleteFactoryConfiguration(ilTermsOfServiceTableDataProviderFactory $factory)
testInstanceCanBeCreated
Create styles array
The data for the language used.
testFactoryShouldReturnAcceptanceHistoryProviderWhenRequested(ilTermsOfServiceTableDataProviderFactory $factory)
testExceptionIsRaisedWhenUnsupportedProviderIsRequested(ilTermsOfServiceTableDataProviderFactory $factory)
testInstanceCanBeCreated
global $lng
Definition: privfeed.php:17
testFactoryShouldReturnAgreementByLanguageProviderWhenRequested(ilTermsOfServiceTableDataProviderFactory $factory)
testFactoryShouldReturnDatabaseAdapterWhenDatabaseAdapterIsSet(ilTermsOfServiceTableDataProviderFactory $factory)
defined( 'APPLICATION_ENV')||define( 'APPLICATION_ENV'
Definition: bootstrap.php:27