public function testConnect_NoErrors() { $logger = LoggerFactory::getFileLogger('tests/RealGsmModemSerialConnectorTest'); $serial = new PhpSerial($logger); $connector = new GsmModemSerialConnector(new StubLogger(), $serial); $connector->setParams(array('port' => 'COM1', 'timeout' => 5, 'flowControl' => 'rts/cts', 'baudrate' => 9600, 'parity' => 'none', 'stopBits' => 1, 'dataBits' => 8)); $output = null; $result = $connector->readData($output); $this->assertTrue($result); $errors = $connector->errors(); $this->assertEquals(0, count($errors)); $this->assertEquals(2, count($output)); $this->assertEquals('AT+CMGL="ALL"', $output[0]); $this->assertEquals('OK', $output[1]); }
public function testConnect_ErrorOnRead_NoErrors() { $logger = LoggerFactory::getTestLogger(); $logger->log(__METHOD__); $serial = new Stub(array('functions' => array('deviceSet' => array('return' => true), 'deviceOpen' => array('return' => true), 'readPort' => array('return' => "String1\r\nString2\r\nString3\r\n")), 'attributes' => array('_dHandle' => STDOUT))); $connector = new GsmModemSerialConnector($logger, $serial); $connector->setParams(array('port' => 'COM#')); $output = null; $result = $connector->readData($output); $expected = array('String1', 'String2', 'String3'); $this->assertTrue($result); $this->assertEquals($expected, $output); $errors = $connector->errors(); $this->assertEquals(0, count($errors)); }