Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

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

…ld for running tests. Fixes: #6156.
  • Loading branch information...
commit 4977318f46781619ff5cee2b10784e8807be96ec 1 parent 1686636
@wilr wilr authored
Showing with 33 additions and 1 deletion.
  1. +33 −1 tests/api/RestfulServiceTest.php
View
34 tests/api/RestfulServiceTest.php
@@ -1,7 +1,31 @@
<?php
+/**
+ * @package framework
+ * @subpackage tests
+ */
class RestfulServiceTest extends SapphireTest {
+ protected $member_unique_identifier_field = '';
+
+ function setUp() {
+ // backup the project unique identifier field
+ $this->member_unique_identifier_field = Member::get_unique_identifier_field();
+
+ Member::set_unique_identifier_field('Email');
+
+ parent::setUp();
+ }
+
+ function tearDown() {
+ parent::tearDown();
+
+ // set old member::get_unique_identifier_field value
+ if ($this->member_unique_identifier_field) {
+ Member::set_unique_identifier_field($this->member_unique_identifier_field);
+ }
+ }
+
function testSpecialCharacters() {
$service = new RestfulServiceTest_MockRestfulService(Director::absoluteBaseURL());
$url = 'RestfulServiceTest_Controller/';
@@ -134,8 +158,16 @@ private function createFakeCachedResponse($connection, $subUrl) {
}
class RestfulServiceTest_Controller extends Controller implements TestOnly {
+
+ public static $allowed_actions = array(
+ 'index',
+ 'httpErrorWithoutCache',
+ 'httpErrorWithCache'
+ );
+
public function init() {
$this->basicAuthEnabled = false;
+
parent::init();
}
@@ -191,7 +223,7 @@ public function httpErrorWithoutCache() {
$this->response->setBody($out);
$this->response->setStatusCode(400);
$this->response->addHeader('Content-type', 'text/xml');
-
+
return $this->response;
}
Please sign in to comment.
Something went wrong with that request. Please try again.