From 8a8f1585cf06ed0f28b3747a3738b232e6c4523f Mon Sep 17 00:00:00 2001 From: Pavel Djundik Date: Thu, 22 Oct 2015 13:31:24 +0300 Subject: [PATCH] Add rules test --- Tests/Rules/tf2_sourcemod.json | 263 +++++++++++++++++++++++++++++++++ Tests/Rules/tf2_sourcemod.raw | 6 + Tests/Tests.php | 57 ++++++- 3 files changed, 322 insertions(+), 4 deletions(-) create mode 100644 Tests/Rules/tf2_sourcemod.json create mode 100644 Tests/Rules/tf2_sourcemod.raw diff --git a/Tests/Rules/tf2_sourcemod.json b/Tests/Rules/tf2_sourcemod.json new file mode 100644 index 0000000..627bede --- /dev/null +++ b/Tests/Rules/tf2_sourcemod.json @@ -0,0 +1,263 @@ +{ + "anti_f2p_version": "2.1.0", + "backpack_tf_version": "2.11.1A", + "backpack_viewer_version": "1.1.2A", + "bethehorsemann_version": "1.1", + "connect_method_version": "1.2.0A", + "connect_version": "1.2.0", + "coop": "0", + "custom_chat_colors_mysql_version": "1.1.3A", + "custom_chat_colors_toggle_version": "2.0.0A", + "custom_chat_colors_version": "3.1.0A", + "deathmatch": "1", + "decalfrequency": "10", + "dynamicmotd_version": "2.2.3s", + "enhanced_items_version": "1.1.0A", + "falsemessages_version": "3.1", + "goto_version": "1.2", + "impersonate_version": "1.5.0", + "kartify_version": "1.5.0A", + "local_item_server_version": "1.1.5A", + "metamod_version": "1.10.6-devV", + "mp_allowNPCs": "1", + "mp_autocrosshair": "1", + "mp_autoteambalance": "0", + "mp_disable_respawn_times": "1", + "mp_fadetoblack": "0", + "mp_falldamage": "0", + "mp_flashlight": "0", + "mp_footsteps": "1", + "mp_forceautoteam": "0", + "mp_forcerespawn": "1", + "mp_fraglimit": "0", + "mp_friendlyfire": "0", + "mp_highlander": "0", + "mp_holiday_nogifts": "0", + "mp_match_end_at_timelimit": "1", + "mp_maxrounds": "0", + "mp_respawnwavetime": "10.0", + "mp_scrambleteams_auto": "0", + "mp_scrambleteams_auto_windifference": "3", + "mp_stalemate_enable": "0", + "mp_stalemate_meleeonly": "0", + "mp_teamlist": "hgrunt;scientist", + "mp_teamplay": "0", + "mp_timelimit": "300", + "mp_tournament": "0", + "mp_tournament_readymode": "0", + "mp_tournament_readymode_countdown": "10", + "mp_tournament_readymode_min": "2", + "mp_tournament_readymode_team_size": "0", + "mp_tournament_stopwatch": "1", + "mp_weaponstay": "0", + "mp_windifference": "0", + "mp_windifference_min": "0", + "mp_winlimit": "0", + "nextlevel": "", + "no_enemy_in_spawn_version": "1.2.1A", + "player_analytics_version": "1.3.1A", + "rainbowize_version": "1.7.0A", + "rplayer_version": "1.1", + "r_AirboatViewDampenDamp": "1.0", + "r_AirboatViewDampenFreq": "7.0", + "r_AirboatViewZHeight": "0.0", + "r_JeepViewDampenDamp": "1.0", + "r_JeepViewDampenFreq": "7.0", + "r_JeepViewZHeight": "10.0", + "r_VehicleViewDampen": "1", + "sbchecker_version": "1.0.2", + "sb_version": "1.4.11", + "scp_version": "2.1.0A", + "setuber_version": "1.3", + "smdj_version": "2.6.1", + "sm_adminsmite_version": "2.1", + "sm_aimnames_version": "0.8", + "sm_al_version": "1.0", + "sm_ammopackspawner_version": "1.0.0", + "sm_anticolorabuse_version": "1.0.0", + "sm_bgod_version": "1.0.1", + "sm_bhs_version": "1.0.0", + "sm_bleed_version": "1.0.0", + "sm_destroy_version": "1.2.0", + "sm_disco_version": "0.3.0", + "sm_fakegifts_version": "1.0.1", + "sm_fakeitem_version": "1.3.0", + "sm_fcvar_version": "1.1", + "sm_fia_version": "2.2.4", + "sm_funcommandsx_version": "2.2", + "sm_godmode_version": "2.3.1", + "sm_healthpack_spawner_version": "1.0.0", + "sm_horsemann_version": "1.1", + "sm_merasmus_version": "1.4.2", + "sm_monospawn_version": "1.1.1", + "sm_mutecheck_version": "1.9.2A", + "sm_nextmap": "trade_unusual_center_v3", + "sm_noisemaker_version": "2.2.0", + "sm_powerplay_version": "1.5.3m", + "sm_raffle_version": "0.9", + "sm_regen_version": "1.0", + "sm_resize_version": "1.2.0", + "sm_rweapons_version": "1.3", + "sm_setammo_version": "1.1.0", + "sm_setclass_chat": "1", + "sm_setclass_log": "1", + "sm_setclass_version": "1.2.0", + "sm_setspeed_chat": "1", + "sm_setspeed_log": "1", + "sm_setspeed_version": "1.3.1", + "sm_shutdown_countdown_version": "1.6.2A", + "sm_spray_version": "5.8a", + "sm_stunmod_version": "1.4.4.7", + "sm_taunt_version": "0.3", + "sm_tidychat_version": "0.4", + "sm_traderep_version": "1.0.2A", + "sm_updater_version": "1.2.2", + "sourcecomms_version": "0.9.266", + "sourcemod_version": "1.7.3-dev+5240", + "steamrep_checker_version": "1.2.0A", + "steamtools_version": "0.9.0+d5d0838", + "stripper_version": "1.2.2", + "st_gamedesc_override_version": "1.1.3A", + "sv_accelerate": "10", + "sv_airaccelerate": "10", + "sv_alltalk": "1", + "sv_bounce": "0", + "sv_cheats": "0", + "sv_contact": "service@firepoweredgaming.com", + "sv_footsteps": "1", + "sv_friction": "4", + "sv_gravity": "800", + "sv_maxspeed": "320", + "sv_maxusrcmdprocessticks": "24", + "sv_noclipaccelerate": "5", + "sv_noclipspeed": "5", + "sv_password": "0", + "sv_pausable": "0", + "sv_registration_message": "No account specified", + "sv_registration_successful": "0", + "sv_rollangle": "0", + "sv_rollspeed": "200", + "sv_specaccelerate": "5", + "sv_specnoclip": "1", + "sv_specspeed": "3", + "sv_steamgroup": "", + "sv_stepsize": "18", + "sv_stopspeed": "100", + "sv_tags": "FirePowered,alltalk,backpack.tf,increased_maxplayers,no_ads,noads,nopinion,norespawntime,trade,trading,unusual", + "sv_voiceenable": "1", + "sv_vote_quorum_ratio": "0.6", + "sv_wateraccelerate": "10", + "sv_waterfriction": "1", + "teamswitch_version": "1.3", + "tf2items_giveweapon_version": "3.14159", + "tf2items_manager": "1", + "tf2items_manager_version": "1.4.1", + "tf2items_version": "1.6.2", + "tfh_aprilfools": "0", + "tfh_birthday": "1", + "tfh_enabled": "1", + "tfh_endoftheline": "0", + "tfh_fullmoon": "1", + "tfh_halloween": "0", + "tfh_normalhealth": "0", + "tfh_valentines": "0", + "tfh_version": "1.10.2", + "tfh_winter": "1", + "tf_allow_player_use": "0", + "tf_arena_change_limit": "1", + "tf_arena_first_blood": "1", + "tf_arena_force_class": "0", + "tf_arena_max_streak": "3", + "tf_arena_override_cap_enable_time": "-1", + "tf_arena_preround_time": "10", + "tf_arena_round_time": "0", + "tf_arena_use_queue": "1", + "tf_beta_content": "0", + "tf_birthday": "0", + "tf_bot_count": "0", + "tf_classlimit": "0", + "tf_ctf_bonus_time": "10", + "tf_damage_disablespread": "1", + "tf_force_holidays_off": "0", + "tf_gamemode_arena": "0", + "tf_gamemode_cp": "0", + "tf_gamemode_ctf": "0", + "tf_gamemode_mvm": "0", + "tf_gamemode_passtime": "0", + "tf_gamemode_payload": "0", + "tf_gamemode_pd": "0", + "tf_gamemode_rd": "0", + "tf_gamemode_sd": "0", + "tf_max_charge_speed": "750", + "tf_medieval": "0", + "tf_medieval_autorp": "1", + "tf_mm_servermode": "1", + "tf_mm_strict": "0", + "tf_mm_trusted": "0", + "tf_mvm_death_penalty": "0", + "tf_mvm_min_players_to_start": "3", + "tf_overtime_nag": "0", + "tf_passtime_ball_carrier_regen_dmgtime": "3", + "tf_passtime_ball_carrier_regen_interval": "1", + "tf_passtime_ball_carrier_regen_maxpct": "1", + "tf_passtime_ball_carrier_regen_scale": "0.1f", + "tf_passtime_ball_damping_scale": "0.01f", + "tf_passtime_ball_drag_coefficient": "0.01f", + "tf_passtime_ball_inertia_scale": "1.0f", + "tf_passtime_ball_mass": "1.0f", + "tf_passtime_ball_model": "models/passtime/ball/passtime_ball.mdl", + "tf_passtime_ball_radius": "7.2f", + "tf_passtime_ball_reset_time": "15", + "tf_passtime_ball_rotdamping_scale": "1.0f", + "tf_passtime_ball_seek_range": "128", + "tf_passtime_ball_seek_speed_factor": "1.5f", + "tf_passtime_ball_takedamage": "1", + "tf_passtime_ball_takedamage_force": "800.0f", + "tf_passtime_flinch_boost": "0", + "tf_passtime_mode_homing_lock_sec": "1.5f", + "tf_passtime_mode_homing_speed": "1000.0f", + "tf_passtime_player_reticles_enemies": "1", + "tf_passtime_player_reticles_friends": "2", + "tf_passtime_score_crit_sec": "5.0f", + "tf_passtime_speedboost_on_get_ball_time": "2.0f", + "tf_passtime_steal_on_melee": "1", + "tf_passtime_teammate_steal_time": "45", + "tf_passtime_throwarc_demoman": "0.3f", + "tf_passtime_throwarc_engineer": "0.3f", + "tf_passtime_throwarc_heavy": "0.3f", + "tf_passtime_throwarc_medic": "0.3f", + "tf_passtime_throwarc_pyro": "0.3f", + "tf_passtime_throwarc_scout": "0.3f", + "tf_passtime_throwarc_sniper": "0.3f", + "tf_passtime_throwarc_soldier": "0.3f", + "tf_passtime_throwarc_spy": "0.3f", + "tf_passtime_throwspeed_demoman": "1000.0f", + "tf_passtime_throwspeed_engineer": "1000.0f", + "tf_passtime_throwspeed_heavy": "1000.0f", + "tf_passtime_throwspeed_medic": "1000.0f", + "tf_passtime_throwspeed_pyro": "1000.0f", + "tf_passtime_throwspeed_scout": "1000.0f", + "tf_passtime_throwspeed_sniper": "1000.0f", + "tf_passtime_throwspeed_soldier": "1000.0f", + "tf_passtime_throwspeed_spy": "1000.0f", + "tf_passtime_throwspeed_velocity_scale": "0", + "tf_playergib": "1", + "tf_player_name_change_time": "60", + "tf_powerup_mode": "0", + "tf_server_identity_disable_quickplay": "0", + "tf_spec_xray": "1", + "tf_spells_enabled": "0", + "tf_teamtalk": "1", + "tf_use_fixed_weaponspreads": "0", + "tf_weapon_criticals": "1", + "tf_weapon_criticals_melee": "1", + "thirdperson_version": "2.1.0", + "tidykick_version": "1.1.5A", + "tv_enable": "1", + "tv_password": "1", + "tv_relaypassword": "0", + "uberpunisher_version": "1.5.2", + "ufov_version": "1.2.0A", + "voiceannounce_ex_version": "2.0.0", + "votekick_switcher_version": "1.3.0A" +} diff --git a/Tests/Rules/tf2_sourcemod.raw b/Tests/Rules/tf2_sourcemod.raw new file mode 100644 index 0000000..412eecd --- /dev/null +++ b/Tests/Rules/tf2_sourcemod.raw @@ -0,0 +1,6 @@ +feffffff570100000600e004ffffffff450501616e74695f6632705f76657273696f6e00322e312e30006261636b7061636b5f74665f76657273696f6e00322e31312e3141006261636b7061636b5f7669657765725f76657273696f6e00312e312e3241006265746865686f7273656d616e6e5f76657273696f6e00312e3100636f6e6e6563745f6d6574686f645f76657273696f6e00312e322e304100636f6e6e6563745f76657273696f6e00312e322e3000636f6f70003000637573746f6d5f636861745f636f6c6f72735f6d7973716c5f76657273696f6e00312e312e334100637573746f6d5f636861745f636f6c6f72735f746f67676c655f76657273696f6e00322e302e304100637573746f6d5f636861745f636f6c6f72735f76657273696f6e00332e312e30410064656174686d61746368003100646563616c6672657175656e63790031300064796e616d69636d6f74645f76657273696f6e00322e322e337300656e68616e6365645f6974656d735f76657273696f6e00312e312e30410066616c73656d657373616765735f76657273696f6e00332e3100676f746f5f76657273696f6e00312e3200696d706572736f6e6174655f76657273696f6e00312e352e30006b6172746966795f76657273696f6e00312e352e3041006c6f63616c5f6974656d5f7365727665725f76657273696f6e00312e312e3541006d6574616d6f645f76657273696f6e00312e31302e362d64657656006d705f616c6c6f774e5043730031006d705f6175746f63726f7373686169720031006d705f6175746f7465616d62616c616e63650030006d705f64697361626c655f7265737061776e5f74696d65730031006d705f66616465746f626c61636b0030006d705f66616c6c64616d6167650030006d705f666c6173686c696768740030006d705f666f6f7473746570730031006d705f666f7263656175746f7465616d0030006d705f666f7263657265737061776e0031006d705f667261676c696d69740030006d705f667269656e646c79666972650030006d705f686967686c616e6465720030006d705f686f6c696461795f6e6f67696674730030006d705f6d617463685f656e645f61745f74696d656c696d69740031006d705f6d6178726f756e64730030006d705f7265737061776e7761766574696d650031302e30006d705f736372616d626c657465616d735f6175746f0030006d705f736372616d626c657465616d735f6175746f5f77696e646966666572656e63650033006d705f7374616c656d6174655f656e61626c650030006d705f7374616c656d6174655f6d656c65656f6e6c790030006d705f7465616d6c69737400686772756e743b736369656e74697374006d705f7465616d706c61790030006d705f74696d656c696d697400333030006d705f746f75726e616d656e740030006d705f746f75726e616d656e745f72656164796d6f64650030006d705f746f75726e616d656e745f72656164796d6f64655f636f756e74646f776e003130006d705f746f75726e616d656e745f72656164796d6f64655f6d696e0032006d705f746f75726e616d656e745f72656164796d6f64655f7465616d5f73697a650030006d705f746f75726e616d656e745f73746f7077617463680031006d705f776561706f6e737461790030006d705f77696e646966666572656e63650030006d705f77696e646966666572656e63655f6d696e0030 +feffffff570100000601e004006d705f77696e6c696d69740030006e6578746c6576656c00006e6f5f656e656d795f696e5f737061776e5f76657273696f6e00312e322e314100706c617965725f616e616c79746963735f76657273696f6e00312e332e3141007261696e626f77697a655f76657273696f6e00312e372e30410072706c617965725f76657273696f6e00312e3100725f416972626f61745669657744616d70656e44616d7000312e3000725f416972626f61745669657744616d70656e4672657100372e3000725f416972626f6174566965775a48656967687400302e3000725f4a6565705669657744616d70656e44616d7000312e3000725f4a6565705669657744616d70656e4672657100372e3000725f4a656570566965775a4865696768740031302e3000725f56656869636c655669657744616d70656e0031007362636865636b65725f76657273696f6e00312e302e320073625f76657273696f6e00312e342e3131007363705f76657273696f6e00322e312e304100736574756265725f76657273696f6e00312e3300736d646a5f76657273696f6e00322e362e3100736d5f61646d696e736d6974655f76657273696f6e00322e3100736d5f61696d6e616d65735f76657273696f6e00302e3800736d5f616c5f76657273696f6e00312e3000736d5f616d6d6f7061636b737061776e65725f76657273696f6e00312e302e3000736d5f616e7469636f6c6f7261627573655f76657273696f6e00312e302e3000736d5f62676f645f76657273696f6e00312e302e3100736d5f6268735f76657273696f6e00312e302e3000736d5f626c6565645f76657273696f6e00312e302e3000736d5f64657374726f795f76657273696f6e00312e322e3000736d5f646973636f5f76657273696f6e00302e332e3000736d5f66616b6567696674735f76657273696f6e00312e302e3100736d5f66616b656974656d5f76657273696f6e00312e332e3000736d5f66637661725f76657273696f6e00312e3100736d5f6669615f76657273696f6e00322e322e3400736d5f66756e636f6d6d616e6473785f76657273696f6e00322e3200736d5f676f646d6f64655f76657273696f6e00322e332e3100736d5f6865616c74687061636b5f737061776e65725f76657273696f6e00312e302e3000736d5f686f7273656d616e6e5f76657273696f6e00312e3100736d5f6d657261736d75735f76657273696f6e00312e342e3200736d5f6d6f6e6f737061776e5f76657273696f6e00312e312e3100736d5f6d757465636865636b5f76657273696f6e00312e392e324100736d5f6e6578746d61700074726164655f756e757375616c5f63656e7465725f763300736d5f6e6f6973656d616b65725f76657273696f6e00322e322e3000736d5f706f776572706c61795f76657273696f6e00312e352e336d00736d5f726166666c655f76657273696f6e00302e3900736d5f726567656e5f76657273696f6e00312e3000736d5f726573697a655f76657273696f6e00312e322e3000736d5f72776561706f6e735f76657273696f6e00312e3300736d5f736574616d6d6f5f76657273696f6e00312e312e3000736d5f736574636c6173735f63686174003100736d5f736574636c6173735f6c6f67003100736d5f736574636c6173735f76657273696f6e00312e322e3000736d5f73657473706565645f63686174003100736d5f736574737065 +feffffff570100000602e00465645f6c6f67003100736d5f73657473706565645f76657273696f6e00312e332e3100736d5f73687574646f776e5f636f756e74646f776e5f76657273696f6e00312e362e324100736d5f73707261795f76657273696f6e00352e386100736d5f7374756e6d6f645f76657273696f6e00312e342e342e3700736d5f7461756e745f76657273696f6e00302e3300736d5f74696479636861745f76657273696f6e00302e3400736d5f74726164657265705f76657273696f6e00312e302e324100736d5f757064617465725f76657273696f6e00312e322e3200736f75726365636f6d6d735f76657273696f6e00302e392e32363600736f757263656d6f645f76657273696f6e00312e372e332d6465762b3532343000737465616d7265705f636865636b65725f76657273696f6e00312e322e304100737465616d746f6f6c735f76657273696f6e00302e392e302b643564303833380073747269707065725f76657273696f6e00312e322e320073745f67616d65646573635f6f766572726964655f76657273696f6e00312e312e33410073765f616363656c65726174650031300073765f616972616363656c65726174650031300073765f616c6c74616c6b00310073765f626f756e636500300073765f63686561747300300073765f636f6e7461637400736572766963654066697265706f776572656467616d696e672e636f6d0073765f666f6f74737465707300310073765f6672696374696f6e00340073765f67726176697479003830300073765f6d61787370656564003332300073765f6d6178757372636d6470726f636573737469636b730032340073765f6e6f636c6970616363656c657261746500350073765f6e6f636c6970737065656400350073765f70617373776f726400300073765f7061757361626c6500300073765f726567697374726174696f6e5f6d657373616765004e6f206163636f756e74207370656369666965640073765f726567697374726174696f6e5f7375636365737366756c00300073765f726f6c6c616e676c6500300073765f726f6c6c7370656564003230300073765f73706563616363656c657261746500350073765f737065636e6f636c697000310073765f73706563737065656400330073765f737465616d67726f7570000073765f7374657073697a650031380073765f73746f707370656564003130300073765f746167730046697265506f77657265642c616c6c74616c6b2c6261636b7061636b2e74662c696e637265617365645f6d6178706c61796572732c6e6f5f6164732c6e6f6164732c6e6f70696e696f6e2c6e6f7265737061776e74696d652c74726164652c74726164696e672c756e757375616c0073765f766f696365656e61626c6500310073765f766f74655f71756f72756d5f726174696f00302e360073765f7761746572616363656c65726174650031300073765f77617465726672696374696f6e0031007465616d7377697463685f76657273696f6e00312e33007466326974656d735f67697665776561706f6e5f76657273696f6e00332e3134313539007466326974656d735f6d616e616765720031007466326974656d735f6d616e616765725f76657273696f6e00312e342e31007466326974656d735f76657273696f6e00312e362e32007466685f617072696c666f6f6c730030007466685f62697274686461790031007466685f65 +feffffff570100000603e0046e61626c65640031007466685f656e646f667468656c696e650030007466685f66756c6c6d6f6f6e0031007466685f68616c6c6f7765656e0030007466685f6e6f726d616c6865616c74680030007466685f76616c656e74696e65730030007466685f76657273696f6e00312e31302e32007466685f77696e74657200310074665f616c6c6f775f706c617965725f75736500300074665f6172656e615f6368616e67655f6c696d697400310074665f6172656e615f66697273745f626c6f6f6400310074665f6172656e615f666f7263655f636c61737300300074665f6172656e615f6d61785f73747265616b00330074665f6172656e615f6f766572726964655f6361705f656e61626c655f74696d65002d310074665f6172656e615f707265726f756e645f74696d650031300074665f6172656e615f726f756e645f74696d6500300074665f6172656e615f7573655f717565756500310074665f626574615f636f6e74656e7400300074665f626972746864617900300074665f626f745f636f756e7400300074665f636c6173736c696d697400300074665f6374665f626f6e75735f74696d650031300074665f64616d6167655f64697361626c6573707265616400310074665f666f7263655f686f6c69646179735f6f666600300074665f67616d656d6f64655f6172656e6100300074665f67616d656d6f64655f637000300074665f67616d656d6f64655f63746600300074665f67616d656d6f64655f6d766d00300074665f67616d656d6f64655f7061737374696d6500300074665f67616d656d6f64655f7061796c6f616400300074665f67616d656d6f64655f706400300074665f67616d656d6f64655f726400300074665f67616d656d6f64655f736400300074665f6d61785f6368617267655f7370656564003735300074665f6d6564696576616c00300074665f6d6564696576616c5f6175746f727000310074665f6d6d5f7365727665726d6f646500310074665f6d6d5f73747269637400300074665f6d6d5f7472757374656400300074665f6d766d5f64656174685f70656e616c747900300074665f6d766d5f6d696e5f706c61796572735f746f5f737461727400330074665f6f76657274696d655f6e616700300074665f7061737374696d655f62616c6c5f636172726965725f726567656e5f646d6774696d6500330074665f7061737374696d655f62616c6c5f636172726965725f726567656e5f696e74657276616c00310074665f7061737374696d655f62616c6c5f636172726965725f726567656e5f6d617870637400310074665f7061737374696d655f62616c6c5f636172726965725f726567656e5f7363616c6500302e31660074665f7061737374696d655f62616c6c5f64616d70696e675f7363616c6500302e3031660074665f7061737374696d655f62616c6c5f647261675f636f656666696369656e7400302e3031660074665f7061737374696d655f62616c6c5f696e65727469615f7363616c6500312e30660074665f7061737374696d655f62616c6c5f6d61737300312e30660074665f7061737374696d655f62616c6c5f6d6f64656c006d6f64656c732f7061737374696d652f62616c6c2f7061737374696d655f62616c6c2e6d646c0074665f7061737374696d655f62616c6c5f72616469757300372e32660074665f7061737374696d655f62616c6c5f7265736574 +feffffff570100000604e0045f74696d650031350074665f7061737374696d655f62616c6c5f726f7464616d70696e675f7363616c6500312e30660074665f7061737374696d655f62616c6c5f7365656b5f72616e6765003132380074665f7061737374696d655f62616c6c5f7365656b5f73706565645f666163746f7200312e35660074665f7061737374696d655f62616c6c5f74616b6564616d61676500310074665f7061737374696d655f62616c6c5f74616b6564616d6167655f666f726365003830302e30660074665f7061737374696d655f666c696e63685f626f6f737400300074665f7061737374696d655f6d6f64655f686f6d696e675f6c6f636b5f73656300312e35660074665f7061737374696d655f6d6f64655f686f6d696e675f737065656400313030302e30660074665f7061737374696d655f706c617965725f72657469636c65735f656e656d69657300310074665f7061737374696d655f706c617965725f72657469636c65735f667269656e647300320074665f7061737374696d655f73636f72655f637269745f73656300352e30660074665f7061737374696d655f7370656564626f6f73745f6f6e5f6765745f62616c6c5f74696d6500322e30660074665f7061737374696d655f737465616c5f6f6e5f6d656c656500310074665f7061737374696d655f7465616d6d6174655f737465616c5f74696d650034350074665f7061737374696d655f7468726f776172635f64656d6f6d616e00302e33660074665f7061737374696d655f7468726f776172635f656e67696e65657200302e33660074665f7061737374696d655f7468726f776172635f686561767900302e33660074665f7061737374696d655f7468726f776172635f6d6564696300302e33660074665f7061737374696d655f7468726f776172635f7079726f00302e33660074665f7061737374696d655f7468726f776172635f73636f757400302e33660074665f7061737374696d655f7468726f776172635f736e6970657200302e33660074665f7061737374696d655f7468726f776172635f736f6c6469657200302e33660074665f7061737374696d655f7468726f776172635f73707900302e33660074665f7061737374696d655f7468726f7773706565645f64656d6f6d616e00313030302e30660074665f7061737374696d655f7468726f7773706565645f656e67696e65657200313030302e30660074665f7061737374696d655f7468726f7773706565645f686561767900313030302e30660074665f7061737374696d655f7468726f7773706565645f6d6564696300313030302e30660074665f7061737374696d655f7468726f7773706565645f7079726f00313030302e30660074665f7061737374696d655f7468726f7773706565645f73636f757400313030302e30660074665f7061737374696d655f7468726f7773706565645f736e6970657200313030302e30660074665f7061737374696d655f7468726f7773706565645f736f6c6469657200313030302e30660074665f7061737374696d655f7468726f7773706565645f73707900313030302e30660074665f7061737374696d655f7468726f7773706565645f76656c6f636974795f7363616c6500300074665f706c6179657267696200310074665f706c617965725f6e616d655f6368616e67655f74696d650036300074665f706f77657275705f6d6f646500300074665f +feffffff570100000605e0047365727665725f6964656e746974795f64697361626c655f717569636b706c617900300074665f737065635f7872617900310074665f7370656c6c735f656e61626c656400300074665f7465616d74616c6b00310074665f7573655f66697865645f776561706f6e7370726561647300300074665f776561706f6e5f637269746963616c7300310074665f776561706f6e5f637269746963616c735f6d656c65650031007468697264706572736f6e5f76657273696f6e00322e312e3000746964796b69636b5f76657273696f6e00312e312e35410074765f656e61626c6500310074765f70617373776f726400310074765f72656c617970617373776f72640030007562657270756e69736865725f76657273696f6e00312e352e320075666f765f76657273696f6e00312e322e304100766f696365616e6e6f756e63655f65785f76657273696f6e00322e302e3000766f74656b69636b5f73776974636865725f76657273696f6e00312e332e304100 diff --git a/Tests/Tests.php b/Tests/Tests.php index ab4b4f4..819b590 100644 --- a/Tests/Tests.php +++ b/Tests/Tests.php @@ -27,7 +27,10 @@ public function Open( $Address, $Port, $Timeout, $Engine ) { - // + $this->Timeout = $Timeout; + $this->Engine = $Engine; + $this->Port = $Port; + $this->Ip = $Ip; } public function Write( $Header, $String = '' ) @@ -38,7 +41,7 @@ public function Read( $Length = 1400 ) { $Buffer = new Buffer( ); - $Buffer->Set( $this->PacketQueue->pop() ); + $Buffer->Set( $this->PacketQueue->shift() ); $this->ReadInternal( $Buffer, $Length, [ $this, 'Sherlock' ] ); @@ -47,7 +50,14 @@ public function Sherlock( $Buffer, $Length ) { - return false; + if( $this->PacketQueue->isEmpty() ) + { + return false; + } + + $Buffer->Set( $this->PacketQueue->shift() ); + + return $Buffer->GetLong( ) === -2; } } @@ -67,7 +77,7 @@ { $this->SourceQuery->Disconnect(); - unset( $this->SourceQuery ); + unset( $this->Socket, $this->SourceQuery ); } /** @@ -168,7 +178,46 @@ [ "\xff\xff\xff\xff\x49" ], // Correct type, but no data after [ "\xff\xff\xff\xff\x6D" ], // Old info packet, but tests are done for source [ "\xff\xff\xff\xff\x11" ], // Wrong type + [ "\x11\x11\x11\x11" ], // Wrong header [ "\xff" ], // Should be 4 bytes, but it's 1 ]; } + + /** + * @dataProvider RulesProvider + */ + public function testGetRules( $RawInput, $ExpectedOutput ) + { + $this->Socket->Queue( hex2bin( "ffffffff4104fce20e" ) ); // Challenge + + foreach( $RawInput as $Packet ) + { + $this->Socket->Queue( hex2bin( $Packet ) ); + } + + $RealOutput = $this->SourceQuery->GetRules(); + + foreach( $ExpectedOutput as $Key => $ExpectedValue ) + { + $this->assertEquals( $ExpectedValue, $RealOutput[ $Key ], $Key ); + } + } + + public function RulesProvider() + { + $DataProvider = []; + + $Files = glob( __DIR__ . '/Rules/*.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; + } }