-
Notifications
You must be signed in to change notification settings - Fork 625
Expand file tree
/
Copy pathTestlinkXMLRPCServerTest.php
More file actions
996 lines (801 loc) · 35.4 KB
/
Copy pathTestlinkXMLRPCServerTest.php
File metadata and controls
996 lines (801 loc) · 35.4 KB
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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
<?php
/*
* TestLink Open Source Project - http://testlink.sourceforge.net/
* $Id: TestlinkXMLRPCServerTest.php,v 1.5 2009/01/23 20:28:27 asielb Exp $
*
* These tests require phpunit: http://www.phpunit.de/
*/
/**
* @author Asiel Brumfield <asielb@users.sourceforge.net>
* @package TestlinkAPI
* @link http://testlink.org/api/
*/
require_once dirname(__FILE__) . '/../../../third_party/xml-rpc/class-IXR.php';
require_once dirname(__FILE__) . '/../APIErrors.php';
require_once dirname(__FILE__) . '/TestlinkXMLRPCServerTestData.php';
require_once 'PHPUnit/Framework.php';
require_once 'PHPUnit/TextUI/TestRunner.php';
/**
* Unit tests for the Testlink API
*
* @author Asiel Brumfield <asielb@users.sourceforge.net>
* @since Class available since Release 1.8.0
* @version 1.0
*/
class TestlinkXMLRPCServerTest extends PHPUnit_Framework_TestCase
{
protected $client;
protected $SERVER_URL = "http://localhost/testlink_trunk/lib/api/xmlrpc.php";
function setUp()
{
// This is the path to the server and will vary from machine to machine
$this->client = $client = new IXR_Client($this->SERVER_URL);
// run IXR_Client in debug mode showing verbose output
$this->client->debug = true;
//$this->setupTestMode();
}
private function setupTestMode()
{
$data["testmode"] = true;
if(!$this->client->query('tl.setTestMode', $data)) {
echo "\n" . $this->getName() . " >> problem setting testMode - " . $this->client->getErrorCode() .
$this->client->getErrorMessage();
}
$this->assertEquals(true, $this->client->getResponse());
}
public static function suite()
{
$suite = new PHPUnit_Framework_TestSuite;
// Run specific individual tests
$suite->addTest(new TestlinkXMLRPCServerTest('testSayHello'));
$suite->addTest(new TestlinkXMLRPCServerTest('testReportTCResultWithInvalidDevKey'));
$suite->addTest(new TestlinkXMLRPCServerTest('testReportTCResultWithoutDevKey'));
$suite->addTest(new TestlinkXMLRPCServerTest('testReportTCResultWithEmptyDevKey'));
$suite->addTest(new TestlinkXMLRPCServerTest('testReportTCResultWithoutTCID'));
$suite->addTest(new TestlinkXMLRPCServerTest('testReportTCResultWithInvalidTCID'));
$suite->addTest(new TestlinkXMLRPCServerTest('testReportTCResultWithoutNonIntTCID'));
$suite->addTest(new TestlinkXMLRPCServerTest('testReportTCResultWithoutTPID'));
$suite->addTest(new TestlinkXMLRPCServerTest('testReportTCResultRequestWithoutStatus'));
$suite->addTest(new TestlinkXMLRPCServerTest('testReportTCResultRequestWithInvalidStatus'));
$suite->addTest(new TestlinkXMLRPCServerTest('testReportTCResultRequestWithBlockedStatus'));
$suite->addTest(new TestlinkXMLRPCServerTest('testReportTCResultRequestWithPassedStatus'));
$suite->addTest(new TestlinkXMLRPCServerTest('testReportTCResultValidRequest'));
$suite->addTest(new TestlinkXMLRPCServerTest('testReportTCResultWithNoParams'));
$suite->addTest(new TestlinkXMLRPCServerTest('testReportTCResultRequestWithValidBuildID'));
$suite->addTest(new TestlinkXMLRPCServerTest('testReportTCResultNotGuessingBuildID'));
$suite->addTest(new TestlinkXMLRPCServerTest('testReportTCResultWithNotes'));
$suite->addTest(new TestlinkXMLRPCServerTest('testCreateBuildWithoutNotes'));
$suite->addTest(new TestlinkXMLRPCServerTest('testCreateBuildWithNotes'));
$suite->addTest(new TestlinkXMLRPCServerTest('testCreateBuildWithInvalidTPID'));
$suite->addTest(new TestlinkXMLRPCServerTest('testValidDevKeyWorks'));
$suite->addTest(new TestlinkXMLRPCServerTest('testGetProjects'));
$suite->addTest(new TestlinkXMLRPCServerTest('testReportTCResultRequestWithFailedStatus'));
$suite->addTest(new TestlinkXMLRPCServerTest('testCreateBuildWithInsufficientRights'));
$suite->addTest(new TestlinkXMLRPCServerTest('testGetProjectTestPlans'));
$suite->addTest(new TestlinkXMLRPCServerTest('testGetTestCasesForTestSuite'));
$suite->addTest(new TestlinkXMLRPCServerTest('testGetTestCasesForTestSuiteDeepFalse'));
$suite->addTest(new TestlinkXMLRPCServerTest('testGetTestCaseIDByName'));
$suite->addTest(new TestlinkXMLRPCServerTest('testGetTestCaseIDByNameWithInvalidName'));
$suite->addTest(new TestlinkXMLRPCServerTest('testRepeat'));
$suite->addTest(new TestlinkXMLRPCServerTest('testAbout'));
$suite->addTest(new TestlinkXMLRPCServerTest('testNonExistantMethod'));
//NEW TESTS
$suite->addTest(new TestlinkXMLRPCServerTest('testCreateBuildWithInsufficientRights'));
$suite->addTest(new TestlinkXMLRPCServerTest('testReportTCResultWithInsufficientRights'));
$suite->addTest(new TestlinkXMLRPCServerTest('testGetTestCasesForTestSuiteWithInsufficientRights'));
$suite->addTest(new TestlinkXMLRPCServerTest('testGetTestCaseIDByNameWithInsufficientRights'));
$suite->addTest(new TestlinkXMLRPCServerTest('testGetLastTestResult'));
//INCOMPLETE
//THERE IS NO RIGHTS ASSOCIATED WITH THIS YET - $suite->addTest(new TestlinkXMLRPCServerTest('testGetProjectsWithInsufficientRights'));
//$suite->addTest(new TestlinkXMLRPCServerTest('testReportTCResultWithInvalidTCIDAndTPIDCombo'));
//$suite->addTest(new TestlinkXMLRPCServerTest('testReportTCResultWithTimestamp'));
//$suite->addTest(new TestlinkXMLRPCServerTest('testGetProjectTestPlansWithInvalidID'));
//$suite->addTest(new TestlinkXMLRPCServerTest('testGetProjectTestPlansWithoutTestProjectID'));
//$suite->addTest(new TestlinkXMLRPCServerTest('testGetTestSuitesForTestPlan'));
//$suite->addTest(new TestlinkXMLRPCServerTest('testGetTestSuitesForTestPlanWithoutTestPlanID'));
//$suite->addTest(new TestlinkXMLRPCServerTest('testGetTestCasesForTestSuiteWithInvalidSuiteID'));
//$suite->addTest(new TestlinkXMLRPCServerTest('testGetTestCasesForTestSuiteWithoutSuiteID'));
// run all the tests
//$suite->addTestSuite('TestlinkXMLRPCServerTest');
return $suite;
}
function testSayHello()
{
if (!$this->client->query('tl.sayHello')) {
die('big time problem ' . $this->client->getErrorCode() . ' : ' .
$this->client->getErrorMessage());
}
$this->assertEquals('Hello!', $this->client->getResponse());
}
function testReportTCResultWithInvalidDevKey()
{
$data = array();
$data["devKey"] = "wrongKey";
if(!$this->client->query('tl.reportTCResult', $data)) {
echo "\n" . $this->getName() . " >> something went really wrong - " . $this->client->getErrorCode() .
$this->client->getErrorMessage();
}
// build up an array contining the error that should come back
$expectedResult = array();
$expectedResult[0]["code"] = constant("INVALID_AUTH");
$expectedResult[0]["message"] = constant("INVALID_AUTH_STR");
$this->assertEquals($expectedResult, $this->client->getResponse());
}
function testReportTCResultWithInsufficientRights()
{
$data = array();
$data["devKey"] = TestlinkXMLRPCServerTestData::noRightsDevKey;
$data["testcaseid"] = TestlinkXMLRPCServerTestData::testTCID;
$data["testplanid"] = TestlinkXMLRPCServerTestData::testTPID;
$data["buildid"] = TestlinkXMLRPCServerTestData::testBuildID;
// set the status to blocked
$data["status"] = "b";
if(!$this->client->query('tl.reportTCResult', $data)) {
echo "\n" . $this->getName() . " >> something went really wrong - " . $this->client->getErrorCode() .
$this->client->getErrorMessage();
}
$expectedResult = array();
$expectedResult[0]["code"] = constant("INSUFFICIENT_RIGHTS");
$expectedResult[0]["message"] = constant("INSUFFICIENT_RIGHTS_STR");
$result = $this->client->getResponse();
$this->assertEquals($expectedResult, $result);
}
function testReportTCResultWithoutDevKey()
{
$data = array();
if(!$this->client->query('tl.reportTCResult', $data)) {
echo "\n" . $this->getName() . " >> something went really wrong - " . $this->client->getErrorCode() .
$this->client->getErrorMessage();
}
// build up an array contining the error that should come back
$expectedResult = array();
$expectedResult[0]["code"] = constant("NO_DEV_KEY");
$expectedResult[0]["message"] = constant("NO_DEV_KEY_STR");
$this->assertEquals($expectedResult, $this->client->getResponse());
}
function testReportTCResultWithEmptyDevKey()
{
$data = array();
$data["devKey"] = "";
if(!$this->client->query('tl.reportTCResult', $data)) {
echo "\n" . $this->getName() . " >> something went really wrong - " . $this->client->getErrorCode() .
$this->client->getErrorMessage();
}
// build up an array contining the error that should come back
$expectedResult = array();
$expectedResult[0]["code"] = constant("INVALID_AUTH");
$expectedResult[0]["message"] = constant("INVALID_AUTH_STR");
$this->assertEquals($expectedResult, $this->client->getResponse());
}
function testReportTCResultWithoutTCID()
{
$data = array();
$data["devKey"] = TestlinkXMLRPCServerTestData::testDevKey;
if(!$this->client->query('tl.reportTCResult', $data)) {
echo "\n" . $this->getName() . " >> something went really wrong - " . $this->client->getErrorCode() .
$this->client->getErrorMessage();
}
// build up an array contining the error that should come back
$expectedResult = array();
$expectedResult[0]["code"] = constant("NO_TCASEID");
$expectedResult[0]["message"] = constant("NO_TCASEID_STR");
var_dump($expectedResult);
var_dump($this->client->getResponse());
$this->assertEquals($expectedResult, $this->client->getResponse());
}
function testReportTCResultWithInvalidTCID()
{
$data = array();
$data["devKey"] = TestlinkXMLRPCServerTestData::testDevKey;
$data["testplanid"] = TestlinkXMLRPCServerTestData::testTPID;
$data["status"] = "f";
$data["testcaseid"] = -100; // shouldn't have a negative number for TCID in db
if(!$this->client->query('tl.reportTCResult', $data)) {
echo "\n" . $this->getName() . " >> something went really wrong - " . $this->client->getErrorCode() .
$this->client->getErrorMessage();
}
// build up an array contining the error that should come back
$expectedResult = array();
$expectedResult[0]["code"] = constant("INVALID_TCASEID");
$expectedResult[0]["message"] = constant("INVALID_TCASEID_STR");
$result = $this->client->getResponse();
//print_r($result);
//print_r($expectedResult);
$this->assertEquals($expectedResult, $result);
}
function testReportTCResultWithoutNonIntTCID()
{
$data = array();
$data["devKey"] = TestlinkXMLRPCServerTestData::testDevKey;
$data["testcaseid"] = "notAnInt";
if(!$this->client->query('tl.reportTCResult', $data)) {
echo "\n" . $this->getName() . " >> something went really wrong - " . $this->client->getErrorCode() .
$this->client->getErrorMessage();
}
// build up an array containing the errors that should come back
$expectedResult = array();
$expectedResult[0]["code"] = constant("TCASEID_NOT_INTEGER");
$expectedResult[0]["message"] = constant("TCASEID_NOT_INTEGER_STR");
$expectedResult[1]["code"] = constant("INVALID_TCASEID");
$expectedResult[1]["message"] = constant("INVALID_TCASEID_STR");
$result = $this->client->getResponse();
$this->assertEquals($expectedResult, $this->client->getResponse());
}
// TODO: Implement
function testReportTCResultWithoutTPID()
{
$data = array();
$data["devKey"] = TestlinkXMLRPCServerTestData::testDevKey;
// dependant on data in the sql file
$data["testcaseid"] = TestlinkXMLRPCServerTestData::testTCID;
if(!$this->client->query('tl.reportTCResult', $data)) {
echo "\n" . $this->getName() . " >> something went really wrong - " . $this->client->getErrorCode() .
$this->client->getErrorMessage();
}
// build up an array contining the error that should come back
$expectedResult = array();
$expectedResult[0]["code"] = constant("NO_TPLANID");
$expectedResult[0]["message"] = constant("NO_TPLANID_STR");
$response = $this->client->getResponse();
$this->assertEquals($expectedResult, $response);
}
function testReportTCResultRequestWithoutStatus()
{
$data = array();
$data["devKey"] = TestlinkXMLRPCServerTestData::testDevKey;
$data["testcaseid"] = TestlinkXMLRPCServerTestData::testTCID;
$data["testplanid"] = TestlinkXMLRPCServerTestData::testTPID;
$data["buildid"] = TestlinkXMLRPCServerTestData::testBuildID;
if(!$this->client->query('tl.reportTCResult', $data)) {
echo "\n" . $this->getName() . " >> something went really wrong - " . $this->client->getErrorCode() .
$this->client->getErrorMessage();
}
// build up an array contining the error that should come back
$expectedResult = array();
$expectedResult[0]["code"] = constant("NO_STATUS");
$expectedResult[0]["message"] = constant("NO_STATUS_STR");
$response = $this->client->getResponse();
$this->assertEquals($expectedResult, $response);
}
function testReportTCResultRequestWithInvalidStatus()
{
$data = array();
$data["devKey"] = TestlinkXMLRPCServerTestData::testDevKey;
$data["testcaseid"] = TestlinkXMLRPCServerTestData::testTCID;
$data["testplanid"] = TestlinkXMLRPCServerTestData::testTPID;
$data["buildid"] = TestlinkXMLRPCServerTestData::testBuildID;
$data["status"] = "invalidStatus";
if(!$this->client->query('tl.reportTCResult', $data)) {
echo "\n" . $this->getName() . " >> something went really wrong - " . $this->client->getErrorCode() .
$this->client->getErrorMessage();
}
// build up an array contining the error that should come back
$expectedResult = array();
$expectedResult[0]["code"] = constant("INVALID_STATUS");
$expectedResult[0]["message"] = constant("INVALID_STATUS_STR");
$response = $this->client->getResponse();
$this->assertEquals($expectedResult, $response);
}
function testReportTCResultRequestWithBlockedStatus()
{
$data = array();
$data["devKey"] = TestlinkXMLRPCServerTestData::testDevKey;
$data["testcaseid"] = TestlinkXMLRPCServerTestData::testTCID;
$data["testplanid"] = TestlinkXMLRPCServerTestData::testTPID;
$data["buildid"] = TestlinkXMLRPCServerTestData::testBuildID;
// set the status to blocked
$data["status"] = "b";
if(!$this->client->query('tl.reportTCResult', $data)) {
echo "\n" . $this->getName() . " >> something went really wrong - " . $this->client->getErrorCode() .
$this->client->getErrorMessage();
}
$response = $this->client->getResponse();
var_dump($response);
// Just check the size is good since we don't know the insert id
$this->assertEquals(3, sizeof((array)$response[0]));
}
function testReportTCResultRequestWithPassedStatus()
{
$data = array();
$data["devKey"] = TestlinkXMLRPCServerTestData::testDevKey;
$data["testcaseid"] = TestlinkXMLRPCServerTestData::testTCID;
$data["testplanid"] = TestlinkXMLRPCServerTestData::testTPID;
$data["buildid"] = TestlinkXMLRPCServerTestData::testBuildID;
// set the status to passed
$data["status"] = "p";
if(!$this->client->query('tl.reportTCResult', $data)) {
echo "\n" . $this->getName() . " >> something went really wrong - " . $this->client->getErrorCode() .
$this->client->getErrorMessage();
}
$response = $this->client->getResponse();
// Just check the size is good since we don't know the insert id
$this->assertEquals(3, sizeof((array)$response[0]));
}
function testReportTCResultRequestWithFailedStatus()
{
$data = array();
$data["devKey"] = TestlinkXMLRPCServerTestData::testDevKey;
$data["testcaseid"] = TestlinkXMLRPCServerTestData::testTCID;
$data["testplanid"] = TestlinkXMLRPCServerTestData::testTPID;
$data["buildid"] = TestlinkXMLRPCServerTestData::testBuildID;
// set the status to failed
$data["status"] = "f";
if(!$this->client->query('tl.reportTCResult', $data)) {
echo "\n" . $this->getName() . " >> something went really wrong - " . $this->client->getErrorCode() .
$this->client->getErrorMessage();
}
$response = $this->client->getResponse();
// Just check the size is good since we don't know the insert id
$this->assertEquals(3, sizeof((array)$response[0]));
}
function testReportTCResultWithNoParams()
{
$data = array();
if(!$this->client->query('tl.reportTCResult', $data)) {
echo "\n" . $this->getName() . " >> something went really wrong - " . $this->client->getErrorCode() .
$this->client->getErrorMessage();
}
$expectedResult = array();
$expectedResult[0]["code"] = constant("NO_DEV_KEY");
$expectedResult[0]["message"] = constant("NO_DEV_KEY_STR");
$this->assertEquals($expectedResult, $this->client->getResponse());
}
// TODO: Implement
function testReportTCResultWithInvalidTCIDAndTPIDCombo()
{
// TCID_NOT_IN_TPID, TCID_NOT_IN_TPID_STR
throw new PHPUnit_Framework_IncompleteTestError('This test is not yet implemented');
}
function testReportTCResultValidRequest()
{
$data = array();
$data["devKey"] = TestlinkXMLRPCServerTestData::testDevKey;
$data["testcaseid"] = TestlinkXMLRPCServerTestData::testTCID;
$data["testplanid"] = TestlinkXMLRPCServerTestData::testTPID;
$data["buildid"] = TestlinkXMLRPCServerTestData::testBuildID;
$data["status"] = "p";
if(!$this->client->query('tl.reportTCResult', $data)) {
echo "\n" . $this->getName() . " >> something went really wrong - " . $this->client->getErrorCode() .
$this->client->getErrorMessage();
}
$response = $this->client->getResponse();
// Just check the size is good since we don't know the insert id
$this->assertEquals(3, sizeof((array)$response[0]));
}
function testGetLastTestResult()
{
//Setup a Known Response by reporting a block
$data = array();
$data["devKey"] = TestlinkXMLRPCServerTestData::testDevKey;
$data["testcaseid"] = TestlinkXMLRPCServerTestData::testTCID;
$data["testplanid"] = TestlinkXMLRPCServerTestData::testTPID;
$data["buildid"] = TestlinkXMLRPCServerTestData::testBuildID;
$data["status"] = "b";
if(!$this->client->query('tl.reportTCResult', $data)) {
echo "\n" . $this->getName() . " >> something went really wrong - " . $this->client->getErrorCode() .
$this->client->getErrorMessage();
}
$response = $this->client->getResponse();
//Now Building our get last test result
$data = array();
$data["devKey"] = TestlinkXMLRPCServerTestData::testDevKey;
$data["testcaseid"] = TestlinkXMLRPCServerTestData::testTCID;
$data["testplanid"] = TestlinkXMLRPCServerTestData::testTPID;
if(!$this->client->query('tl.getLastTestResult', $data)) {
echo "\n" . $this->getName() . " >> something went really wrong - " . $this->client->getErrorCode() .
$this->client->getErrorMessage();
}
$response = $this->client->getResponse();
// Just check the size is good since we don't know the insert id
print_r($response);
$this->assertEquals(9, sizeof((array)$response[0]));
$this->assertEquals('b', $response[0]['status']);
}
function testReportTCResultRequestWithValidBuildID()
{
$data = array();
$data["devKey"] = TestlinkXMLRPCServerTestData::testDevKey;
$data["testcaseid"] = TestlinkXMLRPCServerTestData::testTCID;
$data["testplanid"] = TestlinkXMLRPCServerTestData::testTPID;
$data["buildid"] = TestlinkXMLRPCServerTestData::testBuildID;
$data["guess"] = false;
$data["status"] = "f";
if(!$this->client->query('tl.reportTCResult', $data)) {
echo "\n" . $this->getName() . " >> something went really wrong - " . $this->client->getErrorCode() .
$this->client->getErrorMessage();
}
//$expectedResult[0]["message"] = constant("GENERAL_SUCCESS_STR");
//$expectedResult[0]["status"] = true;
$response = $this->client->getResponse();
// Just check the size is good since we don't know the insert id
$this->assertEquals(3, sizeof((array)$response[0]));
}
function testReportTCResultNotGuessingBuildID()
{
$data = array();
$data["devKey"] = TestlinkXMLRPCServerTestData::testDevKey;
$data["testcaseid"] = TestlinkXMLRPCServerTestData::testTCID;
$data["testplanid"] = TestlinkXMLRPCServerTestData::testTPID;
// don't allow guessing the build id
$data["guess"] = false;
if(!$this->client->query('tl.reportTCResult', $data)) {
echo "\n" . $this->getName() . " >> something went really wrong - " . $this->client->getErrorCode() .
$this->client->getErrorMessage();
}
// build up an array contining the error that should come back
$expectedResult = array();
$expectedResult[0]["code"] = constant("BUILDID_NOGUESS");
$expectedResult[0]["message"] = constant("BUILDID_NOGUESS_STR");
$expectedResult[1]["code"] = constant("NO_BUILDID");
$expectedResult[1]["message"] = constant("NO_BUILDID_STR");
$response = $this->client->getResponse();
$this->assertEquals($expectedResult, $response);
}
function testReportTCResultWithTimestamp()
{
throw new PHPUnit_Framework_IncompleteTestError('This test is not yet implemented');
}
function testReportTCResultWithNotes()
{
$data = array();
$data["devKey"] = TestlinkXMLRPCServerTestData::testDevKey;
$data["testcaseid"] = TestlinkXMLRPCServerTestData::testTCID;
$data["testplanid"] = TestlinkXMLRPCServerTestData::testTPID;
$data["status"] = "p";
$data["buildid"] = TestlinkXMLRPCServerTestData::testBuildID;
$data["notes"] = "this is a note about the test";
if(!$this->client->query('tl.reportTCResult', $data)) {
echo "\n" . $this->getName() . " >> something went really wrong - " . $this->client->getErrorCode() .
$this->client->getErrorMessage();
}
$response = $this->client->getResponse();
// Just check the size is good since we don't know the insert id
var_dump($response);
$this->assertEquals(3, sizeof((array)$response[0]));
}
function testCreateBuildWithInsufficientRights()
{
$data = array();
$data["devKey"] = TestlinkXMLRPCServerTestData::noRightsDevKey;
$data["buildname"] = "Another test build from " . @strftime("%c");
$data["testplanid"] = TestlinkXMLRPCServerTestData::testTPID;
if(!$this->client->query('tl.createBuild', $data)) {
echo "\n" . $this->getName() . " >> something went really wrong - " . $this->client->getErrorCode() .
$this->client->getErrorMessage();
}
$expectedResult = array();
$expectedResult[0]["code"] = constant("INSUFFICIENT_RIGHTS");
$expectedResult[0]["message"] = constant("INSUFFICIENT_RIGHTS_STR");
$result = $this->client->getResponse();
$this->assertEquals($expectedResult, $result);
}
function testCreateBuildWithoutNotes()
{
$data = array();
$data["devKey"] = TestlinkXMLRPCServerTestData::testDevKey;
$data["buildname"] = "Another test build from " . @strftime("%c");
$data["testplanid"] = TestlinkXMLRPCServerTestData::testTPID;
if(!$this->client->query('tl.createBuild', $data)) {
echo "\n" . $this->getName() . " >> something went really wrong - " . $this->client->getErrorCode() .
$this->client->getErrorMessage();
}
$response = $this->client->getResponse();
var_dump($response);
$this->assertEquals(3, sizeof((array)$response[0]));
}
function testCreateBuildWithNotes()
{
$data = array();
$data["devKey"] = TestlinkXMLRPCServerTestData::testDevKey;
$data["buildname"] = "Another notes test build from " . @strftime("%c");
$data["testplanid"] = TestlinkXMLRPCServerTestData::testTPID;
$data["buildnotes"] = "Some notes from the build created at " . @strftime("%c");
if(!$this->client->query('tl.createBuild', $data)) {
echo "\n" . $this->getName() . " >> something went really wrong - " . $this->client->getErrorCode() .
$this->client->getErrorMessage();
}
$response = $this->client->getResponse();
$this->assertEquals(3, sizeof((array)$response[0]));
}
function testCreateBuildWithInvalidTPID()
{
$data = array();
$data["devKey"] = TestlinkXMLRPCServerTestData::testDevKey;
$data["buildname"] = "Another test build from " . @strftime("%c");
$data["testplanid"] = -1;
$data["buildnotes"] = "Some notes from the build created at " . @strftime("%c");
if(!$this->client->query('tl.createBuild', $data)) {
echo "\n" . $this->getName() . " >> something went really wrong - " . $this->client->getErrorCode() .
$this->client->getErrorMessage();
}
$expectedResult = array();
$expectedResult[0]["code"] = constant("INVALID_TPLANID");
$expectedResult[0]["message"] = sprintf(constant("INVALID_TPLANID_STR"), $data["testplanid"]);
$result = $this->client->getResponse();
//print_r($expectedResult);
//print_r($result);
$this->assertEquals($expectedResult, $result);
}
function testValidDevKeyWorks()
{
$data = array();
$data["devKey"] = TestlinkXMLRPCServerTestData::testDevKey;
if(!$this->client->query('tl.reportTCResult', $data)) {
echo "\n" . $this->getName() . " >> something went really wrong - " . $this->client->getErrorCode() .
$this->client->getErrorMessage();
}
// The response should not have any errors related to the devKey
$response = $this->client->getResponse();
$expectedResult = array();
$expectedResult[0]["code"] = constant("INVALID_AUTH");
$expectedResult[0]["message"] = constant("INVALID_AUTH_STR");
$this->assertNotEquals($expectedResult, $this->client->getResponse());
$expectedResult = array();
$expectedResult[0]["code"] = constant("NO_DEV_KEY");
$expectedResult[0]["message"] = constant("NO_DEV_KEY_STR");
$this->assertNotEquals($expectedResult, $this->client->getResponse());
}
function testGetProjects()
{
$data = array();
$data["devKey"] = TestlinkXMLRPCServerTestData::testDevKey;
if(!$this->client->query('tl.getProjects', $data)) {
echo "\n" . $this->getName() . " >> something went really wrong - " . $this->client->getErrorCode() .
$this->client->getErrorMessage();
}
$expectedResult = array();
$expectedResult[0]["id"] = "1";
$expectedResult[0]["notes"] = "<p>A project for testing</p>";
$expectedResult[0]["color"] = "";
$expectedResult[0]["active"] = "1";
$expectedResult[0]["option_reqs"] = "1";
$expectedResult[0]["option_priority"] = "1";
$expectedResult[0]["prefix"] = "";
$expectedResult[0]["tc_counter"] = "0";
$expectedResult[0]["option_automation"] = "0";
$expectedResult[0]["name"] = "Test Project";
$response = $this->client->getResponse();
var_dump($response);
var_dump($expectedResult);
$this->assertEquals($expectedResult, $response);
}
function testGetProjectsWithInsufficientRights()
{
$data = array();
$data["devKey"] = TestlinkXMLRPCServerTestData::noRightsDevKey;
if(!$this->client->query('tl.getProjects', $data)) {
echo "\n" . $this->getName() . " >> something went really wrong - " . $this->client->getErrorCode() .
$this->client->getErrorMessage();
}
$expectedResult = array();
$expectedResult[0]["code"] = constant("INSUFFICIENT_RIGHTS");
$expectedResult[0]["message"] = constant("INSUFFICIENT_RIGHTS_STR");
$result = $this->client->getResponse();
$this->assertEquals($expectedResult, $result);
}
function testGetProjectTestPlansWithInvalidID()
{
//TODO: Implement
throw new PHPUnit_Framework_IncompleteTestError('This test is not yet implemented');
}
function testGetProjectTestPlansWithoutTestProjectID()
{
//TODO: Implement
throw new PHPUnit_Framework_IncompleteTestError('This test is not yet implemented');
}
function testGetProjectTestPlans()
{
$data = array();
$data["devKey"] = TestlinkXMLRPCServerTestData::testDevKey;
$data["testprojectid"] = 1;
if(!$this->client->query('tl.getProjectTestPlans', $data)) {
echo "\n" . $this->getName() . " >> something went really wrong - " . $this->client->getErrorCode() .
$this->client->getErrorMessage();
}
$expectedResult = array();
$testplanID = 2;
$expectedResult[$testplanID]["id"] = $testplanID;
$expectedResult[$testplanID]["name"] = "A test plan for testing";
// characters like <p> are stripped
$expectedResult[$testplanID]["notes"] = "<p>A description of a test plan for testing</p>";
$expectedResult[$testplanID]["active"] = "1";
$expectedResult[$testplanID]["testproject_id"] = "1";
$expectedResult = array($expectedResult);
$response = $this->client->getResponse();
//print_r($expectedResult);
//print_r($response);
$this->assertEquals($expectedResult, $response);
}
function testGetTestSuitesForTestPlan()
{
//TODO: Implement
throw new PHPUnit_Framework_IncompleteTestError('This test is not yet implemented');
}
function testGetTestSuitesForTestPlanWithoutTestPlanID()
{
//TODO: Implement
throw new PHPUnit_Framework_IncompleteTestError('This test is not yet implemented');
}
function testGetTestCasesForTestSuite()
{
$data = array();
$data["devKey"] = TestlinkXMLRPCServerTestData::testDevKey;
$data["testsuiteid"] = 3;
if(!$this->client->query('tl.getTestCasesForTestSuite', $data)) {
echo "\n" . $this->getName() . " >> something went really wrong - " . $this->client->getErrorCode() .
$this->client->getErrorMessage();
}
$expectedResult = array();
$expectedResult[0]["id"] = 11;
$expectedResult[0]["name"] = "test case in child suite";
$expectedResult[0]["parent_id"] = 10;
$expectedResult[0]["node_type_id"] = 3;
$expectedResult[0]["node_order"] = 100;
$expectedResult[1]["id"] = 4;
$expectedResult[1]["name"] = "First test case version 3";
$expectedResult[1]["parent_id"] = 3;
$expectedResult[1]["node_type_id"] = 3;
$expectedResult[1]["node_order"] = 100;
$expectedResult[2]["id"] = 6;
$expectedResult[2]["name"] = "Another test case";
$expectedResult[2]["parent_id"] = 3;
$expectedResult[2]["node_type_id"] = 3;
$expectedResult[2]["node_order"] = 100;
$response = $this->client->getResponse();
$this->assertEquals($expectedResult, $response, "arrays do not match");
}
function testGetTestCasesForTestSuiteWithInsufficientRights()
{
$data = array();
$data["devKey"] = TestlinkXMLRPCServerTestData::noRightsDevKey;
$data["testsuiteid"] = 3;
if(!$this->client->query('tl.getTestCasesForTestSuite', $data)) {
echo "\n" . $this->getName() . " >> something went really wrong - " . $this->client->getErrorCode() .
$this->client->getErrorMessage();
}
$expectedResult = array();
$expectedResult[0]["code"] = constant("INSUFFICIENT_RIGHTS");
$expectedResult[0]["message"] = constant("INSUFFICIENT_RIGHTS_STR");
$result = $this->client->getResponse();
$this->assertEquals($expectedResult, $result);
}
function testGetTestCasesForTestSuiteDeepFalse()
{
$data = array();
$data["devKey"] = TestlinkXMLRPCServerTestData::testDevKey;
$data["testsuiteid"] = 3;
$data["deep"] = false;
if(!$this->client->query('tl.getTestCasesForTestSuite', $data)) {
echo "\n" . $this->getName() . " >> something went really wrong - " . $this->client->getErrorCode() .
$this->client->getErrorMessage();
}
$expectedResult = array();
$expectedResult[0]["id"] = 4;
$expectedResult[0]["name"] = "First test case version 3";
$expectedResult[0]["parent_id"] = 3;
$expectedResult[0]["node_type_id"] = 3;
$expectedResult[0]["node_order"] = 100;
$expectedResult[1]["id"] = 6;
$expectedResult[1]["name"] = "Another test case";
$expectedResult[1]["parent_id"] = 3;
$expectedResult[1]["node_type_id"] = 3;
$expectedResult[1]["node_order"] = 100;
$response = $this->client->getResponse();
//print_r($response);
$this->assertEquals($expectedResult, $response, "arrays do not match");
}
function testGetTestCasesForTestSuiteWithoutSuiteID()
{
$data = array();
$data["devKey"] = TestlinkXMLRPCServerTestData::testDevKey;
$data["testsuiteid"] = 3;
if(!$this->client->query('tl.getTestCasesForTestSuite', $data)) {
echo "\n" . $this->getName() . " >> something went really wrong - " . $this->client->getErrorCode() .
$this->client->getErrorMessage();
}
$response = $this->client->getResponse();
//print_r($response);
//TODO: Implement
throw new PHPUnit_Framework_IncompleteTestError('This test is not yet implemented');
}
function testGetTestCasesForTestSuiteWithInvalidSuiteID()
{
$data = array();
$data["devKey"] = TestlinkXMLRPCServerTestData::testDevKey;
$data["testsuiteid"] = 2000;
if(!$this->client->query('tl.getTestCasesForTestSuite', $data)) {
echo "\n" . $this->getName() . " >> something went really wrong - " . $this->client->getErrorCode() .
$this->client->getErrorMessage();
}
$response = $this->client->getResponse();
//print_r($response);
//TODO: Implement
throw new PHPUnit_Framework_IncompleteTestError('This test is not yet implemented');
}
function testGetTestCaseIDByName()
{
$tcName = "First test case version 3";
$data = array();
$data["devKey"] = TestlinkXMLRPCServerTestData::testDevKey;
$data["testcasename"] = $tcName;
if(!$this->client->query('tl.getTestCaseIDByName', $data)) {
echo "\n" . $this->getName() . " >> something went really wrong - " . $this->client->getErrorCode() .
$this->client->getErrorMessage();
}
$expectedResult = array();
$expectedResult[0]["id"] = TestlinkXMLRPCServerTestData::testTCID;
$expectedResult[0]["name"] = $tcName;
$expectedResult[0]["parent_id"] = "1";
$expectedResult[0]["tsuite_name"] = "Top Level Suite";
$expectedResult[0]["tc_external_id"] = "0";
$response = $this->client->getResponse();
//print_r($response);
//print_r($expectedResult);
$this->assertEquals($expectedResult, $response);
}
function testGetTestCaseIDByNameWithInsufficientRights()
{
$tcName = "First test case version 3";
$data = array();
$data["devKey"] = TestlinkXMLRPCServerTestData::noRightsDevKey;
$data["testcasename"] = $tcName;
if(!$this->client->query('tl.getTestCaseIDByName', $data)) {
echo "\n" . $this->getName() . " >> something went really wrong - " . $this->client->getErrorCode() .
$this->client->getErrorMessage();
}
$expectedResult = array();
$expectedResult[0]["code"] = constant("INSUFFICIENT_RIGHTS");
$expectedResult[0]["message"] = constant("INSUFFICIENT_RIGHTS_STR");
$result = $this->client->getResponse();
$this->assertEquals($expectedResult, $result);
}
function testGetTestCaseIDByNameWithInvalidName()
{
$tcName = "A Test case that does not exist";
$data = array();
$data["devKey"] = TestlinkXMLRPCServerTestData::testDevKey;
$data["testcasename"] = $tcName;
if(!$this->client->query('tl.getTestCaseIDByName', $data)) {
echo "\n" . $this->getName() . " >> something went really wrong - " . $this->client->getErrorCode() .
$this->client->getErrorMessage();
}
$expectedResult = array();
$expectedResult[0]["code"] = constant("NO_TESTCASE_BY_THIS_NAME");
$expectedResult[0]["message"] = "(getTestCaseIDByName) - " . constant("NO_TESTCASE_BY_THIS_NAME_STR");
$response = $this->client->getResponse();
//print_r($expectedResult);
//print_r($response);
$this->assertEquals($expectedResult, $response);
}
function testRepeat()
{
$data = array();
$data["str"] = "I like to talk to myself";
if(!$this->client->query('tl.repeat', $data))
{
echo "\n\n" . $this->getName() . "something went really wrong - " . $this->client->getErrorCode() .
$this->client->getErrorMessage();
}
$this->assertEquals("You said: " . $data["str"], $this->client->getResponse());
}
function testAbout()
{
if(!$this->client->query('tl.about', null))
{
echo "\n\n" . $this->getName() . "something went really wrong - " . $this->client->getErrorCode() .
$this->client->getErrorMessage();
}
else
{
echo "success!";
}
}
function testNonExistantMethod()
{
$this->assertFalse($this->client->query('tl.noSuchMethodExists'));
}
}
// this is only necessary if you want to run "php FileName.php"
// otherwise you can just run "phpunit FileName.php" and it should work
//PHPUnit_TextUI_TestRunner::run(TestlinkXMLRPCServerTest::suite());
?>