From 864207923330c157a6e2aa2f0945c8a80c0b5cc8 Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Sat, 24 Oct 2015 16:21:01 +0300 Subject: [PATCH] Add RCON non connected tests --- SourceQuery/SourceQuery.php | 5 +++++ Tests/Tests.php | 26 ++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/SourceQuery/SourceQuery.php b/SourceQuery/SourceQuery.php index 92c857b..3f4c970 100644 --- a/SourceQuery/SourceQuery.php +++ b/SourceQuery/SourceQuery.php @@ -549,6 +549,11 @@ throw new SocketException( 'Not connected.', SocketException::NOT_CONNECTED ); } + if( $this->Rcon === null ) + { + throw new SocketException( 'You must set a RCON password before trying to execute a RCON command.', SocketException::NOT_CONNECTED ); + } + return $this->Rcon->Command( $Command ); } } diff --git a/Tests/Tests.php b/Tests/Tests.php index dfa2661..78bdbe1 100644 --- a/Tests/Tests.php +++ b/Tests/Tests.php @@ -125,6 +125,32 @@ $this->SourceQuery->GetRules(); } + /** + * @expectedException xPaw\SourceQuery\Exception\SocketException + */ + public function testNotConnectedSetRconPassword() + { + $this->SourceQuery->Disconnect(); + $this->SourceQuery->SetRconPassword('a'); + } + + /** + * @expectedException xPaw\SourceQuery\Exception\SocketException + */ + public function testNotConnectedRcon() + { + $this->SourceQuery->Disconnect(); + $this->SourceQuery->Rcon('a'); + } + + /** + * @expectedException xPaw\SourceQuery\Exception\SocketException + */ + public function testRconWithoutPassword() + { + $this->SourceQuery->Rcon('a'); + } + /** * @dataProvider InfoProvider */