| [ Index ] |
PHP Cross Reference of MantisBT |
[Summary view] [Print] [Text view]
1 <?php 2 # MantisBT - a php based bugtracking system 3 4 # MantisBT is free software: you can redistribute it and/or modify 5 # it under the terms of the GNU General Public License as published by 6 # the Free Software Foundation, either version 2 of the License, or 7 # (at your option) any later version. 8 # 9 # MantisBT is distributed in the hope that it will be useful, 10 # but WITHOUT ANY WARRANTY; without even the implied warranty of 11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 # GNU General Public License for more details. 13 # 14 # You should have received a copy of the GNU General Public License 15 # along with MantisBT. If not, see <http://www.gnu.org/licenses/>. 16 17 /** 18 * @package Tests 19 * @subpackage UnitTests 20 * @copyright Copyright (C) 2010-2011 MantisBT Team - mantisbt-dev@lists.sourceforge.net 21 * @link http://www.mantisbt.org 22 */ 23 24 require_once 'SoapBase.php'; 25 26 /** 27 * Test fixture for project webservice methods. 28 */ 29 class ProjectTest extends SoapBase { 30 31 private $projectIdToDelete = array(); 32 33 /** 34 * A test case that tests the following: 35 * 1. Create a project. 36 * 2. Rename the project. 37 */ 38 public function testAddRenameDeleteProject() { 39 $projectName = $this->getOriginalNameProject(); 40 $projectNewName = $this->getNewNameProject(); 41 42 $projectDataStructure = $this->newProjectAsArray($projectName); 43 44 $projectId = $this->client->mc_project_add( 45 $this->userName, 46 $this->password, 47 $projectDataStructure); 48 49 $this->projectIdToDelete[] = $projectId; 50 51 $projectsArray = $this->client->mc_projects_get_user_accessible( 52 $this->userName, 53 $this->password); 54 55 foreach ( $projectsArray as $project ) { 56 if ( $project->id == $projectId ) { 57 $this->assertEquals($projectName, $project->name); 58 } 59 } 60 61 $projectDataStructure['name'] = $projectNewName; 62 63 $return_bool = $this->client->mc_project_update( 64 $this->userName, 65 $this->password, 66 $projectId, 67 $projectDataStructure); 68 69 $projectsArray = $this->client->mc_projects_get_user_accessible( 70 $this->userName, 71 $this->password); 72 73 foreach ( $projectsArray as $project ) { 74 if ( $project->id == $projectId ) { 75 $this->assertEquals($projectNewName, $project->name); 76 } 77 } 78 } 79 80 /** 81 * A test case which does the following 82 * 83 * 1. Create a project 84 * 2. Retrieve the project id by name 85 * 86 */ 87 public function testGetIdFromName() { 88 89 $projectName = 'TestProjectForIdFromName'; 90 91 $projectDataStructure = $this->newProjectAsArray($projectName); 92 93 $projectId = $this->client->mc_project_add( 94 $this->userName, 95 $this->password, 96 $projectDataStructure); 97 98 $this->projectIdToDelete[] = $projectId; 99 100 $projectIdFromName = $this->client->mc_project_get_id_from_name( 101 $this->userName, 102 $this->password, 103 $projectName); 104 105 $this->assertEquals($projectIdFromName, $projectId); 106 } 107 108 /** 109 * A test case which does the following 110 * 111 * 1. Create a project 112 * 2. Retrieve the subproject ids. Must returns empty array. 113 * 114 */ 115 public function testGetSubprojects() { 116 $projectName = $this->getOriginalNameProject(); 117 $projectDataStructure = $this->newProjectAsArray($projectName); 118 119 $projectId = $this->client->mc_project_add( 120 $this->userName, 121 $this->password, 122 $projectDataStructure); 123 124 $this->projectIdToDelete[] = $projectId; 125 126 $projectsArray = $this->client->mc_project_get_all_subprojects( 127 $this->userName, 128 $this->password, 129 $projectId); 130 131 $this->assertEquals(0, count($projectsArray)); 132 } 133 134 private function newProjectAsArray($projectName) { 135 136 $projectDataStructure = array(); 137 $projectDataStructure['name'] = $projectName; 138 $projectDataStructure['status'] = "development"; 139 $projectDataStructure['view_state'] = 10; 140 141 return $projectDataStructure; 142 } 143 144 protected function tearDown() { 145 146 parent::tearDown(); 147 148 foreach ( $this->projectIdToDelete as $projectId ) { 149 $this->client->mc_project_delete( 150 $this->userName, 151 $this->password, 152 $projectId); 153 } 154 } 155 156 private function getOriginalNameProject() { 157 return 'my_project_name'; 158 } 159 160 private function getNewNameProject() { 161 return 'my_new_project_name'; 162 } 163 164 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Jul 28 15:48:31 2011 | Cross-referenced by PHPXref 0.7 |