. */ /** * Unit tests for the PENSResponse class * * This class provides unit tests for the PENSResponse class * * @package PENS * @subpackage Tests * @author Guillaume Viguier-Just * @licence http://www.gnu.org/licenses/gpl.txt */ require_once("simpletest/autorun.php"); require_once(dirname(__FILE__)."/../pens.php"); /** * Unit tests for the PENSResponse class * * This class provides unit tests for the PENSResponse class * * @package PENS * @subpackage Tests * @author Guillaume Viguier-Just * @licence http://www.gnu.org/licenses/gpl.txt */ class TestPENSResponse extends UnitTestCase { public function testCreationFromPENSException() { $object = new PENSResponse(new PENSException(1101)); $this->assertEqual($object->getError(), 1101); $this->assertNotNull($object->getErrorText()); } public function testCreationFromArguments() { $object = new PENSResponse(0, "collect command received and understood"); $this->assertIdentical($object->getError(), 0); $this->assertEqual($object->getErrorText(), "collect command received and understood"); } public function testCreationFromHTTPResponse() { $eol = PENSConfig::$eol; $response = "error=1101".$eol."error-text=unable to parse PENS command".$eol."version=1.0.0".$eol."pens-data=".$eol; $object = new PENSResponse($response); $this->assertIdentical($object->getError(), 1101); $this->assertIdentical($object->getErrorText(), "unable to parse PENS command"); $this->assertIdentical($object->getVersion(), "1.0.0"); $this->assertNull($object->getPensData()); } }