How to testfor a donkey in Minecraft

To "lock" the inventory, you could summon a mule with a saddle: /summon EntityHorse ~ ~ ~ {Type:2,Tame:0,SaddleItem:{id:329},ChestedHorse:1}. Summoning a horse that is not tame and giving it a saddle will make it rideable, with an inaccessable inventory. Also, testing for a mule will work using the /testfor @e[type=EntityHorse] {Type:2} syntax, so you may simply have an issue with your setup. I hope this helps!