Are you purposefully ignoring the facts surrounding the PoJ? Like the fact that it claims Joseph wasn't truly Mary's betrothed, but her "guardian" or "foster father" because he refused to marry her. (Another blatant contradiction to the scriptures.) It is a pure work of fiction, for example, in its opening section, Joachim goes into the desert to fast for 40 days and 40 nights. An obvious rip off of the Noahic flood. It says he will not eat or drink until God answers his prayers. This is in direct contrast to Luke 4:12: Jesus answered, "It is said: 'Do not put the Lord your God to the test. On and on and on. These are the reasons that scholars rejected PoJ.
-_- It never said she wasn't betrothed to him.
Noah never fasted prior to the flood, but for that matter, Christ fasted in the desert for 40 days and 40 nights. Was that a rip off?
Matthew 4:2 After fasting forty days and forty nights, he was hungry.
There are plenty of times, also, where people showed their devotion by prayer and fasting. They fasted in bereavement. They fasted when they desired something of the Lord. They fasted because a fast was a time when one dedicated himself to prayer and service to God in whatever method there was available. A fast was not simply abstinence from food. It was abstinence from doing things which would hinder one's service to God. God gave us examples of when this would work.
Now, when Christ said "do not put the Lord your God to the test," what did He mean? The Bible also says "put me to the test, says the Lord of hosts, if I will not open the windows of heaven for you and pour down for you a blessing until there is no more need."
Since there can be no contradiction, we must assume it isn't a blanket command, because such would contradict the declaration of God.
The context of the first is that Satan was tempting Christ to, basically, attempt suicide. This was taking the Scripture out of context to make it look like it was allowed for us to purposely harm ourselves.
The context of the second is to tithe to God, which is a command of God. It is saying, "follow my command, and see if I will not bless you."
As God does command and bless fasting, we can pretty well say that the fasting of Joachim falls under the second category.