mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #130 from sminnee/master
Fixed tests for PHPUnit 3.6
This commit is contained in:
commit
dd495fb8bf
@ -93,7 +93,7 @@ class ClassInfo {
|
|||||||
if (is_object($class)) $class = get_class($class);
|
if (is_object($class)) $class = get_class($class);
|
||||||
|
|
||||||
if (!is_subclass_of($class, 'DataObject')) {
|
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)) {
|
while ($next = get_parent_class($class)) {
|
||||||
@ -148,7 +148,7 @@ class ClassInfo {
|
|||||||
if (is_object($class)) {
|
if (is_object($class)) {
|
||||||
$class = get_class($class);
|
$class = get_class($class);
|
||||||
} elseif (!is_string($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)
|
'Invalid class value %s, must be an object or string', var_export($class, true)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -102,7 +102,7 @@ class GridField extends FormField {
|
|||||||
return $this->list->dataClass;
|
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) {
|
public function setPresenter($presenter) {
|
||||||
if(!$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)) {
|
if(is_object($presenter)) {
|
||||||
@ -123,11 +123,11 @@ class GridField extends FormField {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(!class_exists($presenter)){
|
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')) {
|
if($presenter !='GridFieldPresenter' && !is_subclass_of($presenter, 'GridFieldPresenter')) {
|
||||||
throw new Exception(sprintf(
|
throw new InvalidArgumentException(sprintf(
|
||||||
'DataPresenter "%s" must subclass GridFieldPresenter', $presenter
|
'DataPresenter "%s" must subclass GridFieldPresenter', $presenter
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -181,7 +181,7 @@ class GridFieldPresenter extends ViewableData {
|
|||||||
*/
|
*/
|
||||||
public function Headers() {
|
public function Headers() {
|
||||||
if(!$this->getList()) {
|
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())
|
'%s needs an data source to be able to render the form', get_class($this->getGridField())
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ class ClassInfoTest extends SapphireTest {
|
|||||||
$this->assertEquals('ClassInfoTest_BaseClass', ClassInfo::baseDataClass('ClassInfoTest_ChildClass'));
|
$this->assertEquals('ClassInfoTest_BaseClass', ClassInfo::baseDataClass('ClassInfoTest_ChildClass'));
|
||||||
$this->assertEquals('ClassInfoTest_BaseClass', ClassInfo::baseDataClass('ClassInfoTest_GrandChildClass'));
|
$this->assertEquals('ClassInfoTest_BaseClass', ClassInfo::baseDataClass('ClassInfoTest_GrandChildClass'));
|
||||||
|
|
||||||
$this->setExpectedException('Exception');
|
$this->setExpectedException('InvalidArgumentException');
|
||||||
ClassInfo::baseDataClass('DataObject');
|
ClassInfo::baseDataClass('DataObject');
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ class ClassInfoTest extends SapphireTest {
|
|||||||
'$tablesOnly option excludes memory-only inheritance classes'
|
'$tablesOnly option excludes memory-only inheritance classes'
|
||||||
);
|
);
|
||||||
|
|
||||||
$this->setExpectedException('Exception');
|
$this->setExpectedException('InvalidArgumentException');
|
||||||
ClassInfo::ancestry(42);
|
ClassInfo::ancestry(42);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,19 +32,19 @@ class GridFieldTest extends SapphireTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function testSetEmptyDataPresenter() {
|
function testSetEmptyDataPresenter() {
|
||||||
$this->setExpectedException('Exception');
|
$this->setExpectedException('InvalidArgumentException');
|
||||||
$grid = new GridField('Testgrid');
|
$grid = new GridField('Testgrid');
|
||||||
$grid->setPresenter('');
|
$grid->setPresenter('');
|
||||||
}
|
}
|
||||||
|
|
||||||
function testSetNonExistingDataPresenter() {
|
function testSetNonExistingDataPresenter() {
|
||||||
$this->setExpectedException('Exception');
|
$this->setExpectedException('InvalidArgumentException');
|
||||||
$grid = new GridField('Testgrid');
|
$grid = new GridField('Testgrid');
|
||||||
$grid->setPresenter('ifThisClassExistsIWouldBeSurprised');
|
$grid->setPresenter('ifThisClassExistsIWouldBeSurprised');
|
||||||
}
|
}
|
||||||
|
|
||||||
function testSetDataPresenterWithDataObject() {
|
function testSetDataPresenterWithDataObject() {
|
||||||
$this->setExpectedException('Exception');
|
$this->setExpectedException('InvalidArgumentException');
|
||||||
$grid = new GridField('Testgrid');
|
$grid = new GridField('Testgrid');
|
||||||
$grid->setPresenter('DataObject');
|
$grid->setPresenter('DataObject');
|
||||||
}
|
}
|
||||||
@ -64,7 +64,7 @@ class GridFieldTest extends SapphireTest {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
function testFieldHolderWithoutDataSource() {
|
function testFieldHolderWithoutDataSource() {
|
||||||
$this->setExpectedException('Exception');
|
$this->setExpectedException('LogicException');
|
||||||
$grid = new GridField('Testgrid');
|
$grid = new GridField('Testgrid');
|
||||||
$this->assertNotNull($grid->FieldHolder());
|
$this->assertNotNull($grid->FieldHolder());
|
||||||
}
|
}
|
||||||
|
@ -192,7 +192,7 @@ class SSViewerCacheBlockTest extends SapphireTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException Exception
|
* @expectedException SSTemplateParseException
|
||||||
*/
|
*/
|
||||||
function testErrorMessageForCachedWithinControlWithinCached() {
|
function testErrorMessageForCachedWithinControlWithinCached() {
|
||||||
$this->_reset(true);
|
$this->_reset(true);
|
||||||
@ -205,7 +205,7 @@ class SSViewerCacheBlockTest extends SapphireTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException Exception
|
* @expectedException SSTemplateParseException
|
||||||
*/
|
*/
|
||||||
function testErrorMessageForCachedWithinIf() {
|
function testErrorMessageForCachedWithinIf() {
|
||||||
$this->_reset(true);
|
$this->_reset(true);
|
||||||
@ -213,7 +213,7 @@ class SSViewerCacheBlockTest extends SapphireTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @expectedException Exception
|
* @expectedException SSTemplateParseException
|
||||||
*/
|
*/
|
||||||
function testErrorMessageForInvalidConditional() {
|
function testErrorMessageForInvalidConditional() {
|
||||||
$this->_reset(true);
|
$this->_reset(true);
|
||||||
|
Loading…
Reference in New Issue
Block a user