A cgda $(A,d)$ is formal if it is weakly equivalent to $(H(A),0)$. There are several equivalent conditions for this. Similarly, a space $X$ is formal if the cgda $(A_{PL}(X),d)$ of polynomial differential forms is formal.
So far, so good. There is however a sentence in the book "Rational Homotopy theory" by Felix, Halperin, Thomas, that confuses me: "Thus $(A,d)$ and $X$ are formal if and only if their minimal sullivan model can be computed directly from their cohomology algebras". The reason why this confuses me, aside from the fact that it is not immediately clear to me why this is true, is that it seems from this sentence that the property of being formal can be read directly from the cohomology algebra $(H(A),0)$. Is this true? More precisely:
Question: [Edited after HenrikRüping comment] suppose that $X$ and $Y$ are spaces with isomorphic cohomology. Assume that $X$ is formal. is it true that $Y$ is formal as well?
Either a motivation for why this is true, or an example of a non-formal space with th same cohomology of a formal one, would be greatly appreciated!
I am mostly interested in spaces with the cohomology of spheres, at most one of which is even dimensional, but any more information on the subject would help me understand this a little better.