3 * Copyright (C) 2012 Roland Mas
5 * This file is part of FusionForge.
7 * FusionForge is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published
9 * by the Free Software Foundation; either version 2 of the License,
10 * or (at your option) any later version.
12 * FusionForge is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
17 * You should have received a copy of the GNU General Public License along
18 * with this program; if not, write to the Free Software Foundation, Inc.,
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
22 require_once dirname(dirname(__FILE__)).'/Testing/SeleniumGforge.php';
24 class ScmBzrTest extends FForge_SeleniumTestCase
28 $this->activatePlugin('scmbzr');
29 $this->populateStandardTemplate('empty');
33 $this->clickAndWait("link=ProjectA");
34 $this->clickAndWait("link=Admin");
35 $this->clickAndWait("link=Tools");
36 $this->clickAndWait("link=Source Code Admin");
37 $this->click("//input[@name='scmradio' and @value='scmbzr']");
38 $this->clickAndWait("submit");
40 // Run the cronjob to create repositories
41 $this->cron("create_scm_repos.php");
43 // Check that the repo is present and Loggerhead shows it (even if empty)
45 $this->clickAndWait("link=ProjectA");
46 $this->clickAndWait("link=SCM");
48 $this->open(ROOT.'/scm/loggerhead/');
49 $this->assertTextPresent("Browsing (root)");
50 $this->clickAndWait("link=projecta");
51 $this->assertTextPresent("Browsing (root)/projecta");
53 // Get the address of the repo
55 $this->clickAndWait("link=ProjectA");
56 $this->clickAndWait("link=SCM");
57 $p = $this->getText("//tt[contains(.,'bzr checkout bzr+ssh')]");
58 $p = preg_replace(",^bzr checkout ,", "", $p);
59 $p = preg_replace(",://.*@,", "://root@", $p);
60 $p = preg_replace(",/branchname$,", "", $p);
62 // Create a local branch, push it to the repo
63 $t = exec("mktemp -d /tmp/bzrTest.XXXXXX");
64 system("cd $t && bzr init --quiet trunk >/dev/null", $ret);
65 $this->assertEquals($ret, 0);
67 system("echo 'this is a simple text' > $t/trunk/mytext.txt");
68 system("cd $t/trunk && bzr add --quiet && bzr commit -m'Adding file' --quiet", $ret);
69 system("echo 'another simple text' >> $t/trunk/mytext.txt");
70 system("cd $t/trunk && bzr add --quiet && bzr commit -m'Modifying file' --quiet", $ret);
71 $this->assertEquals($ret, 0);
73 system("cd $t/trunk && bzr push --quiet $p/trunk", $ret);
74 $this->assertEquals($ret, 0);
76 $this->open(ROOT.'/scm/loggerhead/projecta');
77 $this->assertTextPresent("Browsing (root)/projecta");
78 $this->assertTextPresent("trunk");
79 $this->clickAndWait("link=trunk");
80 $this->assertTextPresent("Modifying file");
81 $this->assertTextNotPresent("Adding file");
82 $this->clickAndWait("link=Changes");
83 $this->assertTextPresent("Modifying file");
84 $this->assertTextPresent("Adding file");