Domesticated dogs were tested as well as undomesticated wolves. Both types of animals were allowed to beg for food from an attentive person and an inattentive person. Both species knew how to beg, suggesting that begging, and thereby reading the behavior of the human being most likely to supply a treat, is a natural trait of canines, not just a learned trait of domesticated animals (Richard Alleyne, "Dogs Can Instinctively Sense a Friendly Face," Telegraph.co.uk, June 10, 2011).
God designed His creation with the ability to adapt to various environments and situations. Dogs can learn, as can other animals, and develop a unique relationship with human beings.