MINOR: Update tests for deprecated functions to explicitly disable deprecation errors.

This commit is contained in:
Sam Minnee 2011-10-29 17:04:45 +13:00
parent a49b56a348
commit 3e3188f81a
5 changed files with 43 additions and 1 deletions

View File

@ -172,14 +172,24 @@ class DirectorTest extends SapphireTest {
} }
function testURLParam() { function testURLParam() {
// 2.4 only
$originalDeprecation = Deprecation::dump_settings();
Deprecation::notification_version('2.4');
Director::test('DirectorTestRule/myaction/myid/myotherid'); Director::test('DirectorTestRule/myaction/myid/myotherid');
// TODO Works on the assumption that urlParam() is not unset after a test run, which is dodgy // TODO Works on the assumption that urlParam() is not unset after a test run, which is dodgy
$this->assertEquals(Director::urlParam('Action'), 'myaction'); $this->assertEquals(Director::urlParam('Action'), 'myaction');
$this->assertEquals(Director::urlParam('ID'), 'myid'); $this->assertEquals(Director::urlParam('ID'), 'myid');
$this->assertEquals(Director::urlParam('OtherID'), 'myotherid'); $this->assertEquals(Director::urlParam('OtherID'), 'myotherid');
Deprecation::restore_settings($originalDeprecation);
} }
function testURLParams() { function testURLParams() {
// 2.4 only
$originalDeprecation = Deprecation::dump_settings();
Deprecation::notification_version('2.4');
Director::test('DirectorTestRule/myaction/myid/myotherid'); Director::test('DirectorTestRule/myaction/myid/myotherid');
// TODO Works on the assumption that urlParam() is not unset after a test run, which is dodgy // TODO Works on the assumption that urlParam() is not unset after a test run, which is dodgy
$this->assertEquals( $this->assertEquals(
@ -191,6 +201,8 @@ class DirectorTest extends SapphireTest {
'OtherID' => 'myotherid' 'OtherID' => 'myotherid'
) )
); );
Deprecation::restore_settings($originalDeprecation);
} }
function testForceSSLProtectsEntireSite() { function testForceSSLProtectsEntireSite() {

View File

@ -77,6 +77,9 @@ class ArrayDataTest extends SapphireTest {
} }
function testGetArray() { function testGetArray() {
$originalDeprecation = Deprecation::dump_settings();
Deprecation::notification_version('2.4');
$array = array( $array = array(
'Foo' => 'Foo', 'Foo' => 'Foo',
'Bar' => 'Bar', 'Bar' => 'Bar',
@ -86,6 +89,8 @@ class ArrayDataTest extends SapphireTest {
$arrayData = new ArrayData($array); $arrayData = new ArrayData($array);
$this->assertEquals($arrayData->getArray(), $array); $this->assertEquals($arrayData->getArray(), $array);
Deprecation::restore_settings($originalDeprecation);
} }
function testArrayToObject() { function testArrayToObject() {

View File

@ -55,6 +55,20 @@ class AggregateTest extends SapphireTest {
'AggregateTest_Baz' 'AggregateTest_Baz'
); );
protected $originalDeprecation;
function setUp() {
parent::setUp();
// This test tests code that was deprecated after 2.4
$this->originalDeprecation = Deprecation::dump_settings();
Deprecation::notification_version('2.4');
}
function tearDown() {
parent::tearDown();
Deprecation::restore_settings($this->originalDeprecation);
}
/** /**
* Test basic aggregation on a passed type * Test basic aggregation on a passed type
*/ */

View File

@ -116,7 +116,10 @@ class DataObjectTest extends SapphireTest {
$this->assertEquals(3, $comments->Count()); $this->assertEquals(3, $comments->Count());
$this->assertEquals('Phil', $comments->First()->Name); $this->assertEquals('Phil', $comments->First()->Name);
// Test join // Test join - 2.4 only
$originalDeprecation = Deprecation::dump_settings();
Deprecation::notification_version('2.4');
$comments = DataObject::get( $comments = DataObject::get(
'DataObjectTest_TeamComment', 'DataObjectTest_TeamComment',
"\"DataObjectTest_Team\".\"Title\" = 'Team 1'", "\"DataObjectTest_Team\".\"Title\" = 'Team 1'",
@ -128,6 +131,8 @@ class DataObjectTest extends SapphireTest {
$this->assertEquals('Bob', $comments->First()->Name); $this->assertEquals('Bob', $comments->First()->Name);
$this->assertEquals('Joe', $comments->Last()->Name); $this->assertEquals('Joe', $comments->Last()->Name);
Deprecation::restore_settings($originalDeprecation);
// Test limit // Test limit
$comments = DataObject::get('DataObjectTest_TeamComment', '', "\"Name\" ASC", '', '1,2'); $comments = DataObject::get('DataObjectTest_TeamComment', '', "\"Name\" ASC", '', '1,2');
$this->assertEquals(2, $comments->Count()); $this->assertEquals(2, $comments->Count());

View File

@ -29,6 +29,10 @@ class GroupTest extends FunctionalTest {
* Test the Group::map() function * Test the Group::map() function
*/ */
function testGroupMap() { function testGroupMap() {
// 2.4 only
$originalDeprecation = Deprecation::dump_settings();
Deprecation::notification_version('2.4');
/* Group::map() returns an SQLMap object implementing iterator. You can use foreach to get ID-Title pairs. */ /* Group::map() returns an SQLMap object implementing iterator. You can use foreach to get ID-Title pairs. */
// We will iterate over the map and build mapOuput to more easily call assertions on the result. // We will iterate over the map and build mapOuput to more easily call assertions on the result.
@ -41,6 +45,8 @@ class GroupTest extends FunctionalTest {
/* We have added 2 groups to our fixture. They should both appear in $mapOutput. */ /* We have added 2 groups to our fixture. They should both appear in $mapOutput. */
$this->assertEquals($mapOutput[$group1->ID], $group1->Title); $this->assertEquals($mapOutput[$group1->ID], $group1->Title);
$this->assertEquals($mapOutput[$group2->ID], $group2->Title); $this->assertEquals($mapOutput[$group2->ID], $group2->Title);
Deprecation::restore_settings($originalDeprecation);
} }
function testMemberGroupRelationForm() { function testMemberGroupRelationForm() {