ILIAS  release_5-3 Revision v5.3.23-19-g915713cf615
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  define('CLIENT_ID', 'phpunit');
25  }
26 
27  parent::setUp();
28  }
29 
33  public function testInstanceCanBeCreated()
34  {
36  $this->assertInstanceOf('ilTermsOfServiceTableDataProviderFactory', $factory);
37  $factory->setDatabaseAdapter($this->getMockBuilder('ilDBInterface')->getMock());
38  $factory->setLanguageAdapter($this->getMockBuilder('ilLanguage')->setMethods(array('toJSON', 'getInstalledLanguages', 'getLangKey', 'getDefaultLanguage'))->disableOriginalConstructor()->getMock());
39  return $factory;
40  }
41 
48  {
49  $this->assertException(InvalidArgumentException::class);
50  $factory->getByContext('PHP unit');
51  }
52 
58  {
59  $lng = $this->getMockBuilder('ilLanguage')->setMethods(array('toJSON', 'getInstalledLanguages'))->disableOriginalConstructor()->getMock();
60  $factory->setLanguageAdapter($lng);
61  $this->assertEquals($lng, $factory->getLanguageAdapter());
62  }
63 
69  {
70  $db = $this->getMockBuilder('ilDBInterface')->getMock();
71  $factory->setDatabaseAdapter($db);
72  $this->assertEquals($db, $factory->getDatabaseAdapter());
73  }
74 
81  {
82  $this->assertException(ilTermsOfServiceMissingLanguageAdapterException::class);
83  $factory->setLanguageAdapter(null);
85  }
86 
93  {
94  $this->assertException(ilTermsOfServiceMissingDatabaseAdapterException::class);
95  $factory->setDatabaseAdapter(null);
97  }
98 
104  {
105  $factory->setLanguageAdapter($this->getMockBuilder('ilLanguage')->setMethods(array('toJSON', 'getInstalledLanguages'))->disableOriginalConstructor()->getMock());
106  $this->assertInstanceOf('ilTermsOfServiceAgreementByLanguageProvider', $factory->getByContext(ilTermsOfServiceTableDataProviderFactory::CONTEXT_AGRREMENT_BY_LANGUAGE));
107  }
108 
114  {
115  $factory->setDatabaseAdapter($this->getMockBuilder('ilDBInterface')->getMock());
116  $this->assertInstanceOf('ilTermsOfServiceAcceptanceHistoryProvider', $factory->getByContext(ilTermsOfServiceTableDataProviderFactory::CONTEXT_ACCEPTANCE_HISTORY));
117  }
118 }
testExceptionIsRaisedWhenAgreementByLanguageProviderIsRequestedWithoutCompleteFactoryConfiguration(ilTermsOfServiceTableDataProviderFactory $factory)
testInstanceCanBeCreated
testFactoryShouldReturnLanguageAdapterWhenLanguageAdapterIsSet(ilTermsOfServiceTableDataProviderFactory $factory)
$factory
Definition: metadata.php:47
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