Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dokuwiki
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
BRIC
dokuwiki
Commits
55545bcc
Commit
55545bcc
authored
11 years ago
by
Gerrit Uitslag
Browse files
Options
Downloads
Patches
Plain Diff
Add unit tests for getRelativerevision
parent
6556cf69
No related branches found
Branches containing commit
No related tags found
Tags containing commit
Loading
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
_test/tests/inc/changelog_getrelativerevision.test.php
+273
-0
273 additions, 0 deletions
_test/tests/inc/changelog_getrelativerevision.test.php
with
273 additions
and
0 deletions
_test/tests/inc/changelog_getrelativerevision.test.php
0 → 100644
+
273
−
0
View file @
55545bcc
<?php
/**
* Tests for requesting revisioninfo of a revision of a page with getRevisionInfo()
*
* This class uses the files:
* - data/pages/mailinglist.txt
* - data/meta/mailinglist.changes
*/
class
changelog_getrelativerevision_test
extends
DokuWikiTest
{
private
$logline
=
"1362525899 127.0.0.1 E mailinglist pubcie [Data entry]
\n
"
;
private
$pageid
=
'mailinglist'
;
function
setup
()
{
parent
::
setup
();
global
$cache_revinfo
;
$cache
=&
$cache_revinfo
;
if
(
isset
(
$cache
[
'nonexist'
]))
{
unset
(
$cache
[
'nonexist'
]);
}
if
(
isset
(
$cache
[
'mailinglist'
]))
{
unset
(
$cache
[
'mailinglist'
]);
}
}
/**
* no nonexist.changes meta file available
*/
function
test_changemetadatanotexists
()
{
$rev
=
1362525899
;
$dir
=
1
;
$id
=
'nonexist'
;
$revsexpected
=
false
;
$pagelog
=
new
PageRevisionLog
(
$id
,
$chunk_size
=
8192
);
$revs
=
$pagelog
->
getRelativeRevision
(
$rev
,
$dir
,
$media
=
false
);
$this
->
assertEquals
(
$revsexpected
,
$revs
);
}
/**
* no nonexist.changes meta file available
*/
function
test_nodirection
()
{
$rev
=
1362525899
;
$dir
=
0
;
$revsexpected
=
false
;
$pagelog
=
new
PageRevisionLog
(
$this
->
pageid
,
$chunk_size
=
8192
);
$revs
=
$pagelog
->
getRelativeRevision
(
$rev
,
$dir
,
$media
=
false
);
$this
->
assertEquals
(
$revsexpected
,
$revs
);
}
/**
* start at exact current revision of mailinglist page
*
*/
function
test_startatexactcurrentrev
()
{
$rev
=
1374261194
;
$dir
=
1
;
$revsexpected
=
false
;
// global $INFO;
// $INFO = pageinfo();
// var_dump($INFO);
// var_dump($INFO['meta']);
// var_dump($INFO['meta']['last_change']);
// var_dump($INFO['meta']['last_change']['date']);
$pagelog
=
new
PageRevisionLog
(
$this
->
pageid
,
$chunk_size
=
8192
);
$revs
=
$pagelog
->
getRelativeRevision
(
$rev
,
$dir
,
$media
=
false
);
$this
->
assertEquals
(
$revsexpected
,
$revs
);
}
/**
* request existing rev
*/
function
test_requestrev
()
{
$rev
=
1362525359
;
$dir
=
1
;
$revexpected
=
1362525899
;
$infoexpected
=
parseChangelogLine
(
$this
->
logline
);
$pagelog
=
new
PageRevisionLog
(
$this
->
pageid
,
$chunk_size
=
8192
);
$revfound
=
$pagelog
->
getRelativeRevision
(
$rev
,
$dir
,
$media
=
false
);
$this
->
assertEquals
(
$revexpected
,
$revfound
);
//checked info returned from cache
$info
=
$pagelog
->
getRevisionInfo
(
$revfound
,
$media
=
false
);
$this
->
assertEquals
(
$infoexpected
,
$info
);
}
/**
* request existing rev with chucked reading
*/
function
test_requestnextrev_chuncked
()
{
$rev
=
1362525899
;
$dir
=
1
;
$revexpected
=
1362525926
;
$pagelog
=
new
PageRevisionLog
(
$this
->
pageid
,
$chunk_size
=
512
);
$revfound
=
$pagelog
->
getRelativeRevision
(
$rev
,
$dir
,
$media
=
false
);
$this
->
assertEquals
(
$revexpected
,
$revfound
);
}
/**
* request existing rev
*/
function
test_requestnextfifthrev
()
{
$rev
=
1362525899
;
$dir
=
5
;
$revexpected
=
1362526767
;
$pagelog
=
new
PageRevisionLog
(
$this
->
pageid
,
$chunk_size
=
8192
);
$revfound
=
$pagelog
->
getRelativeRevision
(
$rev
,
$dir
,
$media
=
false
);
$this
->
assertEquals
(
$revexpected
,
$revfound
);
}
/**
* request existing rev with chucked reading
*/
function
test_requestnextfifthrev_chuncked
()
{
$rev
=
1362525899
;
$dir
=
5
;
$revexpected
=
1362526767
;
$pagelog
=
new
PageRevisionLog
(
$this
->
pageid
,
$chunk_size
=
512
);
$revfound
=
$pagelog
->
getRelativeRevision
(
$rev
,
$dir
,
$media
=
false
);
$this
->
assertEquals
(
$revexpected
,
$revfound
);
}
/**
* request existing rev
*/
function
test_requestprevrev
()
{
$rev
=
1362525899
;
$dir1
=
-
1
;
$dir5
=
-
5
;
$revexpected1
=
1362525359
;
$revexpected5
=
1360110636
;
$pagelog
=
new
PageRevisionLog
(
$this
->
pageid
,
$chunk_size
=
8192
);
$revfound1
=
$pagelog
->
getRelativeRevision
(
$rev
,
$dir1
,
$media
=
false
);
$this
->
assertEquals
(
$revexpected1
,
$revfound1
);
$revfound5
=
$pagelog
->
getRelativeRevision
(
$rev
,
$dir5
,
$media
=
false
);
$this
->
assertEquals
(
$revexpected5
,
$revfound5
);
}
/**
* request existing rev with chucked reading
*/
function
test_requestprevrev_chuncked
()
{
$rev
=
1362525899
;
$dir1
=
-
1
;
$dir5
=
-
5
;
$revexpected1
=
1362525359
;
$revexpected5
=
1360110636
;
$pagelog
=
new
PageRevisionLog
(
$this
->
pageid
,
$chunk_size
=
512
);
$revfound1
=
$pagelog
->
getRelativeRevision
(
$rev
,
$dir1
,
$media
=
false
);
$this
->
assertEquals
(
$revexpected1
,
$revfound1
);
$revfound5
=
$pagelog
->
getRelativeRevision
(
$rev
,
$dir5
,
$media
=
false
);
$this
->
assertEquals
(
$revexpected5
,
$revfound5
);
}
/**
* request after recentest version in changelog
*/
function
test_requestrecentestlogline_next
()
{
$rev
=
1374261194
;
$dir
=
1
;
$revexpected
=
false
;
$pagelog
=
new
PageRevisionLog
(
$this
->
pageid
,
$chunk_size
=
8192
);
$revfound
=
$pagelog
->
getRelativeRevision
(
$rev
,
$dir
,
$media
=
false
);
$this
->
assertEquals
(
$revexpected
,
$revfound
);
}
/**
* request after recentest version in changelog, with chuncked reading
*/
function
test_requestrecentestlogline_next_chuncked
()
{
$rev
=
1374261194
;
$dir
=
1
;
$revexpected
=
false
;
$pagelog
=
new
PageRevisionLog
(
$this
->
pageid
,
$chunk_size
=
512
);
$revfound
=
$pagelog
->
getRelativeRevision
(
$rev
,
$dir
,
$media
=
false
);
$this
->
assertEquals
(
$revexpected
,
$revfound
);
}
/**
* request before current version
*/
function
test_requestrecentestlogline_prev
()
{
$rev
=
1374261194
;
$dir
=
-
1
;
$revexpected
=
1371579614
;
$pagelog
=
new
PageRevisionLog
(
$this
->
pageid
,
$chunk_size
=
8192
);
$revfound
=
$pagelog
->
getRelativeRevision
(
$rev
,
$dir
,
$media
=
false
);
$this
->
assertEquals
(
$revexpected
,
$revfound
);
}
/**
* request before current version, with chuncked reading
*/
function
test_requestrecentestlogline_prev_chuncked
()
{
$rev
=
1374261194
;
$dir
=
-
1
;
$revexpected
=
1371579614
;
$pagelog
=
new
PageRevisionLog
(
$this
->
pageid
,
$chunk_size
=
512
);
$revfound
=
$pagelog
->
getRelativeRevision
(
$rev
,
$dir
,
$media
=
false
);
$this
->
assertEquals
(
$revexpected
,
$revfound
);
}
/**
* Request negative revision
* looks in positive direction, so it catches the oldest revision
*/
function
test_negativerev_posdir
()
{
$rev
=
-
10
;
$dir
=
1
;
$revexpected
=
1360110636
;
$pagelog
=
new
PageRevisionLog
(
$this
->
pageid
,
$chunk_size
=
8192
);
$revfound
=
$pagelog
->
getRelativeRevision
(
$rev
,
$dir
,
$media
=
false
);
$this
->
assertEquals
(
$revexpected
,
$revfound
);
}
/**
* Request negative revision
* looks in negative direction, but there is nothing
*/
function
test_negativerev_negdir
()
{
$rev
=
-
10
;
$dir
=
-
1
;
$revexpected
=
false
;
$pagelog
=
new
PageRevisionLog
(
$this
->
pageid
,
$chunk_size
=
8192
);
$revfound
=
$pagelog
->
getRelativeRevision
(
$rev
,
$dir
,
$media
=
false
);
$this
->
assertEquals
(
$revexpected
,
$revfound
);
}
/**
* Start at non existing revision somewhere between existing revisions
*/
function
test_startatnotexistingrev_next
()
{
$rev
=
1362525890
;
$dir
=
1
;
$revexpected
=
1362525899
;
$pagelog
=
new
PageRevisionLog
(
$this
->
pageid
,
$chunk_size
=
8192
);
$revfound
=
$pagelog
->
getRelativeRevision
(
$rev
,
$dir
,
$media
=
false
);
$this
->
assertEquals
(
$revexpected
,
$revfound
);
}
/**
* Start at non existing revision somewhere between existing revisions
*/
function
test_startatnotexistingrev_prev
()
{
$rev
=
1362525890
;
$dir
=
-
1
;
$revexpected
=
1362525359
;
$pagelog
=
new
PageRevisionLog
(
$this
->
pageid
,
$chunk_size
=
8192
);
$revfound
=
$pagelog
->
getRelativeRevision
(
$rev
,
$dir
,
$media
=
false
);
$this
->
assertEquals
(
$revexpected
,
$revfound
);
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment