Skip to content
This repository
Browse code

FIX: ensure RestfulServiceTest uses email as the unique identifer fie…

…ld for running tests. Fixes: #6156.
  • Loading branch information...
commit 4977318f46781619ff5cee2b10784e8807be96ec 1 parent 1686636
Will Rossiter authored June 29, 2012

Showing 1 changed file with 33 additions and 1 deletion. Show diff stats Hide diff stats

  1. 34  tests/api/RestfulServiceTest.php
34  tests/api/RestfulServiceTest.php
... ...
@@ -1,7 +1,31 @@
1 1
 <?php
2 2
 
  3
+/**
  4
+ * @package framework
  5
+ * @subpackage tests
  6
+ */
3 7
 class RestfulServiceTest extends SapphireTest {
4 8
 	
  9
+	protected $member_unique_identifier_field = ''; 
  10
+	
  11
+	function setUp() { 
  12
+		// backup the project unique identifier field
  13
+		$this->member_unique_identifier_field = Member::get_unique_identifier_field();
  14
+
  15
+		Member::set_unique_identifier_field('Email');
  16
+
  17
+		parent::setUp(); 
  18
+	} 
  19
+
  20
+	function tearDown() {
  21
+		parent::tearDown(); 
  22
+
  23
+		// set old member::get_unique_identifier_field value 
  24
+		if ($this->member_unique_identifier_field) { 
  25
+			Member::set_unique_identifier_field($this->member_unique_identifier_field); 
  26
+		}
  27
+	} 
  28
+
5 29
 	function testSpecialCharacters() {
6 30
 		$service = new RestfulServiceTest_MockRestfulService(Director::absoluteBaseURL());
7 31
 		$url = 'RestfulServiceTest_Controller/';
@@ -134,8 +158,16 @@ private function createFakeCachedResponse($connection, $subUrl) {
134 158
 }
135 159
 
136 160
 class RestfulServiceTest_Controller extends Controller implements TestOnly {
  161
+
  162
+	public static $allowed_actions = array(
  163
+		'index',
  164
+		'httpErrorWithoutCache',
  165
+		'httpErrorWithCache'
  166
+	);
  167
+
137 168
 	public function init() {
138 169
 		$this->basicAuthEnabled = false;
  170
+
139 171
 		parent::init();
140 172
 	}
141 173
 
@@ -191,7 +223,7 @@ public function httpErrorWithoutCache() {
191 223
 		$this->response->setBody($out);
192 224
 		$this->response->setStatusCode(400); 
193 225
 		$this->response->addHeader('Content-type', 'text/xml');
194  
-		
  226
+
195 227
 		return $this->response;
196 228
 	}
197 229
 	

0 notes on commit 4977318

Please sign in to comment.
Something went wrong with that request. Please try again.