ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilTermsOfServiceAcceptanceDatabaseGatewayTest Class Reference
+ Inheritance diagram for ilTermsOfServiceAcceptanceDatabaseGatewayTest:
+ Collaboration diagram for ilTermsOfServiceAcceptanceDatabaseGatewayTest:

Public Member Functions

 setUp ()
 testInstanceCanBeCreated ()
 testAcceptanceIsTrackedAndCreatesANewTermsOfServicesVersion ()
 testAcceptanceIsTrackedAndRefersToAnExistingTermsOfServicesVersion ()
 testCurrentAcceptanceOfUserIsLoaded ()
 testAcceptanceHistoryOfAUserIsDeleted ()

Protected Attributes

 $backupGlobals = false

Detailed Description

Author
Michael Jansen mjans.nosp@m.en@d.nosp@m.ataba.nosp@m.y.de
Version
$Id$

Definition at line 11 of file ilTermsOfServiceAcceptanceDatabaseGatewayTest.php.

Member Function Documentation

ilTermsOfServiceAcceptanceDatabaseGatewayTest::setUp ( )

Definition at line 21 of file ilTermsOfServiceAcceptanceDatabaseGatewayTest.php.

{
}
ilTermsOfServiceAcceptanceDatabaseGatewayTest::testAcceptanceHistoryOfAUserIsDeleted ( )

Definition at line 149 of file ilTermsOfServiceAcceptanceDatabaseGatewayTest.php.

{
$entity->setUserId(4711);
$database = $this->getMockBuilder('ilDB')->disableOriginalConstructor()->getMock();
$database->expects($this->once())->method('quote')->with($entity->getUserId(), 'integer')->will($this->returnValue($entity->getUserId()));
$database->expects($this->once())->method('manipulate')->with('DELETE FROM tos_acceptance_track WHERE usr_id = ' . $entity->getUserId());
$gateway = new ilTermsOfServiceAcceptanceDatabaseGateway($database);
$gateway->deleteAcceptanceHistoryByUser($entity);
}
ilTermsOfServiceAcceptanceDatabaseGatewayTest::testAcceptanceIsTrackedAndCreatesANewTermsOfServicesVersion ( )

Definition at line 38 of file ilTermsOfServiceAcceptanceDatabaseGatewayTest.php.

References $result.

{
$entity->setUserId(666);
$entity->setIso2LanguageCode('de');
$entity->setSource('/path/to/file');
$entity->setSourceType(0);
$entity->setText('PHP Unit');
$entity->setTimestamp(time());
$entity->setHash(md5($entity->getText()));
$expected_id = 4711;
$database = $this->getMockBuilder('ilDB')->disableOriginalConstructor()->getMock();
$result = $this->getMockBuilder('MDB2_BufferedResult_mysqli')->disableOriginalConstructor()->getMock();
$database->expects($this->once())->method('queryF')->with('SELECT id FROM tos_versions WHERE hash = %s AND lng = %s', array('text', 'text'), array($entity->getHash(), $entity->getIso2LanguageCode()))->will($this->returnValue($result));
$database->expects($this->once())->method('numRows')->with($result)->will($this->returnValue(0));
$database->expects($this->once())->method('nextId')->with('tos_versions')->will($this->returnValue($expected_id));
$expectedVersions = array(
'id' => array('integer', $expected_id),
'lng' => array('text', $entity->getIso2LanguageCode()),
'src' => array('text', $entity->getSource()),
'src_type' => array('integer', $entity->getSourceType()),
'text' => array('clob', $entity->getText()),
'hash' => array('text', $entity->getHash()),
'ts' => array('integer', $entity->getTimestamp())
);
$expectedTracking = array(
'tosv_id' => array('integer', $expected_id),
'usr_id' => array('integer', $entity->getUserId()),
'ts' => array('integer', $entity->getTimestamp())
);
$database->expects($this->exactly(2))->method('insert')->with(
$this->logicalOr('tos_versions', 'tos_acceptance_track'),
$this->logicalOr($expectedVersions, $expectedTracking)
);
$gateway = new ilTermsOfServiceAcceptanceDatabaseGateway($database);
$gateway->trackAcceptance($entity);
}
ilTermsOfServiceAcceptanceDatabaseGatewayTest::testAcceptanceIsTrackedAndRefersToAnExistingTermsOfServicesVersion ( )

Definition at line 84 of file ilTermsOfServiceAcceptanceDatabaseGatewayTest.php.

References $result.

{
$entity->setUserId(666);
$entity->setIso2LanguageCode('de');
$entity->setSource('/path/to/file');
$entity->setSourceType(0);
$entity->setText('PHP Unit');
$entity->setTimestamp(time());
$entity->setHash(md5($entity->getText()));
$expected_id = 4711;
$database = $this->getMockBuilder('ilDB')->disableOriginalConstructor()->getMock();
$result = $this->getMockBuilder('MDB2_BufferedResult_mysqli')->disableOriginalConstructor()->getMock();
$database->expects($this->once())->method('queryF')->with('SELECT id FROM tos_versions WHERE hash = %s AND lng = %s', array('text', 'text'), array($entity->getHash(), $entity->getIso2LanguageCode()))->will($this->returnValue($result));
$database->expects($this->once())->method('numRows')->with($result)->will($this->returnValue(1));
$database->expects($this->once())->method('fetchAssoc')->with($result)->will($this->returnValue(array('id' => $expected_id)));
$expectedTracking = array(
'tosv_id' => array('integer', $expected_id),
'usr_id' => array('integer', $entity->getUserId()),
'ts' => array('integer', $entity->getTimestamp())
);
$database->expects($this->once())->method('insert')->with('tos_acceptance_track', $expectedTracking);
$gateway = new ilTermsOfServiceAcceptanceDatabaseGateway($database);
$gateway->trackAcceptance($entity);
}
ilTermsOfServiceAcceptanceDatabaseGatewayTest::testCurrentAcceptanceOfUserIsLoaded ( )

Definition at line 118 of file ilTermsOfServiceAcceptanceDatabaseGatewayTest.php.

{
$expected = array(
'id' => 4711,
'usr_id' => 6,
'lng' => 'de',
'src' => '/path/to/file',
'src_type' => 0,
'text' => 'PHP Unit',
'accepted_ts' => time()
);
$database = $this->getMockBuilder('ilDB')->disableOriginalConstructor()->getMock();
$database->expects($this->once())->method('fetchAssoc')->will($this->onConsecutiveCalls($expected));
$gateway = new ilTermsOfServiceAcceptanceDatabaseGateway($database);
$gateway->loadCurrentAcceptanceOfUser($entity);
$this->assertEquals($expected['id'], $entity->getId());
$this->assertEquals($expected['usr_id'], $entity->getUserId());
$this->assertEquals($expected['lng'], $entity->getIso2LanguageCode());
$this->assertEquals($expected['src'], $entity->getSource());
$this->assertEquals($expected['src_type'], $entity->getSourceType());
$this->assertEquals($expected['text'], $entity->getText());
$this->assertEquals($expected['accepted_ts'], $entity->getTimestamp());
}
ilTermsOfServiceAcceptanceDatabaseGatewayTest::testInstanceCanBeCreated ( )

Definition at line 28 of file ilTermsOfServiceAcceptanceDatabaseGatewayTest.php.

{
$database = $this->getMockBuilder('ilDB')->disableOriginalConstructor()->getMock();
$gateway = new ilTermsOfServiceAcceptanceDatabaseGateway($database);
$this->assertInstanceOf('ilTermsOfServiceAcceptanceDatabaseGateway', $gateway);
}

Field Documentation

ilTermsOfServiceAcceptanceDatabaseGatewayTest::$backupGlobals = false
protected

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