PlayerMockService
Server-side home for the PlayerMocks a test stands up, and the discovery surface PlayerBinders
observe. Creating a mock through the service (rather than PlayerMock.new by hand) parents it into
the world and ties its lifetime to the service maid -- so tearing down the ServiceBag cleans up every
mock it made.
Replication is the default, mirroring how a real Player exists for every peer: any mock parented
into the DataModel (this service's or a hand-built one) is discovered by every PlayerMockService
and PlayerMockServiceClient in the place, across ServiceBags and realms -- which is what lets
TieInterfaces and Remoting bridge a server bag and a client bag in the same test.
Discovery and leak detection live in [PlayerMockServiceBase]: mocks may exist before this service boots (create and designate first, then boot -- production parity), and a leak is a mock that outlived the service that consumed it, not a mock that predates boot. There is one server per place, so only one server-realm service may be alive at a time.
local playerMockService = serviceBag:GetService(require("PlayerMockService"))
local player = playerMockService:CreatePlayer({ UserId = 12345 })
Functions
CreatePlayer
PlayerMockService:CreatePlayer(overrides: {[string]: any}?--
Per-property seed values, e.g. { UserId = 12345 } (see PlayerMock.new).
) → PlayerCreates a PlayerMock, parents it into Players -- where real players live, so the mock's subtree (PlayerGui, property backings) never hydrates instances inside Workspace -- and tracks it for cleanup. Parenting anywhere in the DataModel replicates it, so PlayerBinders and PlayerMockServiceClients in every bag discover it like a real join.