ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilTermsOfServiceAcceptanceHistoryProviderTest Class Reference

Class ilTermsOfServiceAcceptanceHistoryProviderTest. More...

+ Inheritance diagram for ilTermsOfServiceAcceptanceHistoryProviderTest:
+ Collaboration diagram for ilTermsOfServiceAcceptanceHistoryProviderTest:

Public Member Functions

 testHistoryProviderCanBeCreatedByFactory ()
 
 testListCanBeRetrieved ()
 
 testRetrievingListThrowsExceptionsWhenInvalidArgumentsArePassed ()
 

Additional Inherited Members

- Protected Member Functions inherited from ilTermsOfServiceBaseTest
 setUp ()
 
 getLanguageMock ()
 
 setGlobalVariable (string $name, $value)
 
 assertException (string $exceptionClass)
 
 getCriterionConfig ($value=null)
 
- Protected Attributes inherited from ilTermsOfServiceBaseTest
 $dic
 

Detailed Description

Member Function Documentation

◆ testHistoryProviderCanBeCreatedByFactory()

ilTermsOfServiceAcceptanceHistoryProviderTest::testHistoryProviderCanBeCreatedByFactory ( )
Exceptions

Definition at line 13 of file ilTermsOfServiceAcceptanceHistoryProviderTest.php.

References $factory, PHPMailer\PHPMailer\$provider, and ilTermsOfServiceTableDataProviderFactory\CONTEXT_ACCEPTANCE_HISTORY.

14  {
15  $factory = new \ilTermsOfServiceTableDataProviderFactory();
16  $factory->setDatabaseAdapter($this->getMockBuilder(\ilDBInterface::class)->getMock());
17 
19 
20  $this->assertInstanceOf(\ilTermsOfServiceAcceptanceHistoryProvider::class, $provider);
21  $this->assertInstanceOf(\ilTermsOfServiceTableDatabaseDataProvider::class, $provider);
22  $this->assertInstanceOf(\ilTermsOfServiceTableDataProvider::class, $provider);
23  }
$factory
Definition: metadata.php:43

◆ testListCanBeRetrieved()

ilTermsOfServiceAcceptanceHistoryProviderTest::testListCanBeRetrieved ( )

Definition at line 28 of file ilTermsOfServiceAcceptanceHistoryProviderTest.php.

References $data, $factory, PHPMailer\PHPMailer\$provider, $result, and ilTermsOfServiceTableDataProviderFactory\CONTEXT_ACCEPTANCE_HISTORY.

29  {
30  $database = $this->getMockBuilder(\ilDBInterface::class)->getMock();
31  $result = $this->getMockBuilder(\ilDBStatement::class)->getMock();
32 
33  $factory = new \ilTermsOfServiceTableDataProviderFactory();
34  $factory->setDatabaseAdapter($database);
35 
37 
38  $database
39  ->expects($this->exactly(2))
40  ->method('query')
41  ->with($this->stringContains('SELECT'))
42  ->will($this->returnValue($result));
43 
44  $database
45  ->expects($this->exactly(4))
46  ->method('fetchAssoc')
47  ->will($this->onConsecutiveCalls(['phpunit'], ['phpunit'], [], ['cnt' => 2]));
48 
49  $database
50  ->expects($this->any())
51  ->method('like')
52  ->with(
53  $this->isType('string'),
54  $this->isType('string'),
55  $this->isType('string')
56  )->will($this->returnArgument(2));
57 
58  $database
59  ->expects($this->any())
60  ->method('quote')
61  ->with($this->anything(), $this->isType('string'))
62  ->will($this->returnArgument(0));
63 
64  $data = $provider->getList(
65  [
66  'limit' => 5,
67  'order_field' => 'ts'
68  ],
69  [
70  'query' => 'phpunit',
71  'period' => [
72  'start' => time(),
73  'end' => time()
74  ]
75  ]
76  );
77 
78  $this->assertArrayHasKey('items', $data);
79  $this->assertArrayHasKey('cnt', $data);
80  $this->assertCount(2, $data['items']);
81  $this->assertEquals(2, $data['cnt']);
82  }
$result
$factory
Definition: metadata.php:43
$data
Definition: bench.php:6

◆ testRetrievingListThrowsExceptionsWhenInvalidArgumentsArePassed()

ilTermsOfServiceAcceptanceHistoryProviderTest::testRetrievingListThrowsExceptionsWhenInvalidArgumentsArePassed ( )

Definition at line 87 of file ilTermsOfServiceAcceptanceHistoryProviderTest.php.

References $factory, PHPMailer\PHPMailer\$provider, and ilTermsOfServiceTableDataProviderFactory\CONTEXT_ACCEPTANCE_HISTORY.

88  {
89  $database = $this->getMockBuilder(\ilDBInterface::class)->getMock();
90 
91  $factory = new \ilTermsOfServiceTableDataProviderFactory();
92  $factory->setDatabaseAdapter($database);
93 
95 
96  try {
97  $provider->getList(array('limit' => 'phpunit'), array());
98  $this->fail('An expected exception has not been raised.');
99  } catch (\InvalidArgumentException $e) {
100  }
101 
102  try {
103  $provider->getList(array('limit' => 5, 'offset' => 'phpunit'), array());
104  $this->fail('An expected exception has not been raised.');
105  } catch (\InvalidArgumentException $e) {
106  }
107 
108  try {
109  $provider->getList(array('order_field' => 'phpunit'), array());
110  $this->fail('An expected exception has not been raised.');
111  } catch (\InvalidArgumentException $e) {
112  }
113 
114  try {
115  $provider->getList(array('order_field' => 5), array());
116  $this->fail('An expected exception has not been raised.');
117  } catch (\InvalidArgumentException $e) {
118  }
119 
120  try {
121  $provider->getList(array('order_field' => 'ts', 'order_direction' => 'phpunit'), array());
122  $this->fail('An expected exception has not been raised.');
123  } catch (\InvalidArgumentException $e) {
124  }
125  }
$factory
Definition: metadata.php:43

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