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 ScmSvnSSHTest extends FForge_SeleniumTestCase
26 function testScmSvnSSH()
28 $this->skip_on_rpm_installs();
29 $this->skip_on_src_installs();
31 $this->activatePlugin('scmsvn');
32 $this->populateStandardTemplate('empty');
36 $this->clickAndWait("link=ProjectA");
37 $this->clickAndWait("link=Admin");
38 $this->clickAndWait("link=Tools");
39 $this->clickAndWait("link=Source Code Admin");
40 $this->click("//input[@name='scmradio' and @value='scmsvn']");
41 $this->clickAndWait("submit");
43 $this->uploadSshKey();
45 // Run the cronjob to create repositories
47 $this->cron("create_scm_repos.php");
48 $this->cron("homedirs.php");
49 $this->cron("ssh_create.php");
51 // Get the address of the repo
53 $this->clickAndWait("link=ProjectA");
54 $this->clickAndWait("link=SCM");
55 $p = $this->getText("//tt[contains(.,'svn checkout svn+ssh')]");
56 $p = preg_replace(",^svn checkout ,", "", $p);
58 // Create a local checkout, commit stuff
59 $t = exec("mktemp -d /tmp/svnTest.XXXXXX");
60 system("cd $t && svn checkout $p projecta", $ret);
61 $this->assertEquals($ret, 0);
63 system("echo 'this is a simple text' > $t/projecta/mytext.txt");
64 system("cd $t/projecta && svn add mytext.txt && svn commit -m'Adding file'", $ret);
65 system("echo 'another simple text' >> $t/projecta/mytext.txt");
66 system("cd $t/projecta && svn commit -m'Modifying file'", $ret);
67 $this->assertEquals($ret, 0);
69 // Check that the changes appear in svnweb
71 $this->clickAndWait("link=ProjectA");
72 $this->clickAndWait("link=SCM");
73 $this->clickAndWait("link=Browse Subversion Repository");
74 $this->assertTextPresent("Modifying file");
75 $this->assertTextNotPresent("Adding file");
81 * Method that is called after Selenium actions.
83 * @param string $action
85 protected function defaultAssertions($action)
87 if ($action == 'waitForPageToLoad') {
88 $this->assertTrue($this->isElementPresent("//h1")
89 || $this->isElementPresent("//.[@class='page_footer']"));