Skip to content

Commit 43448ab

Browse files
bobfloatsroot
authored and
root
committed
Fixed cleanups and tests
1 parent 85062f5 commit 43448ab

File tree

9 files changed

+650
-32
lines changed

9 files changed

+650
-32
lines changed

Documentation/DatabaseScheme.mwb

158 Bytes
Binary file not shown.

Documentation/version-control.sql

Lines changed: 488 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
Web GIT Version Control System [![Build Status](https://travis-ci.org/SSHVersionControl/git-web-client.svg?branch=master)](https://travis-ci.org/SSHVersionControl/git-web-client)
1+
Web GIT Version Control System [![Build Status](https://travis-ci.org/SSHVersionControl/git-web-client.svg?branch=master)](https://travis-ci.org/SSHVersionControl/git-web-client) [![Coverage Status](https://coveralls.io/repos/github/SSHVersionControl/git-web-client/badge.svg?branch=master)](https://coveralls.io/github/SSHVersionControl/git-web-client?branch=master)
22
========================
33

44
Welcome to the Web GIT Version Control System. This systems allows you to commit,search history,

src/VersionControl/GitControlBundle/Controller/ProjectEnvironmentController.php

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -34,35 +34,7 @@
3434
class ProjectEnvironmentController extends BaseProjectController
3535
{
3636

37-
/**
38-
* Lists all Project entities.
39-
*
40-
* @Route("s/", name="projectenvironment")
41-
* @Method("GET")
42-
* @Template()
43-
* @ProjectAccess(grantType="OWNER")
44-
*/
45-
public function indexAction(Request $request)
46-
{
47-
48-
$em = $this->getDoctrine()->getManager();
4937

50-
$keyword = $request->query->get('keyword', false);
51-
52-
$query = $em->getRepository('VersionControlGitControlBundle:ProjectEnvironment')->findByProjectAndKeyword($keyword,true)->getQuery();
53-
$paginator = $this->get('knp_paginator');
54-
$pagination = $paginator->paginate(
55-
$query,
56-
$request->query->getInt('page', 1)/*page number*/,
57-
15/*limit per page*/
58-
);
59-
60-
return array(
61-
'pagination' => $pagination,
62-
);
63-
}
64-
65-
6638
/**
6739
* Creates a new Project entity.
6840
*
@@ -145,7 +117,6 @@ private function createCreateForm(ProjectEnvironment $entity,$project,$gitaction
145117
* Displays a form to create a new Project entity.
146118
*
147119
* @Route("/new/", name="projectenvironment_new")
148-
* @ParamConverter("project", class="VersionControlGitControlBundle:Project")
149120
* @Method("GET")
150121
* @Template("VersionControlGitControlBundle:ProjectEnvironment:new.html.twig")
151122
* @ProjectAccess(grantType="OWNER")

src/VersionControl/GitControlBundle/Resources/config/services.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ services:
131131
tags:
132132
- { name: validator.constraint_validator, alias: git_folder_not_exists_validator }
133133
arguments:
134-
- '@version_control.ssh_process'
134+
- '@version_control.sftp_process'
135135

136136

137137
version_control.listener.doctrine_event_listener:

src/VersionControl/GitControlBundle/Resources/views/Project/edit.html.twig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
{% if(project.projectEnvironment|length == 0) %}
6666
<div class="alert alert-info text-center" role="alert">
6767
<p>There are no Project Environments yet for this project. So what are you waiting for, go create one</p>
68-
<button data-toggle="modal" data-target="#newProjectEnvironment" class="btn btn-primary">Add a Project Environment</button>
68+
<button data-toggle="modal" data-target="#newProjectEnvironment" class="btn btn-primary prevent-default">Add a Project Environment</button>
6969
</div>
7070
{% endif %}
7171
</div>

src/VersionControl/GitControlBundle/Resources/views/admin.layout.html.twig

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,24 @@
1010
{% block head %}
1111
<!-- Tell the browser to be responsive to screen width -->
1212
<meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" name="viewport">
13+
14+
<link rel="apple-touch-startup-image" href="/startup-image.png">
15+
<!-- iPhone SPLASHSCREEN-->
16+
<link href="apple-touch-startup-image-320x460.png" media="(device-width: 320px)" rel="apple-touch-startup-image">
17+
<!-- iPhone (Retina) SPLASHSCREEN-->
18+
<link href="apple-touch-startup-image-640x920.png" media="(device-width: 320px) and (-webkit-device-pixel-ratio: 2)" rel="apple-touch-startup-image">
19+
<!-- iPad (portrait) SPLASHSCREEN-->
20+
<link href="apple-touch-startup-image-768x1004.png" media="(device-width: 768px) and (orientation: portrait)" rel="apple-touch-startup-image">
21+
<!-- iPad (landscape) SPLASHSCREEN-->
22+
<link href="apple-touch-startup-image-748x1024.png" media="(device-width: 768px) and (orientation: landscape)" rel="apple-touch-startup-image">
23+
<!-- iPad (Retina, portrait) SPLASHSCREEN-->
24+
<link href="apple-touch-startup-image-1536x2008.png" media="(device-width: 1536px) and (orientation: portrait) and (-webkit-device-pixel-ratio: 2)" rel="apple-touch-startup-image">
25+
<!-- iPad (Retina, landscape) SPLASHSCREEN-->
26+
<link href="apple-touch-startup-image-2048x1496.png" media="(device-width: 1536px) and (orientation: landscape) and (-webkit-device-pixel-ratio: 2)" rel="apple-touch-startup-image">
27+
28+
<meta name="apple-mobile-web-app-title" content="Git Web Client">
29+
<meta name="apple-mobile-web-app-capable" content="yes">
30+
1331
<!-- Bootstrap 3.3.5 -->
1432
<link rel="stylesheet" href="{{ asset('bundles/versioncontrolgitcontrol/bootstrap/css/bootstrap.min.css') }}" >
1533
<!-- Font Awesome -->

src/VersionControl/GitControlBundle/Tests/Controller/BaseControllerTestCase.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,15 @@
55
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
66
use Symfony\Component\BrowserKit\Cookie;
77
use Symfony\Component\Security\Core\Authentication\Token\UsernamePasswordToken;
8+
use Symfony\Component\Filesystem\Filesystem;
89

910
class BaseControllerTestCase extends WebTestCase
1011
{
1112
protected $client = null;
1213

1314
public $entityManager;
15+
16+
protected $paths = null;
1417

1518
public function setUp()
1619
{
@@ -101,5 +104,32 @@ protected function assertTextAreaValue($crawler, $key, $val)
101104
$val, $input->text(), $key.' failed'
102105
);
103106
}
107+
108+
/**
109+
* Creates a temp folder. Use to create folder to test git functions
110+
*
111+
* @param string $folderName
112+
*/
113+
protected function createTempFolder($folderName){
114+
$tempDir = realpath(sys_get_temp_dir());
115+
$tempFullPathName = tempnam($tempDir, $folderName);
116+
$this->paths[$folderName] = $tempFullPathName;
117+
@unlink($this->paths[$folderName]);
118+
$fs = new Filesystem();
119+
$fs->mkdir($this->paths[$folderName]);
120+
121+
return $this->paths[$folderName];
122+
}
104123

124+
/**
125+
* Remove any paths created after test
126+
*/
127+
protected function tearDown() {
128+
if(is_array($this->paths)){
129+
$fs = new Filesystem();
130+
foreach($this->paths as $path){
131+
$fs->remove($path);
132+
}
133+
}
134+
}
105135
}
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
<?php
2+
3+
namespace VersionControl\GitControlBundle\Tests\Controller;
4+
5+
6+
class ProjectEnvironmentControllerTest extends BaseControllerTestCase
7+
{
8+
9+
public function testNewGitProjectEnvironmentScenario()
10+
{
11+
$user = $this->createAuthorizedClient();
12+
// Create a new client to browse the application
13+
14+
$project = $this->getProject($user);
15+
16+
17+
// List users for project
18+
$url = $this->client->getContainer()->get('router')->generate('projectenvironment_new', array('id'=>$project->getId()));
19+
$crawler = $this->client->request('GET', $url,array(), array(), array(
20+
'HTTP_X-Requested-With' => 'XMLHttpRequest',
21+
));
22+
$this->assertEquals(200, $this->client->getResponse()->getStatusCode(), "Unexpected HTTP status code for GET ".$url);
23+
24+
$gitPath = $this->createTempFolder('NewRepo');
25+
// Fill in the form and submit it
26+
$form = $crawler->selectButton('Create')->form(array(
27+
'versioncontrol_gitcontrolbundle_projectenvironment[title]' => 'Test New Project Environment',
28+
'versioncontrol_gitcontrolbundle_projectenvironment[description]' => 'Test project environment with new git folder creation',
29+
'versioncontrol_gitcontrolbundle_projectenvironment[path]' => $gitPath,
30+
));
31+
32+
$this->client->submit($form);
33+
$crawler = $this->client->followRedirect();
34+
35+
$this->assertEquals(200, $this->client->getResponse()->getStatusCode(), "Unexpected HTTP status code for creating new project environment");
36+
$this->assertGreaterThan(0, $crawler->filter('a:contains("Test New Project Environment")')->count(), 'Missing element a:contains(""Test New Project Environment")');
37+
38+
}
39+
40+
/**
41+
* Test exisitng Git project. Test does not create a git repo so we test that
42+
* project path does not contain a git repo ;-(
43+
* @todo Does not validate in crawler. no idea why. needs more debugging
44+
*/
45+
public function testExistingGitProjectEnvironmentScenario()
46+
{
47+
$user = $this->createAuthorizedClient();
48+
// Create a new client to browse the application
49+
50+
$project = $this->getProject($user);
51+
52+
53+
// List users for project
54+
$url = $this->client->getContainer()->get('router')->generate('projectenvironment_existing', array('id'=>$project->getId()));
55+
$crawler = $this->client->request('GET', $url,array(), array(), array(
56+
'HTTP_X-Requested-With' => 'XMLHttpRequest',
57+
));
58+
$this->assertEquals(200, $this->client->getResponse()->getStatusCode(), "Unexpected HTTP status code for GET /userprojects/");
59+
60+
$gitPath = $this->createTempFolder('NewExistingRepo');
61+
62+
// Fill in the form and submit it
63+
$form = $crawler->selectButton('Create')->form(array(
64+
'versioncontrol_gitcontrolbundle_projectenvironment[title]' => 'Test New Project Environment with Existing git Repo',
65+
'versioncontrol_gitcontrolbundle_projectenvironment[description]' => 'Test project environment with existing git folder creation',
66+
'versioncontrol_gitcontrolbundle_projectenvironment[path]' => $gitPath,
67+
));
68+
69+
$this->client->submit($form);
70+
$this->assertEquals(200, $this->client->getResponse()->getStatusCode(), "Unexpected HTTP status code for creating new existing git repo project environment");
71+
72+
//$html = $crawler->html();
73+
//$showUrl = $this->client->getRequest()->getUri();
74+
//$this->assertGreaterThan(0, $crawler->filter('.alert-danger')->count(), 'Missing validation errors when there should be some. Element .alert-danger is missing.'.$showUrl);
75+
76+
}
77+
78+
public function testCloneGitProjectEnvironmentScenario()
79+
{
80+
$user = $this->createAuthorizedClient();
81+
// Create a new client to browse the application
82+
83+
$project = $this->getProject($user);
84+
85+
86+
// List users for project
87+
$url = $this->client->getContainer()->get('router')->generate('projectenvironment_clone', array('id'=>$project->getId()));
88+
$crawler = $this->client->request('GET', $url,array(), array(), array(
89+
'HTTP_X-Requested-With' => 'XMLHttpRequest',
90+
));
91+
$this->assertEquals(200, $this->client->getResponse()->getStatusCode(), "Unexpected HTTP status code for GET /userprojects/");
92+
93+
$gitPath = $this->createTempFolder('NewCloneRepo');
94+
// Fill in the form and submit it
95+
$form = $crawler->selectButton('Create')->form(array(
96+
'versioncontrol_gitcontrolbundle_projectenvironment[title]' => 'Test Clone Project Environment',
97+
'versioncontrol_gitcontrolbundle_projectenvironment[description]' => 'Test Clone project environment with new git folder creation',
98+
'versioncontrol_gitcontrolbundle_projectenvironment[path]' => $gitPath,
99+
'versioncontrol_gitcontrolbundle_projectenvironment[gitCloneLocation]' => 'https://github.com/SSHVersionControl/test.git',
100+
));
101+
102+
$this->client->submit($form);
103+
$crawler = $this->client->followRedirect();
104+
105+
$this->assertEquals(200, $this->client->getResponse()->getStatusCode(), "Unexpected HTTP status code for creating new project environment");
106+
$this->assertGreaterThan(0, $crawler->filter('a:contains("Test Clone Project Environment")')->count(), 'Missing element a:contains("Test Clone Project Environment")');
107+
108+
109+
}
110+
111+
}

0 commit comments

Comments
 (0)