I have seen that more than once on DL (also previously also on NW) flights.
I thought it was a requirement that they do block the doors when the cockpit door is open. On Delta on a long flight the FA blocks the entrance with the carts and doesn't move until after the crew member is back in the cockpit (I can't remember if another FA goes in the cockpit or not while the pilot is in the lav). I used to fly southwest a lot, and they don't have carts and when the pilot has to use the restroom one of the FA's will just stand at the front and another goes in the cockpit while the pilot is in the lav.
I really have no idea how this helps though. In the case of delta, someone could simply just shove the cart out of the way (and the cart could be used as an item of defense by the FA or could also be used to harm the FA) and with WN, if someone is going to want in the cockpit having a FA just standing up front isn't going to stop someone.