The reason cupping was first disliked for the fasting person is that Jafar bin Ubayy Talib was cupped while fasting, and the Prophet ﷺ passed by him and said, "These two have broken their fast." Then the Prophet ﷺ later granted permission for cupping while fasting, and Anas used to be cupped while fasting.
أول ما كرهت الحجامة للصائم أن جعفر ابن أبي طالب احتجم وهو صائم، فمر به النبي ﷺ فقال: أفطر هذان. ثم رخص النبي ﷺ بعد في الحجامة للصائم، وكان أنس يحتجم وهو صائم.
No references are available.
Daraqutni narrated it (2260), and from him Bayhaqi (268/4), from Abu Qasim Abdullah bin Muhammad bin Abdul-Aziz, who said, Uthman bin Abu Shayba narrated to us, who said, Khalid bin Mukhlad narrated to us, who said, Abdullah bin Muthanna narrated to us, from Thabit Bunani, from Anas, and he related it.Daraqutni said, "All of them are trustworthy narrators, and I do not know of any defect in it."Bayhaqi said, after quoting Daraqutni's statement, "The hadith of Abu Saeed Khudri, with the wording of permission, supports this, for permission comes after prohibition."I say, Khalid bin Mukhlad, who is Qatawani, and his teacher Abdullah bin Muthanna, who is the son of Abdullah, the son of Anas bin Malik, the Ansari, the Basri, have both been criticized, but their hadith is hasan when their narration contains nothing objectionable. Both of them are among the men of the Sahih collections, and what preceded from the hadith of Abu Saeed Khudri corroborates them, as Bayhaqi said.There is nothing in the hadith of Anas that indicates Jafar bin Abu Talib had been cupped at the time of the conquest. Jafar was killed in the battle of Muta, and Muta was before the conquest. On this basis, some scholars said that it is a mistaken hadith. Rather, it contains what indicates that his cupping was before the battle of Muta, and Allah, Most High, knows best.Bayhaqi said, "We have narrated the permission for this from Saad bin Abu Waqqas, Abdullah bin Masud, Abdullah bin Abbas, Abdullah bin Amr, Husayn bin Ali, Zayd bin Arqam, Ayesha the daughter of Siddiq, and Umm Salama , all of them."Shafii held the view of abrogation, as in Umm (108/2-109), and from him Bayhaqi (268/4), after he related the hadith of Shaddad bin Aws from the time of the conquest, "The cupper and the one cupped have broken their fast." And the hadith of Sufyan, from Yazid bin Abu Ziyad, from Miqsam, from Ibn Abbas, "that the Prophet ﷺ was cupped while in ihram."He said, "Ibn Abbas did not accompany the Prophet ﷺ while in ihram before the Pilgrimage of Islam, so Ibn Abbas's mention of the Prophet's ﷺ cupping must be from the year of the Pilgrimage of Islam, the year ten, while the hadith 'the cupper and the one cupped have broken their fast' ﷺ is from the year eight, two years before the Pilgrimage of Islam. If both are established, then the hadith of Ibn Abbas is the abrogating one, and the hadith 'the cupper and the one cupped have broken their fast' is the abrogated one."And he said, "The chains of both hadiths together are uncertain, and the hadith of Ibn Abbas has the sounder chain of the two. If a man were to avoid cupping, that would be more preferable to me, as a precaution against his fast being weakened and thus broken. But if he is cupped, cupping does not break his fast. And alongside the hadith of Ibn Abbas, there is the analogy that I recall from some companions of the Prophet ﷺ, the successors, and the majority of the people of Madinah, that no one's fast is broken by cupping." End of quote.I say, this is also the view of Sufyan Thawri, Malik, and some of the people of Madinah.Drawing blood during the day in Ramadan for testing purposes is analogous to cupping, and the correct view is that it does not invalidate the fast.