1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Jalle19\StatusManager\Test\Subscription; |
4
|
|
|
|
5
|
|
|
use Jalle19\StatusManager\Subscription\StateChange; |
6
|
|
|
use Jalle19\StatusManager\Subscription\StateChangeParser; |
7
|
|
|
use Jalle19\tvheadend\model\comet\LogMessageNotification; |
8
|
|
|
|
9
|
|
|
/** |
10
|
|
|
* Class StateChangeParserTest |
11
|
|
|
* @package Jalle19\StatusManager\Test\Subscription |
12
|
|
|
* @copyright Copyright © Sam Stenvall 2016- |
13
|
|
|
* @license https://www.gnu.org/licenses/gpl.html The GNU General Public License v2.0 |
14
|
|
|
*/ |
15
|
|
|
class StateChangeParserTest extends \PHPUnit_Framework_TestCase |
16
|
|
|
{ |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* @param string $message |
20
|
|
|
* @param int $expectedSubscriptionId |
21
|
|
|
* @param string $expectedState |
22
|
|
|
* |
23
|
|
|
* @dataProvider messageProvider |
24
|
|
|
*/ |
25
|
|
|
public function testParseMessage($message, $expectedSubscriptionId, $expectedState) |
26
|
|
|
{ |
27
|
|
|
$logMessage = new LogMessageNotification(); |
28
|
|
|
$logMessage->logtxt = $message; |
29
|
|
|
|
30
|
|
|
$stateChanges = StateChangeParser::parseStateChanges([$logMessage]); |
31
|
|
|
$stateChange = $stateChanges[0]; |
32
|
|
|
|
33
|
|
|
$this->assertEquals($expectedSubscriptionId, $stateChange->getSubscriptionId()); |
34
|
|
|
$this->assertEquals($expectedState, $stateChange->getState()); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @return array |
40
|
|
|
*/ |
41
|
|
|
public function messageProvider() |
42
|
|
|
{ |
43
|
|
|
return [ |
44
|
|
|
[ |
45
|
|
|
'2016-04-03 20:29:44.495 subscription: 296B: "HTTP" subscribing on channel "Axess TV", weight: 100, adapter: "IPTV", network: "foo", mux: "bar", provider: "Levira", service: "Axess TV", profile="pass", hostname="::ffff", client="VLC/2.2.1 LibVLC/2.2.1"', |
46
|
|
|
hexdec('296B'), |
47
|
|
|
StateChange::STATE_SUBSCRIPTION_STARTED, |
48
|
|
|
], |
49
|
|
|
[ |
50
|
|
|
'2016-04-03 20:29:44.495 subscription: 296B: "HTTP" unsubscribing from "Axess TV", hostname="::ffff", client="VLC/2.2.1 LibVLC/2.2.1"', |
51
|
|
|
hexdec('296B'), |
52
|
|
|
StateChange::STATE_SUBSCRIPTION_STOPPED, |
53
|
|
|
], |
54
|
|
|
]; |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
} |
58
|
|
|
|