Skip to content

Commit 5ce92ef

Browse files
committed
Tests: Added Travis.ci support, various test fixes
- Removed HHVM and Nightly from Travis.ci - Added runAll.php as Travis.ci script - Added Tests - API_AddField - API_DeleteField - API_AddRecord - API_DeleteRecord - API_Authenticate - API_DoQuery - API_DoQueryCount - API_GetSchema - API_GetUserRole - Fixed runAll.php to work with Travis.ci and CL
1 parent 5673e89 commit 5ce92ef

9 files changed

+180
-7
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ php:
44
- 5.4
55
- 5.5
66
- 5.6
7-
- hhvm
8-
- nightly
7+
8+
script: php tests/runAll.php
99

1010
sudo: false

tests/API_AddField.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
<?php
2+
3+
/* Copyright 2015 Tristian Flanagan
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
$response = $qb->api('API_AddField', array(
19+
'dbid' => getenv('dbid'),
20+
'label' => 'Test Field',
21+
'type' => 'text'
22+
));
23+
24+
$qb->api('API_DeleteField', array(
25+
'dbid' => getenv('dbid'),
26+
'fid' => $response['fid']
27+
));
28+
29+
?>

tests/API_AddRecord.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
/* Copyright 2015 Tristian Flanagan
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
$response = $qb->api('API_AddRecord', array(
19+
'dbid' => getenv('dbid')
20+
));
21+
22+
$qb->api('API_DeleteRecord', array(
23+
'dbid' => getenv('dbid'),
24+
'rid' => $response['rid']
25+
));
26+
27+
?>

tests/API_Authenticate.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
* limitations under the License.
1616
*/
1717

18-
$response = $qb->api('API_Authenticate', array(
19-
'username' => '',
20-
'password' => ''
18+
$qb->api('API_Authenticate', array(
19+
'username' => getenv('username'),
20+
'password' => getenv('password')
2121
));
2222

23-
?>
23+
?>

tests/API_DoQuery.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
/* Copyright 2015 Tristian Flanagan
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
$qb->api('API_DoQuery', array(
19+
'dbid' => getenv('dbid'),
20+
'query' => "{'3'.XEX.''}"
21+
));
22+
23+
?>

tests/API_DoQueryCount.php

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
3+
/* Copyright 2015 Tristian Flanagan
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
$qb->api('API_DoQueryCount', array(
19+
'dbid' => getenv('dbid'),
20+
'query' => "{'3'.XEX.''}"
21+
));
22+
23+
?>

tests/API_GetSchema.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
/* Copyright 2015 Tristian Flanagan
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
$qb->api('API_GetSchema', array(
19+
'dbid' => getenv('dbid')
20+
));
21+
22+
?>

tests/API_GetUserRole.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
/* Copyright 2015 Tristian Flanagan
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
$qb->api('API_GetUserInfo');
19+
20+
?>

tests/runAll.php

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,36 @@
3131
$stderr = fopen('php://stderr', 'w+');
3232
$error = false;
3333

34-
$qb = new QuickBase();
34+
if(!getenv('TRAVIS')){
35+
if(count($argv) !== 6){
36+
echo implode("\n", array(
37+
'ERROR: Incorrect CL Test Usage.',
38+
'',
39+
"\t$ php tests\\runAll.php <realm> <username> <password> <appToken> <dbid>",
40+
'',
41+
"\trealm: www",
42+
"\tusername: foo@bar.com",
43+
"\tpassword: foobar",
44+
"\tappToken: dn23iuct88jvbcx7v9vttp2an6",
45+
"\tdbid: bkcamms4m",
46+
"\t (must be a table dbid, not an application dbid)",
47+
''
48+
));
49+
50+
exit(1);
51+
}
52+
53+
putenv('realm='.$argv[1]);
54+
putenv('username='.$argv[2]);
55+
putenv('password='.$argv[3]);
56+
putenv('appToken='.$argv[4]);
57+
putenv('dbid='.$argv[5]);
58+
}
59+
60+
$qb = new QuickBase(array(
61+
'realm' => getenv('realm'),
62+
'appToken' => getenv('appToken')
63+
));
3564

3665
/* Main */
3766
$files = array_diff(scandir(__DIR__), array(

0 commit comments

Comments
 (0)