Sahih Muslim , Book 1, Hadith 120 (In-Book)

It is reported on the authority of Abu Huraira that the Messenger of Allah (may peace and blessings of Allah be upon him) made observations like them embodied in the hadith narrated by Yahya b. Muhammad on the authority of 'Ala', and added to it: even if he observed fast and prayed and asserted that he was a Muslim.

وَحَدَّثَنِي أَبُو نَصْرٍ التَّمَّارُ، وَعَبْدُ الأَعْلَى بْنُ حَمَّادٍ، قَالاَ حَدَّثَنَا حَمَّادُ بْنُ سَلَمَةَ، عَنْ دَاوُدَ بْنِ أَبِي هِنْدٍ، عَنْ سَعِيدِ بْنِ الْمُسَيَّبِ، عَنْ أَبِي هُرَيْرَةَ، قَالَ قَالَ رَسُولُ اللَّهِ صلى الله عليه وسلم بِمِثْلِ حَدِيثِ يَحْيَى بْنِ مُحَمَّدٍ عَنِ الْعَلاَءِ ذَكَرَ فِيهِ ‏ "‏ وَإِنْ صَامَ وَصَلَّى وَزَعَمَ أَنَّهُ مُسْلِمٌ ‏" ‏ ‏.‏

sunnah.com