示例#1
0
 public function testSSH()
 {
     $PiRelay = new PiRelay();
     $defaultSSHConfig = ['host' => null, 'user' => null, 'keyPath' => null, 'active' => false, 'port' => 22];
     $initialSSHConfig = $PiRelay->getSSHConfig();
     $this->assertEquals($initialSSHConfig, $defaultSSHConfig);
     $expectedSSHConfig = ['host' => 'raspberry.local', 'user' => 'pi', 'keyPath' => '/ssh/key/path', 'active' => true, 'port' => 2000];
     $modifiedSSHConfig = $PiRelay->setSSHConfig($expectedSSHConfig['host'], $expectedSSHConfig['user'], $expectedSSHConfig['keyPath'], $expectedSSHConfig['active'], $expectedSSHConfig['port']);
     $this->assertEquals($modifiedSSHConfig, $expectedSSHConfig);
     $this->currentValue = '0xff';
     $this->_mockShellExec();
     $PiRelay->getState();
     $expectedCommand = "/usr/bin/ssh pi@raspberry.local -i /ssh/key/path -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no -o LogLevel=quiet -p 2000 '/usr/sbin/i2cget -y 1 32 6 2>&1'";
     $this->assertEquals($this->lastShellExecCommand, $expectedCommand);
 }
 public function setState($channel, $state)
 {
     $this->PiRelay->setState($channel, $state);
     $this->redirect(['action' => 'index']);
 }