Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Split of exception tests by tests using @ExpectedException
  • Loading branch information
jrbasso committed Jul 27, 2010
1 parent 9725d12 commit 921dfb2
Showing 1 changed file with 44 additions and 37 deletions.
81 changes: 44 additions & 37 deletions cake/tests/cases/libs/xml.test.php
Expand Up @@ -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>');
}

/**
Expand Down Expand Up @@ -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'));
Expand Down

0 comments on commit 921dfb2

Please sign in to comment.