4 require_once
'Services/TermsOfService/classes/class.ilTermsOfServiceTableDataProviderFactory.php';
5 require_once
'Services/TermsOfService/classes/class.ilTermsOfServiceTableDatabaseDataProvider.php';
31 $factory->setDatabaseAdapter($this->getMockBuilder(
'ilDB')->disableOriginalConstructor()->getMock());
34 $this->assertInstanceOf(
'ilTermsOfServiceAcceptanceHistoryProvider', $provider);
35 $this->assertInstanceOf(
'ilTermsOfServiceTableDatabaseDataProvider', $provider);
36 $this->assertInstanceOf(
'ilTermsOfServiceTableDataProvider', $provider);
46 $database = $this->getMockBuilder(
'ilDB')->disableOriginalConstructor()->getMock();
47 $result = $this->getMockBuilder(
'MDB2_BufferedResult_mysqli')->disableOriginalConstructor()->getMock();
50 $factory->setDatabaseAdapter($database);
53 $database->expects($this->exactly(2))->method(
'query')->with($this->stringContains(
'SELECT'))->will($this->returnValue(
$result));
54 $database->expects($this->exactly(4))->method(
'fetchAssoc')->will($this->onConsecutiveCalls(array(
'phpunit'), array(
'phpunit'), array(), array(
'cnt' => 2)));
55 $database->expects($this->any())->method(
'like')->with(
56 $this->isType(
'string'),
57 $this->isType(
'string'),
58 $this->isType(
'string')
59 )->will($this->returnArgument(2));
60 $database->expects($this->any())->method(
'quote')->with($this->anything(), $this->isType(
'string'))->will($this->returnArgument(0));
62 $data = $provider->getList(
76 $this->assertArrayHasKey(
'items', $data);
77 $this->assertArrayHasKey(
'cnt', $data);
78 $this->assertCount(2, $data[
'items']);
79 $this->assertEquals(2, $data[
'cnt']);
87 $database = $this->getMockBuilder(
'ilDB')->disableOriginalConstructor()->getMock();
89 $factory->setDatabaseAdapter($database);
94 $provider->getList(array(
'limit' =>
'phpunit'), array());
95 $this->fail(
'An expected exception has not been raised.');
97 catch(InvalidArgumentException $e)
103 $provider->getList(array(
'limit' => 5,
'offset' =>
'phpunit'), array());
104 $this->fail(
'An expected exception has not been raised.');
106 catch(InvalidArgumentException $e)
112 $provider->getList(array(
'order_field' =>
'phpunit'), array());
113 $this->fail(
'An expected exception has not been raised.');
115 catch(InvalidArgumentException $e)
121 $provider->getList(array(
'order_field' => 5), array());
122 $this->fail(
'An expected exception has not been raised.');
124 catch(InvalidArgumentException $e)
130 $provider->getList(array(
'order_field' =>
'ts',
'order_direction' =>
'phpunit'), array());
131 $this->fail(
'An expected exception has not been raised.');
133 catch(InvalidArgumentException $e)