BUGFIX: Removed use of base "Exception" class in order to avoid failures on PHPUnit 3.6.

This commit is contained in:
Sam Minnee 2011-12-17 11:51:40 +13:00
parent 36dc31d21d
commit 70d40cf4df
6 changed files with 17 additions and 17 deletions

View File

@ -93,7 +93,7 @@ class ClassInfo {
if (is_object($class)) $class = get_class($class);
if (!is_subclass_of($class, 'DataObject')) {
throw new Exception("$class is not a subclass of DataObject");
throw new InvalidArgumentException("$class is not a subclass of DataObject");
}
while ($next = get_parent_class($class)) {
@ -148,7 +148,7 @@ class ClassInfo {
if (is_object($class)) {
$class = get_class($class);
} elseif (!is_string($class)) {
throw new Exception(sprintf(
throw new InvalidArgumentException(sprintf(
'Invalid class value %s, must be an object or string', var_export($class, true)
));
}

View File

@ -102,7 +102,7 @@ class GridField extends FormField {
return $this->list->dataClass;
}
throw new Exception(get_class($this).' does not have a modelClassName');
throw new LogicException(get_class($this).' does not have a modelClassName');
}
/**
@ -112,7 +112,7 @@ class GridField extends FormField {
*/
public function setPresenter($presenter) {
if(!$presenter){
throw new Exception('setPresenter() for GridField must be set with a class');
throw new InvalidArgumentException('setPresenter() for GridField must be set with a class');
}
if(is_object($presenter)) {
@ -123,11 +123,11 @@ class GridField extends FormField {
}
if(!class_exists($presenter)){
throw new Exception('DataPresenter for GridField must be set with an existing class, '.$presenter.' does not exists.');
throw new InvalidArgumentException('DataPresenter for GridField must be set with an existing class, '.$presenter.' does not exists.');
}
if($presenter !='GridFieldPresenter' && !ClassInfo::is_subclass_of($presenter, 'GridFieldPresenter')) {
throw new Exception(sprintf(
if($presenter !='GridFieldPresenter' && !is_subclass_of($presenter, 'GridFieldPresenter')) {
throw new InvalidArgumentException(sprintf(
'DataPresenter "%s" must subclass GridFieldPresenter', $presenter
));
}

View File

@ -181,7 +181,7 @@ class GridFieldPresenter extends ViewableData {
*/
public function Headers() {
if(!$this->getList()) {
throw new Exception(sprintf(
throw new LogicException(sprintf(
'%s needs an data source to be able to render the form', get_class($this->getGridField())
));
}

View File

@ -48,7 +48,7 @@ class ClassInfoTest extends SapphireTest {
$this->assertEquals('ClassInfoTest_BaseClass', ClassInfo::baseDataClass('ClassInfoTest_ChildClass'));
$this->assertEquals('ClassInfoTest_BaseClass', ClassInfo::baseDataClass('ClassInfoTest_GrandChildClass'));
$this->setExpectedException('Exception');
$this->setExpectedException('InvalidArgumentException');
ClassInfo::baseDataClass('DataObject');
}
@ -71,7 +71,7 @@ class ClassInfoTest extends SapphireTest {
'$tablesOnly option excludes memory-only inheritance classes'
);
$this->setExpectedException('Exception');
$this->setExpectedException('InvalidArgumentException');
ClassInfo::ancestry(42);
}

View File

@ -32,19 +32,19 @@ class GridFieldTest extends SapphireTest {
}
function testSetEmptyDataPresenter() {
$this->setExpectedException('Exception');
$this->setExpectedException('InvalidArgumentException');
$grid = new GridField('Testgrid');
$grid->setPresenter('');
}
function testSetNonExistingDataPresenter() {
$this->setExpectedException('Exception');
$this->setExpectedException('InvalidArgumentException');
$grid = new GridField('Testgrid');
$grid->setPresenter('ifThisClassExistsIWouldBeSurprised');
}
function testSetDataPresenterWithDataObject() {
$this->setExpectedException('Exception');
$this->setExpectedException('InvalidArgumentException');
$grid = new GridField('Testgrid');
$grid->setPresenter('DataObject');
}
@ -64,7 +64,7 @@ class GridFieldTest extends SapphireTest {
*
*/
function testFieldHolderWithoutDataSource() {
$this->setExpectedException('Exception');
$this->setExpectedException('LogicException');
$grid = new GridField('Testgrid');
$this->assertNotNull($grid->FieldHolder());
}

View File

@ -192,7 +192,7 @@ class SSViewerCacheBlockTest extends SapphireTest {
}
/**
* @expectedException Exception
* @expectedException SSTemplateParseException
*/
function testErrorMessageForCachedWithinControlWithinCached() {
$this->_reset(true);
@ -205,7 +205,7 @@ class SSViewerCacheBlockTest extends SapphireTest {
}
/**
* @expectedException Exception
* @expectedException SSTemplateParseException
*/
function testErrorMessageForCachedWithinIf() {
$this->_reset(true);
@ -213,7 +213,7 @@ class SSViewerCacheBlockTest extends SapphireTest {
}
/**
* @expectedException Exception
* @expectedException SSTemplateParseException
*/
function testErrorMessageForInvalidConditional() {
$this->_reset(true);