It really depends on your narrative voice (i.e. who is telling the story to the reader). This is fine for Third Person Omniscient (the narrator is telling a story and knows all), Third Person Limited Omniscient (the narrator is telling the story and knows all from one character's perspective), First Person (The narrator is the main character) or First Person Epistol (The narrator is a character in the story but is relaying the story of another often in the form of a letter, a biography, or news report and is not privy to the main characters exact thoughts but may give voice to his own). It's not permissible in any Third Person Limited narrative (AKA "Camera Lense" In this style the narrator is only allowed to convey to the reader observable detail as if a security camera looking in on the events.).
It's been a while since I read the books, but I recall Harry Potter having this style where the narrator gave voice to Harry's internal monolog and emotions, (or on rare occasions, the focal character of the Chapter who was not Harry, such as Vernon Dursley in the first chapter of Book 1 or the Caretaker of the Riddle Family house in Book Four). In all examples, emotion of the focal chararacter is told by the narrator as if he and the focal character were the same person, but non-focal characters were only allowed to portray emotions by physical actions such as frowns, smiles, looks of smug satisfaction, ect.). Other styles would have the text phrased in a format of a dialog but not given quotation (Often Itilicized Text in Dialog format is used to covey thought monologs, but other methods exist to. In Animorphs, which had different degrees of telepathic communication, the Less Than/Greater Than symbols (<>) were substituted for quotation for the most common form of telepathic communication (called thought speech) and Underlined Dialog was used for a much rarer communication using true telepathy.).