public function testConnect_NoErrors()
 {
     $logger = LoggerFactory::getFileLogger('tests/LoggerSerialConnectorTest');
     $serial = new PhpSerial($logger);
     $connector = new DataLoggerSerialConnector(new StubLogger(), $serial);
     $connector->setParams(array('port' => 'COM1', 'timeout' => 60, 'flowControl' => 'xon/xoff', 'baudrate' => 9600, 'parity' => 'none', 'stopBits' => 1, 'dataBits' => 8));
     $output = null;
     $result = $connector->readData($output);
     $this->assertTrue($result);
     $this->assertTrue(count($output) > 0);
     $this->assertStringMatchesFormat('@DAWS%s$', $output[0]);
     $errors = $connector->errors();
     $this->assertEquals(0, count($errors));
 }
 public function testConnect_ErrorOnRead()
 {
     $logger = LoggerFactory::getTestLogger();
     $logger->log(__METHOD__);
     $serial = new Stub(array('functions' => array('deviceSet' => array('return' => true), 'deviceOpen' => array('return' => true), 'readString' => array('return' => false)), 'attributes' => array('_dHandle' => STDOUT)));
     $connector = new DataLoggerSerialConnector($logger, $serial);
     $connector->setParams(array('port' => 'COM#'));
     $output = null;
     $result = $connector->readData($output);
     $this->assertFalse($result);
     $this->assertNull($output);
     $errors = $connector->errors();
     $this->assertEquals(1, count($errors));
     $this->assertEquals('Error during read message', $errors[0]);
 }