3 * Copyright (c) Xerox Corporation, Codendi Team, 2001-2009. All rights reserved
5 * This file is a part of Codendi.
7 * Codendi is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * Codendi is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with Codendi. If not, see <http://www.gnu.org/licenses/>.
21 require_once(dirname(__FILE__).'/../include/HudsonTestResult.class.php');
22 Mock::generatePartial(
24 'HudsonTestResultTestVersion',
25 array('_getXMLObject', 'getHudsonControler')
28 require_once(dirname(__FILE__).'/../include/hudson.class.php');
29 Mock::generate('hudson');
31 require_once 'common/language/BaseLanguage.class.php';
32 Mock::generate('BaseLanguage');
34 class HudsonTestResultTest extends UnitTestCase {
36 * Constructor of the test. Can be ommitted.
37 * Usefull to set the name of the test
39 function HudsonTestResultTest($name = 'HudsonTestResult test') {
40 $this->UnitTestCase($name);
44 $GLOBALS['Language'] = new MockBaseLanguage($this);
47 function testMalformedURL() {
48 $this->expectException('HudsonJobURLMalformedException');
50 $j = new HudsonJob("toto");
52 function testMissingSchemeURL() {
53 $this->expectException('HudsonJobURLMalformedException');
55 $j = new HudsonJob("code4:8080/hudson/jobs/Codendi");
57 function testMissingHostURL() {
58 $this->expectException('HudsonJobURLMalformedException');
60 $j = new HudsonJob("http://");
63 function testWrongXMLFile() {
65 <?xml version='1.0' standalone='yes'?>
71 $xmldom = new SimpleXMLElement($xmlstr);
73 $j = new HudsonJobTestVersion($this);
74 $j->setReturnValue('_getXMLObject', $xmldom);
80 function testSimpleJobTestResult() {
82 $test_result_file = dirname(__FILE__).'/resources/testReport.xml';
83 $xmldom = simplexml_load_file($test_result_file);
85 $j = new HudsonTestResultTestVersion($this);
86 $j->setReturnValue('_getXMLObject', $xmldom);
87 $mh = new Mockhudson($this);
88 $mh->setReturnValue('getIconsPath', '');
89 $j->setReturnValue('getHudsonControler', $mh);
90 $j->setReturnValue('getIconsPath', '');
92 $j->HudsonTestResult("http://myCIserver/jobs/myCIjob/lastBuild/testReport/");
94 $this->assertEqual($j->getFailCount(), 5);
95 $this->assertEqual($j->getPassCount(), 416);
96 $this->assertEqual($j->getSkipCount(), 3);
97 $this->assertEqual($j->getTotalCount(), 424);