Skip to content
Permalink
Browse files

Split of exception tests by tests using @expectedException

  • Loading branch information...
jrbasso committed Jul 27, 2010
1 parent 9725d12 commit 921dfb259f1a7fb3facff888b7888ea1aaf6ab92
Showing with 44 additions and 37 deletions.
  1. +44 −37 cake/tests/cases/libs/xml.test.php
@@ -57,32 +57,33 @@ function testBuild() {
}
/**
* testBuildException method
* testBuildInvalidData
*
* @access public
* @return void
* @expectedException Exception
* return void
*/
function testBuildException() {
try {
Xml::build(false);
$this->fail('No exception thrown');
} catch (Exception $e) {
$this->assertTrue(true);
}
function testBuildInvalidData() {
Xml::build(false);
}
try {
Xml::build('');
$this->fail('No exception thrown');
} catch (Exception $e) {
$this->assertTrue(true);
}
/**
* testBuildEmptyData
*
* @expectedException Exception
* return void
*/
function testBuildEmptyData() {
Xml::build('');
}
try {
Xml::build('<tag>');
$this->fail('No exception thrown');
} catch (Exception $e) {
$this->assertTrue(true);
}
/**
* testBuildInvalidTag
*
* @expectedException Exception
* return void
*/
function testBuildInvalidTag() {
Xml::build('<tag>');
}
/**
@@ -221,27 +222,33 @@ function testFromArrayFail() {
}
/**
* testToArray method
* testToArrayInvalidObject
*
* @access public
* @expectedException Exception
* @return void
*/
function testToArray() {
function testToArrayInvalidObject() {
$obj = new DateTime();
try {
Xml::toArray($obj);
$this->fail('No exception thrown');
} catch (Exception $e) {
$this->assertTrue(true);
}
Xml::toArray($obj);
}
try {
Xml::toArray(array());
$this->fail('No exception thrown');
} catch (Exception $e) {
$this->assertTrue(true);
}
/**
* testToArrayNoObject
*
* @expectedException Exception
* @return void
*/
function testToArrayNoObject() {
Xml::toArray(array());
}
/**
* testToArray method
*
* @access public
* @return void
*/
function testToArray() {
$xml = '<tag>name</tag>';
$obj = Xml::build($xml);
$this->assertEqual(Xml::toArray($obj), array('tag' => 'name'));

0 comments on commit 921dfb2

Please sign in to comment.
You can’t perform that action at this time.