FIX: ensure RestfulServiceTest uses email as the unique identifer field for running tests. Fixes: #6156.

This commit is contained in:
Will Rossiter 2012-06-29 20:45:57 +12:00
parent 168663657b
commit 4977318f46

View File

@ -1,7 +1,31 @@
<?php <?php
/**
* @package framework
* @subpackage tests
*/
class RestfulServiceTest extends SapphireTest { 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() { function testSpecialCharacters() {
$service = new RestfulServiceTest_MockRestfulService(Director::absoluteBaseURL()); $service = new RestfulServiceTest_MockRestfulService(Director::absoluteBaseURL());
$url = 'RestfulServiceTest_Controller/'; $url = 'RestfulServiceTest_Controller/';
@ -134,8 +158,16 @@ class RestfulServiceTest extends SapphireTest {
} }
class RestfulServiceTest_Controller extends Controller implements TestOnly { class RestfulServiceTest_Controller extends Controller implements TestOnly {
public static $allowed_actions = array(
'index',
'httpErrorWithoutCache',
'httpErrorWithCache'
);
public function init() { public function init() {
$this->basicAuthEnabled = false; $this->basicAuthEnabled = false;
parent::init(); parent::init();
} }