Add players tests and some goldsource info tests

pull/94/head
Pavel Djundik 9 years ago
parent 750df786ec
commit d322b3bb78

@ -0,0 +1,16 @@
{
"Address": "192.168.1.197:27020",
"HostName": "Castle Mortimus:0",
"Map": "op4_kbase",
"ModDir": "gearbox",
"ModDesc": "HLTV",
"Players": 0,
"MaxPlayers": 1,
"Protocol": 48,
"Dedicated": "p",
"Os": "w",
"Password": false,
"IsMod": false,
"Secure": false,
"Bots": 0
}

@ -0,0 +1 @@
ffffffff6d3139322e3136382e312e3139373a323730323000436173746c65204d6f7274696d75733a30006f70345f6b626173650067656172626f7800484c5456000001307077000000

@ -0,0 +1,24 @@
{
"Address": "127.0.0.1:27015",
"HostName": "ClanSC #3 - Engage [Logros]",
"Map": "sc_doc",
"ModDir": "svencoop",
"ModDesc": "Sven Co-op 4.8",
"Players": 0,
"MaxPlayers": 16,
"Protocol": 47,
"Dedicated": "d",
"Os": "w",
"Password": true,
"IsMod": true,
"Secure": false,
"Bots": 0,
"Mod": {
"Url": "",
"Download": "",
"Version": 1,
"Size": 0,
"ServerSide": true,
"CustomDLL": false
}
}

@ -0,0 +1 @@
ffffffff6d3132372e302e302e313a323730313500436c616e5343202333202d20456e67616765205b4c6f67726f735d0073635f646f63007376656e636f6f70005376656e20436f2d6f7020342e380000102f64770101000000010000000000000001000000

@ -0,0 +1,408 @@
[
{
"Id": 0,
"Name": "Zien",
"Frags": 0,
"Time": 11538,
"TimeF": "03:12:18"
},
{
"Id": 0,
"Name": "",
"Frags": 0,
"Time": 8919,
"TimeF": "02:28:39"
},
{
"Id": 0,
"Name": "丶↑뮈지 这是什么鬼",
"Frags": 0,
"Time": 8804,
"TimeF": "02:26:44"
},
{
"Id": 0,
"Name": "LiGGleS",
"Frags": 0,
"Time": 7561,
"TimeF": "02:06:01"
},
{
"Id": 0,
"Name": "☣[AGC]Michael J. Caboose☣",
"Frags": 0,
"Time": 5675,
"TimeF": "01:34:35"
},
{
"Id": 0,
"Name": "decision <vancity_dv>",
"Frags": 0,
"Time": 5339,
"TimeF": "01:28:59"
},
{
"Id": 0,
"Name": "Mime ❝Matheo❞",
"Frags": 0,
"Time": 4296,
"TimeF": "01:11:36"
},
{
"Id": 0,
"Name": "Szp@n3r",
"Frags": 0,
"Time": 3880,
"TimeF": "01:04:40"
},
{
"Id": 0,
"Name": "Foxy | D:<",
"Frags": 0,
"Time": 3746,
"TimeF": "01:02:26"
},
{
"Id": 0,
"Name": "Giguli",
"Frags": 0,
"Time": 3599,
"TimeF": "59:59"
},
{
"Id": 0,
"Name": "Erkxalle",
"Frags": 0,
"Time": 2860,
"TimeF": "47:40"
},
{
"Id": 0,
"Name": "[GlobalEdgelite]DaC0p#fuckturks",
"Frags": 0,
"Time": 2666,
"TimeF": "44:26"
},
{
"Id": 0,
"Name": "Aluminiu",
"Frags": 0,
"Time": 2634,
"TimeF": "43:54"
},
{
"Id": 0,
"Name": "BlackLounge-ZombieSOAD TwinBROS",
"Frags": 0,
"Time": 2499,
"TimeF": "41:39"
},
{
"Id": 0,
"Name": "Captain Buster",
"Frags": 0,
"Time": 2420,
"TimeF": "40:20"
},
{
"Id": 0,
"Name": "thirty seven",
"Frags": 0,
"Time": 2395,
"TimeF": "39:55"
},
{
"Id": 0,
"Name": "!Bastardo!",
"Frags": 0,
"Time": 2274,
"TimeF": "37:54"
},
{
"Id": 0,
"Name": "Saibot™",
"Frags": 0,
"Time": 2240,
"TimeF": "37:20"
},
{
"Id": 0,
"Name": "OG W i l l y",
"Frags": 0,
"Time": 2182,
"TimeF": "36:22"
},
{
"Id": 0,
"Name": "TriXterR",
"Frags": 0,
"Time": 2034,
"TimeF": "33:54"
},
{
"Id": 0,
"Name": "ToadsMansion",
"Frags": 0,
"Time": 1974,
"TimeF": "32:54"
},
{
"Id": 0,
"Name": "Moxshi™",
"Frags": 0,
"Time": 1924,
"TimeF": "32:04"
},
{
"Id": 0,
"Name": "bish",
"Frags": 0,
"Time": 1831,
"TimeF": "30:31"
},
{
"Id": 0,
"Name": "Arakismo",
"Frags": 0,
"Time": 1811,
"TimeF": "30:11"
},
{
"Id": 0,
"Name": "Just_Dank",
"Frags": 0,
"Time": 1753,
"TimeF": "29:13"
},
{
"Id": 0,
"Name": "Aftersh0ck",
"Frags": 0,
"Time": 1724,
"TimeF": "28:44"
},
{
"Id": 0,
"Name": "Saibaman",
"Frags": 0,
"Time": 1635,
"TimeF": "27:15"
},
{
"Id": 0,
"Name": "The Ultimate Gamer",
"Frags": 0,
"Time": 1610,
"TimeF": "26:50"
},
{
"Id": 0,
"Name": "Butter Kaya no Peanut",
"Frags": 0,
"Time": 1549,
"TimeF": "25:49"
},
{
"Id": 0,
"Name": "Lugiia",
"Frags": 0,
"Time": 1488,
"TimeF": "24:48"
},
{
"Id": 0,
"Name": "Hoang Bao",
"Frags": 0,
"Time": 1387,
"TimeF": "23:07"
},
{
"Id": 0,
"Name": "Eldo Prezidento",
"Frags": 0,
"Time": 1344,
"TimeF": "22:24"
},
{
"Id": 0,
"Name": "Sky[C.Y.R]",
"Frags": 0,
"Time": 1306,
"TimeF": "21:46"
},
{
"Id": 0,
"Name": "PunckChop",
"Frags": 0,
"Time": 995,
"TimeF": "16:35"
},
{
"Id": 0,
"Name": "Elmoradian",
"Frags": 0,
"Time": 968,
"TimeF": "16:08"
},
{
"Id": 0,
"Name": "friendshipz",
"Frags": 0,
"Time": 967,
"TimeF": "16:07"
},
{
"Id": 0,
"Name": "Guardios",
"Frags": 0,
"Time": 897,
"TimeF": "14:57"
},
{
"Id": 0,
"Name": "Samuel Luz",
"Frags": 0,
"Time": 779,
"TimeF": "12:59"
},
{
"Id": 0,
"Name": "LordMerkx",
"Frags": 0,
"Time": 756,
"TimeF": "12:36"
},
{
"Id": 0,
"Name": "zeroyjk",
"Frags": 0,
"Time": 698,
"TimeF": "11:38"
},
{
"Id": 0,
"Name": "[yellow][@Rainbow@][blue](moon)",
"Frags": 0,
"Time": 633,
"TimeF": "10:33"
},
{
"Id": 0,
"Name": "XiaoJim(Newbie)",
"Frags": 0,
"Time": 588,
"TimeF": "09:48"
},
{
"Id": 0,
"Name": "George Costanza",
"Frags": 0,
"Time": 568,
"TimeF": "09:28"
},
{
"Id": 0,
"Name": "Boring Bob",
"Frags": 0,
"Time": 565,
"TimeF": "09:25"
},
{
"Id": 0,
"Name": "Chris",
"Frags": 0,
"Time": 559,
"TimeF": "09:19"
},
{
"Id": 0,
"Name": "NLVN",
"Frags": 0,
"Time": 554,
"TimeF": "09:14"
},
{
"Id": 0,
"Name": "Dan Rampage",
"Frags": 0,
"Time": 518,
"TimeF": "08:38"
},
{
"Id": 0,
"Name": "Kikerini",
"Frags": 0,
"Time": 477,
"TimeF": "07:57"
},
{
"Id": 0,
"Name": "waxor123",
"Frags": 0,
"Time": 382,
"TimeF": "06:22"
},
{
"Id": 0,
"Name": "Uzu",
"Frags": 0,
"Time": 286,
"TimeF": "04:46"
},
{
"Id": 0,
"Name": "chewin'_ma_BIC #FREE KAKAROT",
"Frags": 0,
"Time": 265,
"TimeF": "04:25"
},
{
"Id": 0,
"Name": "Milk Tea.",
"Frags": 0,
"Time": 218,
"TimeF": "03:38"
},
{
"Id": 0,
"Name": "Inglorious Bastard",
"Frags": 0,
"Time": 208,
"TimeF": "03:28"
},
{
"Id": 0,
"Name": "Bloody Wolf",
"Frags": 0,
"Time": 184,
"TimeF": "03:04"
},
{
"Id": 0,
"Name": "YurMum",
"Frags": 0,
"Time": 161,
"TimeF": "02:41"
},
{
"Id": 0,
"Name": "Modica",
"Frags": 0,
"Time": 113,
"TimeF": "01:53"
},
{
"Id": 0,
"Name": "[P].R.O.T.O.T.Y.P.E",
"Frags": 0,
"Time": 109,
"TimeF": "01:49"
},
{
"Id": 0,
"Name": "69@War",
"Frags": 0,
"Time": 33,
"TimeF": "00:33"
}
]

@ -0,0 +1,2 @@
feffffffff8400000200a404ffffffff443a005a69656e0000000000d948344600efbca4efbd8fefbd86efbd86efbd9900000000007a5c0b4600e4b8b6e28691ebae88eca78020e8bf99e698afe4bb80e4b988e9acbc00000000003a920946004c6947476c655300000000005348ec4500e298a35b4147435d4d69636861656c204a2e204361626f6f7365e298a30000000000905ab145006465636973696f6e203c76616e636974795f64763e00000000004edfa645004d696d6520e29d9d4d617468656fe29d9e00000000001940864500537a70406e33720000000000898c724500466f7879207c20443a3c0000000000622c6a4500476967756c690000000000ebfb60450045726b78616c6c65000000000048c93245005b476c6f62616c456467656c6974655d4461433070236675636b7475726b73000000000087a5264500416c756d696e69750000000000c6ac244500426c61636b4c6f756e67652d5a6f6d626965534f4144205477696e42524f530000000000c6381c45004361707461696e204275737465720000000000ac4917450074686972747920736576656e00000000006eb315450021426173746172646f210000000000ed260e4500536169626f74e284a20000000000ae000c45004f4720572069206c206c20790000000000836508450054726958746572520000000000855afe4400546f6164734d616e73696f6e000000000003d1f644004d6f78736869e284a200000000000483f0440062697368000000000096efe444004172616b69736d6f00000000009769e244004a7573745f44616e6b00000000009d27db44004166746572736830636b00000000002680d7440053616962616d616e00000000009274cc440054686520556c74696d6174652047616d65720000000000934bc94400427574746572204b617961206e6f205065616e7574000000000075a0c144004c75676969610000000000fd02ba4400486f616e672042616f0000000000677aad4400456c646f205072657a6964656e746f00000000006612a84400536b795b432e592e525d0000000000e758a3440050756e636b43686f7000000000007bee784400456c6d6f72616469616e00000000008e0b724400667269656e64736869707a000000000090d37144004775617264696f7300000000008e4a60440053616d75656c204c757a0000000000cbdb4244004c6f72644d65726b780000000000c9123d44007a65726f796a6b000000000083a92e44005b79656c6c6f775d5b405261696e626f77405d5b626c75655d286d6f6f6e29000000000088401e44005869616f4a696d284e6577626965290000000000a33c13440047656f72676520436f7374616e7a610000000000af040e4400426f72696e6720426f620000000000b7600d440043687269730000000000b6fa0b44004e4c564e0000000000b0870a440044616e2052616d7061676500000000008d900144004b696b6572696e690000000000dae3ee43007761786f723132330000000000d713bf4300557a750000000000276b8f430063686577696e275f6d615f424943202346524545204b414b41524f5400000000000df78443004d696c6b205465612e00000000002a025a4300496e676c6f72696f75732042617374617264000000000052
feffffffff8400000201a4040e504300426c6f6f647920576f6c66000000000014583843005975724d756d0000000000f6452143004d6f64696361000000000041e7e242005b505d2e522e4f2e542e4f2e542e592e502e4500000000005db8da4200363940576172000000000018f00742

@ -130,14 +130,16 @@
*/ */
public function testGetInfo( $RawInput, $ExpectedOutput ) public function testGetInfo( $RawInput, $ExpectedOutput )
{ {
if( isset( $ExpectedOutput[ 'IsMod' ] ) )
{
$this->Socket->Engine = SourceQuery::GOLDSOURCE;
}
$this->Socket->Queue( $RawInput ); $this->Socket->Queue( $RawInput );
$RealOutput = $this->SourceQuery->GetInfo(); $RealOutput = $this->SourceQuery->GetInfo();
foreach( $ExpectedOutput as $Key => $ExpectedValue ) $this->assertEquals( $ExpectedOutput, $RealOutput );
{
$this->assertEquals( $ExpectedValue, $RealOutput[ $Key ], $Key );
}
} }
public function InfoProvider() public function InfoProvider()
@ -197,10 +199,7 @@
$RealOutput = $this->SourceQuery->GetRules(); $RealOutput = $this->SourceQuery->GetRules();
foreach( $ExpectedOutput as $Key => $ExpectedValue ) $this->assertEquals( $ExpectedOutput, $RealOutput );
{
$this->assertEquals( $ExpectedValue, $RealOutput[ $Key ], $Key );
}
} }
public function RulesProvider() public function RulesProvider()
@ -220,4 +219,48 @@
return $DataProvider; return $DataProvider;
} }
/**
* @dataProvider PlayersProvider
*/
public function testGetPlayers( $RawInput, $ExpectedOutput )
{
$this->Socket->Queue( hex2bin( "ffffffff4104fce20e" ) ); // Challenge
foreach( $RawInput as $Packet )
{
$this->Socket->Queue( hex2bin( $Packet ) );
}
$RealOutput = $this->SourceQuery->GetPlayers();
$this->assertEquals( $ExpectedOutput, $RealOutput );
}
public function PlayersProvider()
{
$DataProvider = [];
$Files = glob( __DIR__ . '/Players/*.raw', GLOB_ERR );
foreach( $Files as $File )
{
$DataProvider[] =
[
file( $File, FILE_SKIP_EMPTY_LINES | FILE_IGNORE_NEW_LINES ),
json_decode( file_get_contents( str_replace( '.raw', '.json', $File ) ), true )
];
}
return $DataProvider;
}
public function testPing()
{
$this->Socket->Queue( "\xFF\xFF\xFF\xFF\x6A\x00");
$this->assertTrue( $this->SourceQuery->Ping() );
$this->Socket->Queue( "\xFF\xFF\xFF\xFF\xEE");
$this->assertFalse( $this->SourceQuery->Ping() );
}
} }

Loading…
Cancel
Save