1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <?php
-
- require_once 'simpletest/autorun.php';
- require_once __DIR__.'/../pens.php';
- 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());
- }
- }
|