forked from RRZE-Webteam/fau-cris
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cris-generic-tests.php
147 lines (119 loc) · 3.99 KB
/
cris-generic-tests.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<?php
/*
* Vergleich zwischen generischem Zugang vs. bisherigem
*/
require_once('class_Publikationen.php');
/*
* helper methods for testing outside wordpress environment
*/
if (!function_exists("__")) {
function __($text, $x=null) {
return $text;
}
}
if (!function_exists("get_option")) {
function get_option($x) {
return array(
"cris_org_nr" => 142528,
"cris_pub_order" => array(''),
);
}
}
if (!function_exists("get_locale")) {
function get_locale() {
return "de_DE";
}
}
// style
$quotation = '';
// single publication
$param1 = 'publication';
$param2 = 36722;
$liste = new Publikationen($param1, $param2);
$output1 = $liste->singlePub($quotation);
$liste = new Publikationen($param1, $param2);
$output2 = $liste->singlePub($quotation);
assert($output1 === $output2, "single publication");
// person's list
$param1 = 'person';
$param2 = 162826;
// no filters
$year = '';
$start = '';
$pubtype = '';
$liste = new Publikationen($param1, $param2);
$output1 = $liste->pubNachJahr($year, $start, $pubtype, $quotation);
$liste = new Publikationen($param1, $param2);
$output2 = $liste->pubNachJahr($year, $start, $pubtype, $quotation);
assert($output1 === $output2, "person's list");
// select year
$year = '2015';
$start = '';
$pubtype = '';
$liste = new Publikationen($param1, $param2);
$output1 = $liste->pubNachJahr($year, $start, $pubtype, $quotation);
$liste = new Publikationen($param1, $param2);
$output2 = $liste->pubNachJahr($year, $start, $pubtype, $quotation);
assert($output1 === $output2, "person's list for one year");
// define start year
$year = '';
$start = '2013';
$pubtype = '';
$liste = new Publikationen($param1, $param2);
$output1 = $liste->pubNachJahr($year, $start, $pubtype, $quotation);
$liste = new Publikationen($param1, $param2);
$output2 = $liste->pubNachJahr($year, $start, $pubtype, $quotation);
assert($output1 === $output2, "person's list start year");
// restrict publication type
$year = '';
$start = '';
$pubtype = 'zeitschriftenartikel';
$liste = new Publikationen($param1, $param2);
$output1 = $liste->pubNachJahr($year, $start, $pubtype, $quotation);
$liste = new Publikationen($param1, $param2);
$output2 = $liste->pubNachJahr($year, $start, $pubtype, $quotation);
assert($output1 === $output2, "person's list of defined type");
// organisation's list
// note: Tests will fail if publications are additionally related to
// organisation since old method doesn't fetch these.
$param1 = "orga";
$param2 = 142528;
$year = '';
$start = '';
$pubtype = '';
// no settings at all (fallback to config)
$liste = new Publikationen();
$output1 = $liste->pubNachJahr();
$liste = new Publikationen();
$output2 = $liste->pubNachJahr();
assert($output1 === $output2, "configuration settings");
// using settings
$liste = new Publikationen($param1, $param2);
$output1 = $liste->pubNachJahr($year, $start, $pubtype, $quotation);
$liste = new Publikationen($param1, $param2);
$output2 = $liste->pubNachJahr($year, $start, $pubtype, $quotation);
assert($output1 === $output2, "organisations's list");
// ordering by type
// since the sub order inside each year is undefined assertion often fails
// so for testing we use a person with only a few publications...
$param1 = "person";
$param2 = '1008228';
$year = '';
$start = '2008';
$pubtype = '';
$liste = new Publikationen($param1, $param2);
$output1 = $liste->pubNachTyp($year, $start, $pubtype, $quotation);
$liste = new Publikationen($param1, $param2);
$output2 = $liste->pubNachTyp($year, $start, $pubtype, $quotation);
assert($output1 === $output2, "person's list by type");
// more filters
$year = '';
$start = '';
$pubtype = 'zeitschriftenartikel';
$liste = new Publikationen($param1, $param2);
$output1 = $liste->pubNachTyp($year, $start, $pubtype, $quotation);
$liste = new Publikationen($param1, $param2);
$output2 = $liste->pubNachTyp($year, $start, $pubtype, $quotation);
assert($output1 === $output2, "person's list by type, filtered by type");
//print_r($output1);
//print_r($output2);