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->click("link=projecta");
51 $this->waitForPageToLoad(60000);
52 $this->assertTextPresent("Browsing (root)/projecta");
54 // Get the address of the repo
56 $this->clickAndWait("link=ProjectA");
57 $this->clickAndWait("link=SCM");
58 $p = $this->getText("//tt[contains(.,'bzr checkout bzr+ssh')]");
59 $p = preg_replace(",^bzr checkout ,", "", $p);
60 $p = preg_replace(",://.*@,", "://root@", $p);
61 $p = preg_replace(",/branchname$,", "", $p);
63 // Create a local branch, push it to the repo
64 $t = exec("mktemp -d /tmp/bzrTest.XXXXXX");
65 system("cd $t && bzr init --quiet trunk >/dev/null", $ret);
66 $this->assertEquals($ret, 0);
68 system("echo 'this is a simple text' > $t/trunk/mytext.txt");
69 system("cd $t/trunk && bzr add --quiet && bzr commit -m'Adding file' --quiet", $ret);
70 system("echo 'another simple text' >> $t/trunk/mytext.txt");
71 system("cd $t/trunk && bzr add --quiet && bzr commit -m'Modifying file' --quiet", $ret);
72 $this->assertEquals($ret, 0);
74 system("cd $t/trunk && bzr push --quiet $p/trunk", $ret);
75 $this->assertEquals($ret, 0);
77 $this->open(ROOT.'/scm/loggerhead/');
78 $this->assertTextPresent("Browsing (root)");
79 $this->click("link=projecta");
80 $this->waitForPageToLoad(60000);
81 $this->assertTextPresent("Browsing (root)/projecta");
82 $this->assertTextPresent("trunk");
83 $this->click("link=trunk");
84 $this->waitForPageToLoad(60000);
85 $this->assertTextPresent("Modifying file");
86 $this->assertTextNotPresent("Adding file");
87 $this->click("link=Changes");
88 $this->waitForPageToLoad(60000);
89 $this->assertTextPresent("Modifying file");
90 $this->assertTextPresent("Adding file");